@@ -4,7 +4,6 @@ import {get} from '../constants'
4
4
import sx , { SxProp } from '../sx'
5
5
import { ItemInput } from './List'
6
6
import styled from 'styled-components'
7
- import { themeGet } from '..'
8
7
9
8
/**
10
9
* Contract for props passed to the `Item` component.
@@ -13,7 +12,7 @@ export interface ItemProps extends React.ComponentPropsWithoutRef<'div'>, SxProp
13
12
/**
14
13
* Primary text which names an `Item`.
15
14
*/
16
- text : string
15
+ text ? : string
17
16
18
17
/**
19
18
* Secondary text which provides additional information about an `Item`.
@@ -75,9 +74,9 @@ export interface ItemProps extends React.ComponentPropsWithoutRef<'div'>, SxProp
75
74
const getItemVariant = ( variant = 'default' , disabled ?: boolean ) => {
76
75
if ( disabled ) {
77
76
return {
78
- color : themeGet ( 'colors.text.disabled' ) ,
79
- iconColor : themeGet ( 'colors.text.disabled' ) ,
80
- annotationColor : themeGet ( 'colors.text.disabled' ) ,
77
+ color : get ( 'colors.text.disabled' ) ,
78
+ iconColor : get ( 'colors.text.disabled' ) ,
79
+ annotationColor : get ( 'colors.text.disabled' ) ,
81
80
hoverBackground : 'inherit' ,
82
81
hoverCursor : 'default'
83
82
}
@@ -86,18 +85,18 @@ const getItemVariant = (variant = 'default', disabled?: boolean) => {
86
85
switch ( variant ) {
87
86
case 'danger' :
88
87
return {
89
- color : themeGet ( 'colors.text.danger' ) ,
90
- iconColor : themeGet ( 'colors.icon.danger' ) ,
91
- annotationColor : themeGet ( 'colors.text.disabled' ) ,
92
- hoverBackground : themeGet ( 'colors.bg.danger' ) ,
88
+ color : get ( 'colors.text.danger' ) ,
89
+ iconColor : get ( 'colors.icon.danger' ) ,
90
+ annotationColor : get ( 'colors.text.disabled' ) ,
91
+ hoverBackground : get ( 'colors.bg.danger' ) ,
93
92
hoverCursor : 'pointer'
94
93
}
95
94
default :
96
95
return {
97
96
color : 'inherit' ,
98
- iconColor : themeGet ( 'colors.text.disabled' ) ,
99
- annotationColor : themeGet ( 'colors.text.disabled' ) ,
100
- hoverBackground : themeGet ( 'colors.selectMenu.tapHighlight' ) ,
97
+ iconColor : get ( 'colors.text.disabled' ) ,
98
+ annotationColor : get ( 'colors.text.disabled' ) ,
99
+ hoverBackground : get ( 'colors.selectMenu.tapHighlight' ) ,
101
100
hoverCursor : 'pointer'
102
101
}
103
102
}
@@ -179,6 +178,7 @@ export function Item(itemProps: Partial<ItemProps> & {item?: ItemInput}): JSX.El
179
178
disabled,
180
179
onAction,
181
180
onKeyPress,
181
+ children,
182
182
onClick,
183
183
...props
184
184
} = itemProps
@@ -224,10 +224,13 @@ export function Item(itemProps: Partial<ItemProps> & {item?: ItemInput}): JSX.El
224
224
< LeadingVisual />
225
225
</ LeadingVisualContainer >
226
226
) }
227
- < StyledTextContainer descriptionVariant = { descriptionVariant } >
228
- < div > { text } </ div >
229
- { description && < DescriptionContainer > { description } </ DescriptionContainer > }
230
- </ StyledTextContainer >
227
+ { children }
228
+ { ( text || description ) && (
229
+ < StyledTextContainer descriptionVariant = { descriptionVariant } >
230
+ { text && < div > { text } </ div > }
231
+ { description && < DescriptionContainer > { description } </ DescriptionContainer > }
232
+ </ StyledTextContainer >
233
+ ) }
231
234
{ ( TrailingIcon || trailingText ) && (
232
235
< TrailingVisualContainer variant = { variant } disabled = { disabled } >
233
236
{ trailingText && < div > { trailingText } </ div > }
0 commit comments