Skip to content

Commit 6073f1c

Browse files
authored
docs: improve custom render value S2 Picker example (#9682)
* docs: improve custom Render Value Picker example * fix empty tree story * fix order of TreeExampleStatic spread * revert EmptyTree back to original
1 parent f3e3157 commit 6073f1c

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

packages/@react-spectrum/tree/stories/TreeView.stories.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,7 @@ const DynamicTreeItem = (props) => {
317317
};
318318

319319
export const TreeExampleDynamic: StoryObj<typeof TreeView> = {
320+
...TreeExampleStatic,
320321
render: (args: SpectrumTreeViewProps<unknown>) => (
321322
<div style={{width: '300px', resize: 'both', height: '90vh', overflow: 'auto'}}>
322323
<TreeView disabledKeys={['reports-1AB']} aria-label="test dynamic tree" items={rows} onExpandedChange={action('onExpandedChange')} onSelectionChange={action('onSelectionChange')} {...args}>
@@ -331,7 +332,6 @@ export const TreeExampleDynamic: StoryObj<typeof TreeView> = {
331332
</TreeView>
332333
</div>
333334
),
334-
...TreeExampleStatic,
335335
parameters: undefined
336336
};
337337

packages/dev/s2-docs/pages/s2/Picker.mdx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -249,15 +249,16 @@ Use the `renderValue` prop to provide a custom element to display selected items
249249

250250
```tsx render
251251
"use client";
252-
import {Avatar, Picker, PickerItem, Text} from '@react-spectrum/s2';
253-
import {style} from '@react-spectrum/s2/style' with {type: 'macro'};
252+
import {Avatar, AvatarGroup, Picker, PickerItem, Text} from '@react-spectrum/s2';
254253

254+
///- begin collapse -///
255255
let users = [
256256
{id: 'abraham-baker', avatar: 'https://www.untitledui.com/images/avatars/abraham-baker', name: 'Abraham Baker', email: 'abraham@example.com'},
257257
{id: 'adriana-sullivan', avatar: 'https://www.untitledui.com/images/avatars/adriana-sullivan', name: 'Adriana Sullivan', email: 'adriana@example.com'},
258258
{id: 'jonathan-kelly', avatar: 'https://www.untitledui.com/images/avatars/jonathan-kelly', name: 'Jonathan Kelly', email: 'jonathan@example.com'},
259259
{id: 'zara-bush', avatar: 'https://www.untitledui.com/images/avatars/zara-bush', name: 'Zara Bush', email: 'zara@example.com'}
260260
];
261+
///- end collapse -///
261262

262263
function Example() {
263264
return (
@@ -268,11 +269,11 @@ function Example() {
268269
selectionMode={"multiple"}
269270
///- begin highlight -///
270271
renderValue={(selectedItems) => (
271-
<div className={style({ display: 'flex', gap: 4, height: '80%' })}>
272+
<AvatarGroup aria-label="Selected users">
272273
{selectedItems.map(item => (
273-
<Avatar slot={null} key={item.id} src={item.avatar} alt={item.name} />
274+
<Avatar key={item.id} src={item.avatar} alt={item.name} />
274275
))}
275-
</div>
276+
</AvatarGroup>
276277
)}
277278
///- end highlight -///
278279
>

0 commit comments

Comments
 (0)