mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-13 21:05:19 +00:00
init: the first public commit for AFFiNE
This commit is contained in:
52
libs/components/ui/src/divider/Divider.tsx
Normal file
52
libs/components/ui/src/divider/Divider.tsx
Normal file
@@ -0,0 +1,52 @@
|
||||
import type { FC, ReactNode, CSSProperties } from 'react';
|
||||
import { styled } from '../styled';
|
||||
import { MuiDivider } from '../mui';
|
||||
import type { MuiDividerProps } from '../mui';
|
||||
|
||||
interface DividerProps {
|
||||
orientation?: 'horizontal' | 'vertical';
|
||||
textAlign?: 'center' | 'start' | 'end';
|
||||
children?: ReactNode;
|
||||
className?: string;
|
||||
style?: CSSProperties;
|
||||
}
|
||||
|
||||
const _textAlignMap: Record<
|
||||
DividerProps['textAlign'],
|
||||
MuiDividerProps['textAlign']
|
||||
> = {
|
||||
center: 'center',
|
||||
start: 'left',
|
||||
end: 'right',
|
||||
};
|
||||
|
||||
export const Divider: FC<DividerProps> = ({
|
||||
orientation = 'horizontal',
|
||||
textAlign = 'center',
|
||||
children,
|
||||
}) => {
|
||||
return (
|
||||
<StyledMuiDivider
|
||||
orientation={orientation}
|
||||
textAlign={_textAlignMap[textAlign]}
|
||||
variant="fullWidth"
|
||||
>
|
||||
{children}
|
||||
</StyledMuiDivider>
|
||||
);
|
||||
};
|
||||
|
||||
const StyledMuiDivider = styled(MuiDivider)<Pick<DividerProps, 'orientation'>>(
|
||||
({ orientation }) => {
|
||||
if (orientation === 'horizontal') {
|
||||
return {
|
||||
marginTop: '6px',
|
||||
marginBottom: '6px',
|
||||
};
|
||||
}
|
||||
return {
|
||||
marginLeft: '6px',
|
||||
marginRight: '6px',
|
||||
};
|
||||
}
|
||||
);
|
||||
1
libs/components/ui/src/divider/index.ts
Normal file
1
libs/components/ui/src/divider/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export * from './Divider';
|
||||
Reference in New Issue
Block a user