mirror of
https://github.com/toeverything/AFFiNE.git
synced 2024-12-24 01:41:41 +03:00
chore: simplify panel
This commit is contained in:
parent
7820fd7b34
commit
196fe993b3
@ -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 };
|
||||
|
@ -62,7 +62,7 @@ const GroupBy = ({ closePanel }: { closePanel: () => void }) => {
|
||||
};
|
||||
|
||||
return (
|
||||
<Panel extraStyle={panelStyle}>
|
||||
<Panel style={panelStyle}>
|
||||
<Item disabled>
|
||||
<div>COLUMN</div>
|
||||
</Item>
|
||||
|
@ -24,7 +24,7 @@ const Sorter = ({
|
||||
};
|
||||
|
||||
return (
|
||||
<Panel extraStyle={extraStyle}>
|
||||
<Panel style={extraStyle}>
|
||||
<GroupBySelector />
|
||||
<div>
|
||||
<Title>
|
||||
|
Loading…
Reference in New Issue
Block a user