File tree Expand file tree Collapse file tree 5 files changed +24
-12
lines changed
Expand file tree Collapse file tree 5 files changed +24
-12
lines changed Original file line number Diff line number Diff line change @@ -152,11 +152,11 @@ export const ItemAction = forwardRef(function ItemAction(
152152 allProps : CubeItemActionProps ,
153153 ref : FocusableRef < HTMLElement > ,
154154) {
155- const { type : contextType } = useItemActionContext ( ) ;
155+ const { type : contextType , theme : contextTheme } = useItemActionContext ( ) ;
156156
157157 const {
158158 type = contextType ?? 'neutral' ,
159- theme = 'default' ,
159+ theme = contextTheme ?? 'default' ,
160160 icon,
161161 children,
162162 isLoading = false ,
@@ -238,6 +238,10 @@ export const ItemAction = forwardRef(function ItemAction(
238238 return { } ;
239239 } , [ tooltip ] ) ;
240240
241+ const finalType = useMemo ( ( ) => {
242+ return theme !== 'default' && type === 'neutral' ? 'clear' : type ;
243+ } , [ theme , type ] ) ;
244+
241245 // Render function that accepts tooltip trigger props and ref
242246 const renderButton = (
243247 tooltipTriggerProps ?: HTMLAttributes < HTMLElement > ,
@@ -267,9 +271,9 @@ export const ItemAction = forwardRef(function ItemAction(
267271 return (
268272 < ItemActionElement
269273 { ...mergedProps }
270- variant = { `${ theme } .${ type } ` as ItemActionVariant }
274+ variant = { `${ theme } .${ finalType } ` as ItemActionVariant }
271275 data-theme = { theme }
272- data-type = { type }
276+ data-type = { finalType }
273277 tabIndex = { finalTabIndex }
274278 >
275279 { finalIcon && < div data-element = "Icon" > { finalIcon } </ div > }
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ import { CubeItemBaseProps } from '../content/ItemBase';
44
55interface ItemActionContextValue {
66 type ?: CubeItemBaseProps [ 'type' ] ;
7+ theme ?: 'default' | 'danger' | 'success' | 'special' | ( string & { } ) ;
78}
89
910const ItemActionContext = createContext < ItemActionContextValue | undefined > (
@@ -12,11 +13,13 @@ const ItemActionContext = createContext<ItemActionContextValue | undefined>(
1213
1314export interface ItemActionProviderProps {
1415 type ?: CubeItemBaseProps [ 'type' ] ;
16+ theme ?: 'default' | 'danger' | 'success' | 'special' | ( string & { } ) ;
1517 children : ReactNode ;
1618}
1719
1820export function ItemActionProvider ( {
1921 type,
22+ theme,
2023 children,
2124} : ItemActionProviderProps ) {
2225 return (
@@ -28,6 +31,7 @@ export function ItemActionProvider({
2831 : type === 'secondary'
2932 ? 'clear'
3033 : type ,
34+ theme,
3135 } }
3236 >
3337 { children }
Original file line number Diff line number Diff line change @@ -168,7 +168,7 @@ const ItemButton = forwardRef(function ItemButton(
168168 }
169169 >
170170 { button }
171- < ItemActionProvider type = { type } >
171+ < ItemActionProvider type = { type } theme = { theme } >
172172 { showActionsOnHover ? (
173173 < DisplayTransition
174174 exposeUnmounted
Original file line number Diff line number Diff line change @@ -1991,13 +1991,11 @@ export const ItemsWithActions = (props) => {
19911991 < >
19921992 < ItemAction
19931993 icon = { < EditIcon /> }
1994- aria-label = "Edit"
19951994 tooltip = "Edit"
19961995 onPress = { ( ) => handleItemAction ( 'file1' , 'edit' ) }
19971996 />
19981997 < ItemAction
19991998 icon = { < ClearIcon /> }
2000- aria-label = "Delete"
20011999 tooltip = "Delete"
20022000 onPress = { ( ) => handleItemAction ( 'file1' , 'delete' ) }
20032001 />
@@ -2013,12 +2011,14 @@ export const ItemsWithActions = (props) => {
20132011 < >
20142012 < Menu . Item . Action
20152013 icon = { < EditIcon /> }
2016- aria-label = "Edit"
2014+ tooltip = "Edit"
2015+ theme = "danger"
20172016 onPress = { ( ) => handleItemAction ( 'file2' , 'edit' ) }
20182017 />
20192018 < Menu . Item . Action
20202019 icon = { < ClearIcon /> }
2021- aria-label = "Delete"
2020+ tooltip = "Delete"
2021+ theme = "danger"
20222022 onPress = { ( ) => handleItemAction ( 'file2' , 'delete' ) }
20232023 />
20242024 </ >
@@ -2033,12 +2033,14 @@ export const ItemsWithActions = (props) => {
20332033 < >
20342034 < ItemAction
20352035 icon = { < EditIcon /> }
2036- aria-label = "Edit"
2036+ tooltip = "Edit"
2037+ theme = "success"
20372038 onPress = { ( ) => handleItemAction ( 'file3' , 'edit' ) }
20382039 />
20392040 < ItemAction
20402041 icon = { < ClearIcon /> }
2041- aria-label = "Delete"
2042+ tooltip = "Delete"
2043+ theme = "success"
20422044 onPress = { ( ) => handleItemAction ( 'file3' , 'delete' ) }
20432045 />
20442046 </ >
Original file line number Diff line number Diff line change @@ -840,7 +840,9 @@ const ItemBase = <T extends HTMLElement = HTMLDivElement>(
840840 { actions && (
841841 < div data-element = "Actions" { ...ACTIONS_EVENT_HANDLERS } >
842842 { actions !== true ? (
843- < ItemActionProvider type = { type } > { actions } </ ItemActionProvider >
843+ < ItemActionProvider type = { type } theme = { theme } >
844+ { actions }
845+ </ ItemActionProvider >
844846 ) : null }
845847 </ div >
846848 ) }
You can’t perform that action at this time.
0 commit comments