@@ -7,6 +7,8 @@ import { Icon } from '../Icon'
7
7
import { getTooltipProps } from '../SelectPicker/common'
8
8
import { ActionMenuItemProps } from './types'
9
9
10
+ const COMMON_ACTION_MENU_ITEM_CLASS = 'flex-grow-1 flex left top dc__gap-8 py-6 px-8'
11
+
10
12
export const ActionMenuItem = < T extends string | number > ( {
11
13
item,
12
14
itemRef,
@@ -52,19 +54,25 @@ export const ActionMenuItem = <T extends string | number>({
52
54
53
55
const renderContent = ( ) => (
54
56
< >
55
- < Tooltip content = { label } placement = "right" >
56
- < span className = { `m-0 fs-13 fw-4 lh-20 dc__truncate ${ isNegativeType ? 'cr-5' : 'cn-9' } ` } > { label } </ span >
57
- </ Tooltip >
58
- { description &&
59
- ( typeof description === 'string' ? (
60
- < span
61
- className = { `m-0 fs-12 fw-4 lh-18 cn-7 ${ ! disableDescriptionEllipsis ? 'dc__ellipsis-right__2nd-line' : 'dc__word-break' } ` }
62
- >
63
- { description }
57
+ { renderIcon ( startIcon ) }
58
+ < span >
59
+ < Tooltip content = { label } placement = "right" >
60
+ < span className = { `m-0 fs-13 fw-4 lh-20 dc__truncate ${ isNegativeType ? 'cr-5' : 'cn-9' } ` } >
61
+ { label }
64
62
</ span >
65
- ) : (
66
- description
67
- ) ) }
63
+ </ Tooltip >
64
+ { description &&
65
+ ( typeof description === 'string' ? (
66
+ < span
67
+ className = { `m-0 fs-12 fw-4 lh-18 cn-7 ${ ! disableDescriptionEllipsis ? 'dc__ellipsis-right__2nd-line' : 'dc__word-break' } ` }
68
+ >
69
+ { description }
70
+ </ span >
71
+ ) : (
72
+ description
73
+ ) ) }
74
+ </ span >
75
+ { renderIcon ( endIcon ) }
68
76
</ >
69
77
)
70
78
@@ -74,7 +82,7 @@ export const ActionMenuItem = <T extends string | number>({
74
82
return (
75
83
< a
76
84
ref = { itemRef as LegacyRef < HTMLAnchorElement > }
77
- className = "flex-grow-1"
85
+ className = { COMMON_ACTION_MENU_ITEM_CLASS }
78
86
href = { item . href }
79
87
target = "_blank"
80
88
rel = "noreferrer"
@@ -84,7 +92,11 @@ export const ActionMenuItem = <T extends string | number>({
84
92
)
85
93
case 'link' :
86
94
return (
87
- < Link ref = { itemRef as Ref < HTMLAnchorElement > } className = "flex-grow-1" to = { item . to } >
95
+ < Link
96
+ ref = { itemRef as Ref < HTMLAnchorElement > }
97
+ className = { COMMON_ACTION_MENU_ITEM_CLASS }
98
+ to = { item . to }
99
+ >
88
100
{ renderContent ( ) }
89
101
</ Link >
90
102
)
@@ -94,7 +106,7 @@ export const ActionMenuItem = <T extends string | number>({
94
106
< button
95
107
ref = { itemRef as LegacyRef < HTMLButtonElement > }
96
108
type = "button"
97
- className = " dc__transparent p-0 flex-grow-1"
109
+ className = { ` dc__transparent ${ COMMON_ACTION_MENU_ITEM_CLASS } ` }
98
110
>
99
111
{ renderContent ( ) }
100
112
</ button >
@@ -111,13 +123,11 @@ export const ActionMenuItem = <T extends string | number>({
111
123
onMouseEnter = { onMouseEnter }
112
124
tabIndex = { - 1 }
113
125
// Intentionally added margin to the left and right to have the gap on the edges of the options
114
- className = { `action-menu__option br-4 flex left top dc__gap-8 mr-4 ml-4 py-6 px-8 ${ isDisabled ? 'dc__disabled' : 'cursor' } ${ isNegativeType ? 'dc__hover-r50' : 'dc__hover-n50' } ${ isFocused ? `action-menu__option--focused${ isNegativeType ? '-negative' : '' } ` : '' } ` }
126
+ className = { `action-menu__option br-4 mr-4 ml-4 ${ isDisabled ? 'dc__disabled' : 'cursor' } ${ isNegativeType ? 'dc__hover-r50' : 'dc__hover-n50' } ${ isFocused ? `action-menu__option--focused${ isNegativeType ? '-negative' : '' } ` : '' } ` }
115
127
onClick = { ! isDisabled ? handleClick : undefined }
116
128
aria-disabled = { isDisabled }
117
129
>
118
- { renderIcon ( startIcon ) }
119
130
{ renderComponent ( ) }
120
- { renderIcon ( endIcon ) }
121
131
</ li >
122
132
</ Tooltip >
123
133
)
0 commit comments