Skip to content

Commit bb05fdc

Browse files
authored
docs(RSP): clean up TreeView docs (#6959)
* add maxWidth to examples * dedupe items
1 parent a5679cd commit bb05fdc

File tree

1 file changed

+6
-46
lines changed

1 file changed

+6
-46
lines changed

packages/@react-spectrum/tree/docs/TreeView.mdx

Lines changed: 6 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ keywords: [tree, grid]
5151
## Example
5252

5353
```tsx example
54-
<TreeView aria-label="Example tree with static contents" defaultExpandedKeys={new Set(['documents', 'photos'])} height="size-4600">
54+
<TreeView aria-label="Example tree with static contents" defaultExpandedKeys={new Set(['documents', 'photos'])} height="size-4600" maxWidth="size-6000">
5555
<TreeViewItem id="documents" textValue="Documents">
5656
<Text>Documents</Text>
5757
<Folder />
@@ -125,7 +125,7 @@ let items: MyItem[] = [
125125

126126
function ExampleTree(props) {
127127
return (
128-
<TreeView aria-label="Example tree with dynamic content" height="size-3000" items={items} {...props}>
128+
<TreeView aria-label="Example tree with dynamic content" height="size-3000" maxWidth="size-6000" items={items} {...props}>
129129
{(item: MyItem) => (
130130
<TreeViewItem childItems={item.childItems} textValue={item.name}>
131131
<Text>{item.name}</Text>
@@ -337,7 +337,7 @@ This behavior is slightly different in the highlight selection style, where sing
337337
Tree items may also be links to another page or website. This can be achieved by passing the `href` prop to the `<TreeViewItem>` component. Links behave the same way as described above for item actions depending on the `selectionMode` and `selectionStyle`.
338338

339339
```tsx example
340-
<TreeView aria-label="Example tree with links" defaultExpandedKeys={new Set(['bookmarks'])} height="size-2000">
340+
<TreeView aria-label="Example tree with links" defaultExpandedKeys={new Set(['bookmarks'])} height="size-2000" maxWidth="size-6000">
341341
<TreeViewItem id="bookmarks" textValue="Bookmarks">
342342
<Text>Bookmarks</Text>
343343
<Folder />
@@ -364,27 +364,7 @@ The `<TreeViewItem>` component works with frameworks and client side routers lik
364364
### With action groups
365365

366366
```tsx example
367-
type MyItem = {
368-
id: string,
369-
name: string,
370-
icon: JSX.Element,
371-
childItems?: MyItem[]
372-
};
373-
374-
let items: MyItem[] = [
375-
{id: 'projects', name: 'Projects', icon: <Folder />, childItems: [
376-
{id: 'project-1', name: 'Project 1', icon: <FileTxt />},
377-
{id: 'project-2', name: 'Project 2', icon: <Folder />, childItems: [
378-
{id: 'document-a', name: 'Document A', icon: <FileTxt />},
379-
{id: 'document-b', name: 'Document B', icon: <FileTxt />},
380-
]}
381-
]},
382-
{id: 'reports', name: 'Reports', icon: <Folder />, childItems: [
383-
{id: 'report-1', name: 'Reports 1', icon: <FileTxt />}
384-
]}
385-
];
386-
387-
<TreeView aria-label="Example tree with action groups" height="size-3000" items={items}>
367+
<TreeView aria-label="Example tree with action groups" height="size-3000" maxWidth="size-6000" items={items}>
388368
{(item: MyItem) => (
389369
<TreeViewItem childItems={item.childItems} textValue={item.name}>
390370
<Text>{item.name}</Text>
@@ -407,27 +387,7 @@ let items: MyItem[] = [
407387
### With action menus
408388

409389
```tsx example
410-
type MyItem = {
411-
id: string,
412-
name: string,
413-
icon: JSX.Element,
414-
childItems?: MyItem[]
415-
};
416-
417-
let items: MyItem[] = [
418-
{id: 'projects', name: 'Projects', icon: <Folder />, childItems: [
419-
{id: 'project-1', name: 'Project 1', icon: <FileTxt />},
420-
{id: 'project-2', name: 'Project 2', icon: <Folder />, childItems: [
421-
{id: 'document-a', name: 'Document A', icon: <FileTxt />},
422-
{id: 'document-b', name: 'Document B', icon: <FileTxt />},
423-
]}
424-
]},
425-
{id: 'reports', name: 'Reports', icon: <Folder />, childItems: [
426-
{id: 'report-1', name: 'Reports 1', icon: <FileTxt />}
427-
]}
428-
];
429-
430-
<TreeView aria-label="Example tree with action menus" height="size-3000" items={items}>
390+
<TreeView aria-label="Example tree with action menus" height="size-3000" maxWidth="size-6000" items={items}>
431391
{(item: MyItem) => (
432392
<TreeViewItem childItems={item.childItems} textValue={item.name}>
433393
<Text>{item.name}</Text>
@@ -477,7 +437,7 @@ function renderEmptyState() {
477437
);
478438
}
479439

480-
<TreeView aria-label="Example tree for empty state" height="size-2400" renderEmptyState={renderEmptyState}>
440+
<TreeView aria-label="Example tree for empty state" height="size-2400" maxWidth="size-6000" renderEmptyState={renderEmptyState}>
481441
{[]}
482442
</TreeView>
483443
```

0 commit comments

Comments
 (0)