@@ -22,10 +22,15 @@ import {
22
22
withFrameProps ,
23
23
} from '../../../utils/frameProps' ;
24
24
import { TransientProps } from '../../../utils/transientProps' ;
25
+ import { Icon , IconName } from '../../Icon/Icon' ;
26
+ import { Row } from '../../Flex/Flex' ;
25
27
26
28
export const allowedSelectBarFrameProps = [ 'margin' , 'width' ] as const satisfies FramePropsKeys [ ] ;
27
29
type AllowedFrameProps = Pick < FrameProps , ( typeof allowedSelectBarFrameProps ) [ number ] > ;
28
30
31
+ export const fillTypes = [ 'none' , 'default' ] as const ;
32
+ export type FillType = ( typeof fillTypes ) [ number ] ;
33
+
29
34
const Wrapper = styled . div < TransientProps < AllowedFrameProps > & { $isFullWidth ?: boolean } > `
30
35
display: flex;
31
36
align-items: center;
@@ -63,14 +68,16 @@ const Options = styled.div<{
63
68
$optionsCount : number ;
64
69
$isFullWidth ?: boolean ;
65
70
$elevation : Elevation ;
71
+ $fillType : FillType ;
66
72
} > `
67
73
position: relative;
68
74
display: grid;
69
75
grid-auto-columns: ${ ( { $optionsCount } ) => `minmax(${ getPuckWidth ( $optionsCount ) } , 1fr)` } ;
70
76
grid-auto-flow: column;
71
77
gap: ${ spacingsPx . xxs } ;
72
78
padding: ${ spacingsPx . xxs } ;
73
- background: ${ mapElevationToBackground } ;
79
+ background: ${ ( { $fillType, theme, $elevation } ) =>
80
+ $fillType === 'default' ? mapElevationToBackground ( { theme, $elevation } ) : undefined } ;
74
81
border-radius: ${ borders . radii . full } ;
75
82
width: ${ ( { $isFullWidth } ) => ( $isFullWidth ? '100%' : 'auto' ) } ;
76
83
@@ -156,6 +163,7 @@ type ValueTypes = number | string | boolean;
156
163
type Option < V extends ValueTypes > = {
157
164
label : ReactNode ;
158
165
value : V ;
166
+ icon ?: IconName ;
159
167
} ;
160
168
161
169
export type SelectBarProps < V extends ValueTypes > = {
@@ -167,6 +175,7 @@ export type SelectBarProps<V extends ValueTypes> = {
167
175
isFullWidth ?: boolean ;
168
176
className ?: string ;
169
177
'data-testid' ?: string ;
178
+ fillType ?: FillType ;
170
179
} & AllowedFrameProps ;
171
180
172
181
// Generic type V is determined by selectedOption/options values
@@ -178,6 +187,7 @@ export const SelectBar = <V extends ValueTypes>({
178
187
isDisabled = false ,
179
188
isFullWidth,
180
189
className,
190
+ fillType = 'default' ,
181
191
'data-testid' : dataTest ,
182
192
...rest
183
193
} : SelectBarProps < V > ) => {
@@ -247,6 +257,7 @@ export const SelectBar = <V extends ValueTypes>({
247
257
$optionsCount = { options . length }
248
258
$isFullWidth = { isFullWidth }
249
259
$elevation = { elevation }
260
+ $fillType = { fillType }
250
261
>
251
262
< Puck
252
263
$optionsCount = { options . length }
@@ -256,22 +267,38 @@ export const SelectBar = <V extends ValueTypes>({
256
267
onKeyDown = { handleKeyboardNav }
257
268
/>
258
269
259
- { options . map ( option => (
260
- < Option
261
- key = { String ( option . value ) }
262
- onClick = { handleOptionClick ( option ) }
263
- $isDisabled = { ! ! isDisabled }
264
- $isSelected = {
265
- selectedOptionIn !== undefined
266
- ? selectedOptionIn === option . value
267
- : false
268
- }
269
- data-testid = { `select-bar/${ String ( option . value ) } ` }
270
- >
270
+ { options . map ( option => {
271
+ const content = option . icon ? (
272
+ < Row gap = { spacings . xs } >
273
+ < Icon
274
+ name = { option . icon }
275
+ size = "medium"
276
+ variant = { selectedOptionIn === option . value ? 'primary' : undefined }
277
+ />
278
+ < span > { option . label } </ span >
279
+ </ Row >
280
+ ) : (
271
281
< span > { option . label } </ span >
272
- < WidthMock > { option . label } </ WidthMock >
273
- </ Option >
274
- ) ) }
282
+ ) ;
283
+
284
+ return (
285
+ < Option
286
+ key = { String ( option . value ) }
287
+ onClick = { handleOptionClick ( option ) }
288
+ $isDisabled = { ! ! isDisabled }
289
+ $isSelected = {
290
+ selectedOptionIn !== undefined
291
+ ? selectedOptionIn === option . value
292
+ : false
293
+ }
294
+ data-testid = { `select-bar/${ String ( option . value ) } ` }
295
+ >
296
+ { content }
297
+
298
+ < WidthMock > { content } </ WidthMock >
299
+ </ Option >
300
+ ) ;
301
+ } ) }
275
302
</ Options >
276
303
</ Wrapper >
277
304
) ;
0 commit comments