fix: #516 commneu menu style

This commit is contained in:
DiamondThree 2022-07-28 17:37:24 +08:00
parent 31c8747f33
commit 27a0b02bdb
3 changed files with 96 additions and 105 deletions

View File

@ -59,7 +59,7 @@ const GroupActionWrapper = styled('div')(({ theme }) => ({
const GroupContainer = styled('div')<{ isSelect?: boolean }>( const GroupContainer = styled('div')<{ isSelect?: boolean }>(
({ isSelect, theme }) => ({ ({ isSelect, theme }) => ({
background: theme.affine.palette.white, background: theme.affine.palette.white,
border: '2px solid #ECF1FB', border: '2px solid rgba(236,241,251,.5)',
padding: '15px 12px', padding: '15px 12px',
borderRadius: '10px', borderRadius: '10px',
...(isSelect ...(isSelect

View File

@ -1,7 +1,7 @@
import React, { useState, useCallback } from 'react'; import React, { useState, useCallback } from 'react';
import style9 from 'style9'; import style9 from 'style9';
import { import {
MuiPopover, Popover,
styled, styled,
type SvgIconProps, type SvgIconProps,
Tooltip, Tooltip,
@ -32,15 +32,6 @@ export const MenuDropdownItem = ({
null null
); );
const handle_open_dropdown_menu = useCallback(
(event: React.MouseEvent<HTMLButtonElement>) => {
event.preventDefault();
event.stopPropagation();
set_anchor_ele(event.currentTarget);
},
[]
);
const handle_close_dropdown_menu = useCallback(() => { const handle_close_dropdown_menu = useCallback(() => {
set_anchor_ele(null); set_anchor_ele(null);
}, []); }, []);
@ -50,40 +41,10 @@ export const MenuDropdownItem = ({
return ( return (
<> <>
<Tooltip <Popover
trigger="click"
placement="bottom-start"
content={ content={
<div style={{ padding: '2px 4px' }}>
<p>{name}</p>
{shortcut && <p>{shortcut}</p>}
</div>
}
placement="bottom"
trigger="hover"
>
<button
onClick={handle_open_dropdown_menu}
className={styles('currentDropdownButton')}
aria-label={name}
onMouseDown={e => {
// prevent toolbar from taking focus away from editor
e.preventDefault();
e.stopPropagation();
}}
>
<MenuIcon sx={{ width: 20, height: 20 }} />
<ArrowDropDownIcon sx={{ width: 20, height: 20 }} />
</button>
</Tooltip>
<MuiPopover
id={anchor_ele ? 'inline-menu-pop' : undefined}
open={Boolean(anchor_ele)}
anchorEl={anchor_ele}
onClose={handle_close_dropdown_menu}
anchorOrigin={{
horizontal: 'left',
vertical: 40,
}}
>
<div className={styles('dropdownContainer')}> <div className={styles('dropdownContainer')}>
{children.map(item => { {children.map(item => {
const { const {
@ -108,7 +69,8 @@ export const MenuDropdownItem = ({
editor, editor,
type: itemNameKey, type: itemNameKey,
anchorNodeId: anchorNodeId:
selectionInfo?.anchorNode?.id, selectionInfo?.anchorNode
?.id,
}); });
} }
handle_close_dropdown_menu(); handle_close_dropdown_menu();
@ -139,14 +101,43 @@ export const MenuDropdownItem = ({
// } // }
/> />
{/* <ItemIcon sx={{ width: 20, height: 20 }} /> */} {/* <ItemIcon sx={{ width: 20, height: 20 }} /> */}
<span className={styles('dropdownItemItext')}> <span
className={styles('dropdownItemItext')}
>
{name} {name}
</span> </span>
</button> </button>
); );
})} })}
</div> </div>
</MuiPopover> } // id={anchor_ele ? 'inline-menu-pop' : undefined}
// open={Boolean(anchor_ele)}
// anchorEl={anchor_ele}
// onClose={handle_close_dropdown_menu}
// anchorOrigin={{
// horizontal: 'left',
// vertical: 40,
// }}
>
<Tooltip
content={
<div style={{ padding: '2px 4px' }}>
<p>{name}</p>
{shortcut && <p>{shortcut}</p>}
</div>
}
placement="top"
trigger="hover"
>
<button
className={styles('currentDropdownButton')}
aria-label={name}
>
<MenuIcon sx={{ width: 20, height: 20 }} />
<ArrowDropDownIcon sx={{ width: 20, height: 20 }} />
</button>
</Tooltip>
</Popover>
</> </>
); );
}; };

View File

@ -45,7 +45,7 @@ export const MenuIconItem = ({
{shortcut && <p>{shortcut}</p>} {shortcut && <p>{shortcut}</p>}
</div> </div>
} }
placement="bottom" placement="top"
trigger="hover" trigger="hover"
> >
<button <button