feat: modify option menu style (#1506)
This commit is contained in:
@@ -77,6 +77,7 @@ export const EditorOptionMenu = () => {
|
|||||||
{mode === 'page' ? t('Edgeless') : t('Page')}
|
{mode === 'page' ? t('Edgeless') : t('Page')}
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
<Menu
|
<Menu
|
||||||
|
width={248}
|
||||||
placement="left-start"
|
placement="left-start"
|
||||||
content={
|
content={
|
||||||
<>
|
<>
|
||||||
@@ -124,6 +125,7 @@ export const EditorOptionMenu = () => {
|
|||||||
<>
|
<>
|
||||||
<FlexWrapper alignItems="center" justifyContent="center">
|
<FlexWrapper alignItems="center" justifyContent="center">
|
||||||
<Menu
|
<Menu
|
||||||
|
width={276}
|
||||||
content={EditMenu}
|
content={EditMenu}
|
||||||
placement="bottom-end"
|
placement="bottom-end"
|
||||||
disablePortal={true}
|
disablePortal={true}
|
||||||
|
|||||||
@@ -1,15 +1,23 @@
|
|||||||
import { TooltipProps } from '@mui/material';
|
import { TooltipProps } from '@mui/material';
|
||||||
|
import { CSSProperties } from 'react';
|
||||||
|
|
||||||
import { Popper, type PopperProps } from '../popper';
|
import { Popper, type PopperProps } from '../popper';
|
||||||
import { StyledMenuWrapper } from './styles';
|
import { StyledMenuWrapper } from './styles';
|
||||||
export const Menu = (props: PopperProps & Omit<TooltipProps, 'title'>) => {
|
|
||||||
const { content, placement = 'bottom-start', children } = props;
|
export type MenuProps = {
|
||||||
|
width?: CSSProperties['width'];
|
||||||
|
} & PopperProps &
|
||||||
|
Omit<TooltipProps, 'title'>;
|
||||||
|
export const Menu = (props: MenuProps) => {
|
||||||
|
const { width, content, placement = 'bottom-start', children } = props;
|
||||||
return content ? (
|
return content ? (
|
||||||
<Popper
|
<Popper
|
||||||
{...props}
|
{...props}
|
||||||
showArrow={false}
|
showArrow={false}
|
||||||
content={
|
content={
|
||||||
<StyledMenuWrapper placement={placement}>{content}</StyledMenuWrapper>
|
<StyledMenuWrapper width={width} placement={placement}>
|
||||||
|
{content}
|
||||||
|
</StyledMenuWrapper>
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
{children}
|
{children}
|
||||||
|
|||||||
@@ -1,10 +1,14 @@
|
|||||||
import { ArrowRightSmallIcon } from '@blocksuite/icons';
|
import { ArrowRightSmallIcon } from '@blocksuite/icons';
|
||||||
|
import { CSSProperties } from 'react';
|
||||||
|
|
||||||
import { displayFlex, styled } from '../../styles';
|
import { displayFlex, styled } from '../../styles';
|
||||||
import StyledPopperContainer from '../shared/Container';
|
import StyledPopperContainer from '../shared/Container';
|
||||||
|
|
||||||
export const StyledMenuWrapper = styled(StyledPopperContainer)(({ theme }) => {
|
export const StyledMenuWrapper = styled(StyledPopperContainer)<{
|
||||||
|
width?: CSSProperties['width'];
|
||||||
|
}>(({ theme, width }) => {
|
||||||
return {
|
return {
|
||||||
|
width,
|
||||||
background: theme.colors.popoverBackground,
|
background: theme.colors.popoverBackground,
|
||||||
padding: '8px 4px',
|
padding: '8px 4px',
|
||||||
fontSize: '14px',
|
fontSize: '14px',
|
||||||
@@ -16,10 +20,11 @@ export const StyledMenuWrapper = styled(StyledPopperContainer)(({ theme }) => {
|
|||||||
|
|
||||||
export const StyledArrow = styled(ArrowRightSmallIcon)({
|
export const StyledArrow = styled(ArrowRightSmallIcon)({
|
||||||
position: 'absolute',
|
position: 'absolute',
|
||||||
right: 0,
|
right: '12px',
|
||||||
top: 0,
|
top: 0,
|
||||||
bottom: 0,
|
bottom: 0,
|
||||||
margin: 'auto',
|
margin: 'auto',
|
||||||
|
fontSize: '20px',
|
||||||
});
|
});
|
||||||
|
|
||||||
export const StyledMenuItem = styled('button')<{
|
export const StyledMenuItem = styled('button')<{
|
||||||
@@ -29,7 +34,7 @@ export const StyledMenuItem = styled('button')<{
|
|||||||
width: '100%',
|
width: '100%',
|
||||||
borderRadius: '5px',
|
borderRadius: '5px',
|
||||||
padding: '0 14px',
|
padding: '0 14px',
|
||||||
fontSize: '14px',
|
fontSize: theme.font.base,
|
||||||
height: '32px',
|
height: '32px',
|
||||||
...displayFlex('flex-start', 'center'),
|
...displayFlex('flex-start', 'center'),
|
||||||
cursor: isDir ? 'pointer' : '',
|
cursor: isDir ? 'pointer' : '',
|
||||||
|
|||||||
Reference in New Issue
Block a user