mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-14 21:27:20 +00:00
feat: add Menu component
This commit is contained in:
2
packages/app/src/ui/menu/index.ts
Normal file
2
packages/app/src/ui/menu/index.ts
Normal file
@@ -0,0 +1,2 @@
|
||||
export * from './menu';
|
||||
export { StyledMenuItem as MenuItem } from './styles';
|
||||
20
packages/app/src/ui/menu/menu.tsx
Normal file
20
packages/app/src/ui/menu/menu.tsx
Normal file
@@ -0,0 +1,20 @@
|
||||
import { Popper, type PopperProps } from '../popper';
|
||||
import { TooltipProps } from '@mui/material';
|
||||
import { StyledMenuWrapper } from '@/ui/menu/styles';
|
||||
|
||||
export const Menu = (props: PopperProps & Omit<TooltipProps, 'title'>) => {
|
||||
const { content, placement = 'bottom-start', children } = props;
|
||||
return content ? (
|
||||
<Popper
|
||||
{...props}
|
||||
showArrow={false}
|
||||
content={
|
||||
<StyledMenuWrapper placement={placement}>{content}</StyledMenuWrapper>
|
||||
}
|
||||
>
|
||||
{children}
|
||||
</Popper>
|
||||
) : null;
|
||||
};
|
||||
|
||||
export default Menu;
|
||||
34
packages/app/src/ui/menu/styles.ts
Normal file
34
packages/app/src/ui/menu/styles.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
import { styled } from '@/styles';
|
||||
import StyledPopperContainer from '../shared/Container';
|
||||
|
||||
export const StyledMenuWrapper = styled(StyledPopperContainer)(({ theme }) => {
|
||||
return {
|
||||
background: theme.colors.popoverBackground,
|
||||
padding: '8px 4px',
|
||||
fontSize: '14px',
|
||||
backgroundColor: theme.colors.popoverBackground,
|
||||
boxShadow: theme.shadow.popover,
|
||||
color: theme.colors.popoverColor,
|
||||
};
|
||||
});
|
||||
|
||||
export const StyledMenuItem = styled('div')<{ popperVisible?: boolean }>(
|
||||
({ theme, popperVisible }) => {
|
||||
return {
|
||||
borderRadius: '5px',
|
||||
padding: '0 14px',
|
||||
|
||||
color: popperVisible
|
||||
? theme.colors.primaryColor
|
||||
: theme.colors.popoverColor,
|
||||
backgroundColor: popperVisible
|
||||
? theme.colors.hoverBackground
|
||||
: 'transparent',
|
||||
|
||||
':hover': {
|
||||
color: theme.colors.primaryColor,
|
||||
backgroundColor: theme.colors.hoverBackground,
|
||||
},
|
||||
};
|
||||
}
|
||||
);
|
||||
Reference in New Issue
Block a user