@@ -26,8 +26,12 @@ export type MenuItem = {
26
26
export type ToolbarButtonWithPopupMenuProps = Omit <
27
27
ToolbarBaseProps < ActionStorage > & {
28
28
icon : ToolbarIconData ;
29
+ iconClassName ?: string ;
30
+ chevronIconClassName ?: string ;
29
31
title : string | ( ( ) => string ) ;
30
32
menuItems : MenuItem [ ] ;
33
+ /** @default 'classic' */
34
+ _selectionType ?: 'classic' | 'light' ;
31
35
} ,
32
36
'editor'
33
37
> ;
@@ -37,8 +41,11 @@ export const ToolbarButtonWithPopupMenu: React.FC<ToolbarButtonWithPopupMenuProp
37
41
focus,
38
42
onClick,
39
43
icon,
44
+ iconClassName,
45
+ chevronIconClassName,
40
46
title,
41
47
menuItems,
48
+ _selectionType,
42
49
} ) => {
43
50
const buttonRef = React . useRef < HTMLButtonElement > ( null ) ;
44
51
const [ open , , hide , toggleOpen ] = useBooleanState ( false ) ;
@@ -48,7 +55,7 @@ export const ToolbarButtonWithPopupMenu: React.FC<ToolbarButtonWithPopupMenuProp
48
55
menuItems . map ( ( i ) => ( { ...i , group : i . group || '' } ) ) ,
49
56
'group' ,
50
57
) ,
51
- [ menuItems , groupBy ] ,
58
+ [ menuItems ] ,
52
59
) ;
53
60
54
61
const someActive = menuItems . some (
@@ -64,6 +71,14 @@ export const ToolbarButtonWithPopupMenu: React.FC<ToolbarButtonWithPopupMenuProp
64
71
}
65
72
} , [ hide , shouldForceHide ] ) ;
66
73
74
+ const [ btnView , btnSelected ] =
75
+ _selectionType === 'light'
76
+ ? ( [
77
+ popupOpen ? 'normal' : someActive ? 'flat-action' : 'flat' ,
78
+ popupOpen && someActive ,
79
+ ] as const )
80
+ : ( [ someActive || popupOpen ? 'normal' : 'flat' , someActive ] as const ) ;
81
+
67
82
return (
68
83
< >
69
84
< ActionTooltip
@@ -75,15 +90,15 @@ export const ToolbarButtonWithPopupMenu: React.FC<ToolbarButtonWithPopupMenuProp
75
90
< Button
76
91
size = "m"
77
92
ref = { buttonRef }
78
- view = { someActive || popupOpen ? 'normal' : 'flat' }
79
- selected = { someActive }
93
+ view = { btnView }
94
+ selected = { btnSelected }
80
95
disabled = { everyDisabled }
81
96
className = { b ( null , [ className ] ) }
82
97
onClick = { toggleOpen }
83
98
>
84
- < Icon data = { icon . data } size = { icon . size } />
99
+ < Icon data = { icon . data } size = { icon . size } className = { iconClassName } />
85
100
{ '' }
86
- < Icon data = { ChevronDown } />
101
+ < Icon data = { ChevronDown } className = { chevronIconClassName } />
87
102
</ Button >
88
103
</ ActionTooltip >
89
104
< Popup anchorRef = { buttonRef } open = { popupOpen } onClose = { hide } >
0 commit comments