chore: simplify panel
This commit is contained in:
@@ -1,33 +1,25 @@
|
|||||||
import { styled } from '@toeverything/components/ui';
|
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 }>(
|
const StyledPanel = styled('div')(() => ({
|
||||||
({ extraStyle }) => ({
|
|
||||||
position: 'absolute',
|
position: 'absolute',
|
||||||
top: 50,
|
top: 50,
|
||||||
background: '#FFFFFF',
|
background: '#FFFFFF',
|
||||||
boxShadow: '0px 1px 10px rgba(152, 172, 189, 0.6)',
|
boxShadow: '0px 1px 10px rgba(152, 172, 189, 0.6)',
|
||||||
borderRadius: 10,
|
borderRadius: 10,
|
||||||
padding: '12px 24px',
|
padding: '12px 24px',
|
||||||
...extraStyle,
|
}));
|
||||||
})
|
|
||||||
);
|
|
||||||
|
|
||||||
const Panel = ({
|
const Panel = forwardRef<HTMLDivElement, ComponentPropsWithRef<'div'>>(
|
||||||
children,
|
({ onClick, ...rest }, ref) => {
|
||||||
extraStyle,
|
const stopPropagation = (e: MouseEvent<HTMLDivElement>) => {
|
||||||
}: {
|
onClick?.(e);
|
||||||
children: ReactNode;
|
|
||||||
extraStyle?: CSSProperties;
|
|
||||||
}) => {
|
|
||||||
const stopPropagation = (e: MouseEvent<HTMLDivElement>) =>
|
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
|
|
||||||
return (
|
|
||||||
<StyledPanel style={extraStyle} onClick={stopPropagation}>
|
|
||||||
{children}
|
|
||||||
</StyledPanel>
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
return <StyledPanel ref={ref} onClick={stopPropagation} {...rest} />;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
export { Panel };
|
export { Panel };
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ const GroupBy = ({ closePanel }: { closePanel: () => void }) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Panel extraStyle={panelStyle}>
|
<Panel style={panelStyle}>
|
||||||
<Item disabled>
|
<Item disabled>
|
||||||
<div>COLUMN</div>
|
<div>COLUMN</div>
|
||||||
</Item>
|
</Item>
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ const Sorter = ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Panel extraStyle={extraStyle}>
|
<Panel style={extraStyle}>
|
||||||
<GroupBySelector />
|
<GroupBySelector />
|
||||||
<div>
|
<div>
|
||||||
<Title>
|
<Title>
|
||||||
|
|||||||
Reference in New Issue
Block a user