perf(MobilePageContentContainer): improve style performance

This commit is contained in:
Zeke Zhang 2024-10-30 15:49:44 +08:00
parent 58ed5229c1
commit f3d7795a1e
2 changed files with 3 additions and 20 deletions

View File

@ -9,10 +9,8 @@
import _ from 'lodash';
import React, { FC, useEffect } from 'react';
import { useStyles } from './styles';
export const MobilePageContentContainer: FC<{ hideTabBar?: boolean }> = ({ children, hideTabBar }) => {
const { styles } = useStyles();
const [mobileTabBarHeight, setMobileTabBarHeight] = React.useState(0);
const [mobilePageHeader, setMobilePageHeader] = React.useState(0);
useEffect(() => {
@ -29,11 +27,13 @@ export const MobilePageContentContainer: FC<{ hideTabBar?: boolean }> = ({ child
<>
{mobilePageHeader ? <div style={{ height: mobilePageHeader }}></div> : null}
<div
className={`${styles.mobilePageContent} mobile-page-content`}
className="mobile-page-content"
data-testid="mobile-page-content"
style={{
height: `calc(100% - ${(mobileTabBarHeight || 0) + (mobilePageHeader || 0)}px)`,
boxSizing: 'border-box',
maxWidth: '100%',
overflowX: 'hidden',
}}
>
{children}

View File

@ -1,17 +0,0 @@
/**
* This file is part of the NocoBase (R) project.
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
* Authors: NocoBase Team.
*
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
* For more information, please refer to: https://www.nocobase.com/agreement.
*/
import { createStyles } from 'antd-style';
export const useStyles = createStyles(() => ({
mobilePageContent: {
maxWidth: '100%',
overflowX: 'hidden',
},
}));