Skip to content

Commit

Permalink
🦺 feat: update styles & props
Browse files Browse the repository at this point in the history
  • Loading branch information
ONLY-yours committed Dec 4, 2023
1 parent 7785cc1 commit decb858
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 46 deletions.
88 changes: 45 additions & 43 deletions src/Layout/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { DraggablePanel } from '@ant-design/pro-editor';
import { FlexProps, TabsProps } from 'antd';
import { Size } from 're-resizable';
import { ReactNode } from 'react';
import { Flexbox } from 'react-layout-kit';
import { Flexbox, FlexboxProps } from 'react-layout-kit';
import { ConfigProvider } from '../ConfigProvider';
import { getPrefixCls } from '../theme';
import { useStyle } from './style';
Expand All @@ -16,7 +16,7 @@ interface HeaderFooterSettings {
children?: ReactNode;
}

interface LayoutProps {
interface LayoutProps extends FlexboxProps {
header?: HeaderFooterSettings;
footer?: HeaderFooterSettings;
leftPannel?: PannelSettings;
Expand All @@ -39,51 +39,53 @@ interface PannelSettings {
className?: string;
}

const getPannelProps = (
index: number,
):
| {
placement: 'left' | 'right' | 'bottom';
className?: string;
defaultSize?: Partial<Size>;
}
| false => {
switch (['left', 'right', 'bottom', 'center'][index]) {
case 'left':
return {
placement: 'left',
defaultSize: {
width: '200',
},
};
case 'right':
return {
placement: 'right',
defaultSize: {
width: '200',
},
};
case 'bottom':
return {
placement: 'bottom',
defaultSize: {
height: '200',
},
};
case 'center':
return false;
default:
return false;
}
};

const BasicLayout = (props: LayoutProps) => {
const { header, footer, leftPannel, rightPannel, bottomPannel, centerPannel, type, ...rest } =
props;

const prefixCls = getPrefixCls('layout');
const { styles, cx } = useStyle(prefixCls);

const getPannelProps = (
index: number,
):
| {
placement: 'left' | 'right' | 'bottom';
className?: string;
defaultSize?: Partial<Size>;
}
| false => {
switch (['left', 'right', 'bottom', 'center'][index]) {
case 'left':
return {
placement: 'left',
className: styles.leftPannel,
defaultSize: {
width: '200',
},
};
case 'right':
return {
placement: 'right',
className: styles.rightPannel,
defaultSize: {
width: '200',
},
};
case 'bottom':
return {
placement: 'bottom',
defaultSize: {
height: '200',
},
};
case 'center':
return false;
default:
return false;
}
};

const DraggablePanelRender = (props: PannelSettings, index: number) => {
const {
children = '',
Expand All @@ -101,7 +103,7 @@ const BasicLayout = (props: LayoutProps) => {
</div>
);
}
const { placement } = pannelProps;
const { placement, className: pannelClassName } = pannelProps;
return (
<DraggablePanel
expandable={false}
Expand All @@ -112,7 +114,7 @@ const BasicLayout = (props: LayoutProps) => {
{...pannelProps}
{...rest}
>
<div className={cx(styles.pannel, className)}>{children}</div>
<div className={cx(styles.pannel, pannelClassName, className)}>{children}</div>
</DraggablePanel>
);
};
Expand Down Expand Up @@ -153,7 +155,7 @@ const BasicLayout = (props: LayoutProps) => {
);
};

const WrapperLayout = (props) => {
const WrapperLayout = (props: LayoutProps) => {
return (
<ConfigProvider>
<BasicLayout {...props} />
Expand Down
9 changes: 6 additions & 3 deletions src/Layout/style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,18 @@ export const useStyle = createStyles(({ css, token, cx }, prefixCls: string) =>
`${prefixCls}-header`,
css`
height: 48px;
min-height: 48px;
border-radius: ${token.borderRadius}px;
background-color: ${token.colorFillQuaternary};
margin-bottom: ${token.margin / 4}px;
margin: ${token.margin / 4}px;
`,
),
footer: cx(
`${prefixCls}-footer`,
css`
height: 28px;
width: 100%;
margin-top: ${token.margin / 4}px;
margin: ${token.margin / 4}px;
background-color: ${token.colorFillQuaternary};
`,
),
Expand Down Expand Up @@ -62,9 +63,11 @@ export const useStyle = createStyles(({ css, token, cx }, prefixCls: string) =>
background-color: ${token.colorFillQuaternary};
margin: ${token.margin / 4 + 2}px;
height: calc(100% - ${token.margin / 2 + 1}px);
width: calc(100% - ${token.margin / 2 + 1}px);
`,
),

leftPannel: cx(`${prefixCls}-left-pannel`, css``),
rightPannel: cx(`${prefixCls}-right-pannel`, css``),
tip: cx(
`${prefixCls}-tip`,
css`
Expand Down

0 comments on commit decb858

Please sign in to comment.