12
12
13
13
import { action } from '@storybook/addon-actions' ;
14
14
import Audio from '@spectrum-icons/workflow/Audio' ;
15
+ import { Avatar } from '@react-spectrum/avatar' ;
15
16
import { ComponentMeta , ComponentStoryObj } from '@storybook/react' ;
16
17
import { Item , SpectrumTagGroupProps , TagGroup } from '../src' ;
17
18
import React , { useState } from 'react' ;
@@ -123,7 +124,43 @@ export const MaxRowsOnRemove: TagGroupStory = {
123
124
storyName : 'maxRows + onRemove'
124
125
} ;
125
126
127
+ export const WithAvatar : TagGroupStory = {
128
+ args : { items : [ { key : '1' , label : 'Cool Person 1' } , { key : '2' , label : 'Cool Person 2' } ] } ,
129
+ render : ( args ) => (
130
+ < TagGroup aria-label = "Tag group with avatars" { ...args } >
131
+ { ( item : any ) => (
132
+ < Item key = { item . key } textValue = { item . label } >
133
+ < Avatar src = "https://i.imgur.com/kJOwAdv.png" alt = "default Adobe avatar" />
134
+ < Text > { item . label } </ Text >
135
+ </ Item >
136
+ ) }
137
+ </ TagGroup >
138
+ ) ,
139
+ storyName : 'with avatar'
140
+ } ;
141
+
142
+ export const WithAvatarOnRemove : TagGroupStory = {
143
+ render : ( args ) => < OnRemoveExample withAvatar { ...args } /> ,
144
+ storyName : 'with avatar + onRemove'
145
+ } ;
146
+
147
+ export const WithAction : TagGroupStory = {
148
+ args : { onAction : action ( 'clear' ) , actionLabel : 'Clear' } ,
149
+ storyName : 'with action'
150
+ } ;
151
+
152
+ export const WithActionAndMaxRows : TagGroupStory = {
153
+ args : {
154
+ maxRows : 2 ,
155
+ onAction : action ( 'clear' ) ,
156
+ actionLabel : 'Clear'
157
+ } ,
158
+ decorators : [ ( Story ) => < ResizableContainer > { < Story /> } </ ResizableContainer > ] ,
159
+ storyName : 'with action and maxRows'
160
+ } ;
161
+
126
162
function OnRemoveExample ( props ) {
163
+ let { withAvatar, ...otherProps } = props ;
127
164
let [ items , setItems ] = useState ( [
128
165
{ id : 1 , label : 'Cool Tag 1' } ,
129
166
{ id : 2 , label : 'Another cool tag' } ,
@@ -139,26 +176,14 @@ function OnRemoveExample(props) {
139
176
} ;
140
177
141
178
return (
142
- < TagGroup allowsRemoving aria-label = "Tag group with removable tags" items = { items } onRemove = { key => onRemove ( key ) } { ...props } >
179
+ < TagGroup allowsRemoving aria-label = "Tag group with removable tags" items = { items } onRemove = { key => onRemove ( key ) } { ...otherProps } >
143
180
{ ( item : any ) => (
144
- < Item > { item . label } </ Item >
181
+ < Item key = { item . key } textValue = { item . label } >
182
+ { withAvatar && < Avatar src = "https://i.imgur.com/kJOwAdv.png" alt = "default Adobe avatar" /> }
183
+ < Text > { item . label } </ Text >
184
+ </ Item >
145
185
) }
146
186
</ TagGroup >
147
187
) ;
148
188
}
149
189
150
- export const WithAction : TagGroupStory = {
151
- args : { onAction : action ( 'clear' ) , actionLabel : 'Clear' } ,
152
- storyName : 'with action'
153
- } ;
154
-
155
- export const WithActionAndMaxRows : TagGroupStory = {
156
- args : {
157
- maxRows : 2 ,
158
- onAction : action ( 'clear' ) ,
159
- actionLabel : 'Clear'
160
- } ,
161
- decorators : [ ( Story ) => < ResizableContainer > { < Story /> } </ ResizableContainer > ] ,
162
- storyName : 'with action and maxRows'
163
- } ;
164
-
0 commit comments