chore: simplify panel

This commit is contained in:
lawvs 2022-07-27 18:30:17 +08:00
parent 7820fd7b34
commit 196fe993b3
3 changed files with 22 additions and 30 deletions

View File

@ -1,33 +1,25 @@
import { styled } from '@toeverything/components/ui';
import type { ReactNode, MouseEvent, CSSProperties } from 'react';
import type { ComponentPropsWithRef, MouseEvent } from 'react';
import { forwardRef } from 'react';
const StyledPanel = styled('div')<{ extraStyle?: CSSProperties }>(
({ extraStyle }) => ({
position: 'absolute',
top: 50,
background: '#FFFFFF',
boxShadow: '0px 1px 10px rgba(152, 172, 189, 0.6)',
borderRadius: 10,
padding: '12px 24px',
...extraStyle,
})
const StyledPanel = styled('div')(() => ({
position: 'absolute',
top: 50,
background: '#FFFFFF',
boxShadow: '0px 1px 10px rgba(152, 172, 189, 0.6)',
borderRadius: 10,
padding: '12px 24px',
}));
const Panel = forwardRef<HTMLDivElement, ComponentPropsWithRef<'div'>>(
({ onClick, ...rest }, ref) => {
const stopPropagation = (e: MouseEvent<HTMLDivElement>) => {
onClick?.(e);
e.stopPropagation();
};
return <StyledPanel ref={ref} onClick={stopPropagation} {...rest} />;
}
);
const Panel = ({
children,
extraStyle,
}: {
children: ReactNode;
extraStyle?: CSSProperties;
}) => {
const stopPropagation = (e: MouseEvent<HTMLDivElement>) =>
e.stopPropagation();
return (
<StyledPanel style={extraStyle} onClick={stopPropagation}>
{children}
</StyledPanel>
);
};
export { Panel };

View File

@ -62,7 +62,7 @@ const GroupBy = ({ closePanel }: { closePanel: () => void }) => {
};
return (
<Panel extraStyle={panelStyle}>
<Panel style={panelStyle}>
<Item disabled>
<div>COLUMN</div>
</Item>

View File

@ -24,7 +24,7 @@ const Sorter = ({
};
return (
<Panel extraStyle={extraStyle}>
<Panel style={extraStyle}>
<GroupBySelector />
<div>
<Title>