Skip to content

Commit

Permalink
optimize(packages): optimized code
Browse files Browse the repository at this point in the history
  • Loading branch information
mufeng889 committed Aug 23, 2024
1 parent a084d21 commit 4f6a2e1
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions packages/materials/src/libs/admin-layout/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type FC, useMemo } from 'react';
import { type FC } from 'react';
import classNames from 'classnames';
import type { AdminLayoutProps } from '../../types';
import { LAYOUT_MAX_Z_INDEX, LAYOUT_SCROLL_EL_ID, createLayoutCssVars } from './shared';
Expand Down Expand Up @@ -66,21 +66,21 @@ const AdminLayout: FC<AdminLayoutProps> = ({
const fixedHeaderAndTab = fixedTop || (isHorizontal && isWrapperScroll);

// css
const leftGapClass = useMemo(() => {
const leftGapClass = () => {
if (!fullContent && showSider) {
return siderCollapse ? style['left-gap_collapsed'] : style['left-gap'];
}
return '';
}, [siderCollapse, showSider, fullContent]);
const headerLeftGapClass = isVertical ? leftGapClass : '';
};
const headerLeftGapClass = isVertical ? leftGapClass() : '';

const footerLeftGapClass = () => {
const condition1 = isVertical;
const condition2 = isHorizontal && isWrapperScroll && !fixedFooter;
const condition3 = Boolean(isHorizontal && rightFooter);

if (condition1 || condition2 || condition3) {
return leftGapClass;
return leftGapClass();
}

return '';
Expand Down Expand Up @@ -147,7 +147,7 @@ const AdminLayout: FC<AdminLayoutProps> = ({
commonClass,
tabClass,
{ 'top-0!': fullContent || !showHeader },
leftGapClass,
leftGapClass(),
{ 'absolute left-0 w-full': fixedHeaderAndTab }
)}
>
Expand Down Expand Up @@ -204,7 +204,7 @@ const AdminLayout: FC<AdminLayoutProps> = ({
{/* Main Content */}
<main
id={isContentScroll ? scrollElId : ''}
className={classNames('flex flex-col flex-grow bg-layout', commonClass, contentClass, leftGapClass, {
className={classNames('flex flex-col flex-grow bg-layout', commonClass, contentClass, leftGapClass(), {
'overflow-y-auto': isContentScroll
})}
>
Expand Down

0 comments on commit 4f6a2e1

Please sign in to comment.