Skip to content

Commit 96ba67e

Browse files
feat(tree-view): new web component (#19027)
* feat(tree-view): web component * feat(tree-view): add withcontrolled expansion * fix(tree-view): more additions * fix(tree-node): if statement * fix(tree-node): add click option to node * fix(tree-view): cleanup * fix(tree-view): click and missing roles * fix(tree-node): left arrow fix * fix(tree): tab issues * fix(tree-node-link): style * fix(tree-view): cleanup * fix(tree-view): suggestions * fix(tree-view): missing parenthsis * fix(tree-view): react story use button * fix(tree-node): update * fix(tree-view): resolve comments --------- Co-authored-by: kennylam <909118+kennylam@users.noreply.github.com>
1 parent 4a48452 commit 96ba67e

File tree

11 files changed

+1216
-19
lines changed

11 files changed

+1216
-19
lines changed

packages/react/src/components/TreeView/TreeView.mdx

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ expanded or collapsed.
6262
]}
6363
/>
6464

65-
## With Custom Icons
65+
## With Icons
6666

6767
The `renderIcon` prop can be used to customize the icons of each node in the
6868
TreeView.
@@ -81,20 +81,12 @@ TreeView.
8181
]}
8282
/>
8383

84-
## Temp
84+
## With Links
85+
86+
The `href` prop can be used with click handling on each node of the TreeView.
8587

8688
<Canvas
87-
of={TreeViewStories.Temp}
88-
additionalActions={[
89-
{
90-
title: 'Open in Stackblitz',
91-
onClick: () =>
92-
stackblitzPrefillConfig(
93-
TreeViewStories.Temp,
94-
"import { Document, Folder } from '@carbon/icons-react';"
95-
),
96-
},
97-
]}
89+
of={TreeViewStories.WithLinks}
9890
/>
9991

10092
## Component API

packages/react/src/components/TreeView/Treeview.stories.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import React from 'react';
99
import { action } from '@storybook/addon-actions';
1010
import { Document, Folder } from '@carbon/icons-react';
1111
import { default as TreeView, TreeNode } from './';
12+
import { Button } from '../Button/index';
1213
import mdx from './TreeView.mdx';
1314
import './story.scss';
1415

@@ -820,12 +821,9 @@ export const WithControlledExpansion = () => {
820821
return (
821822
<>
822823
<div style={{ marginBottom: '1rem' }}>
823-
<button type="button" onClick={() => setExpanded(true)}>
824-
expand all
825-
</button>
826-
<button type="button" onClick={() => setExpanded(false)}>
827-
collapse all
828-
</button>
824+
<Button onClick={() => setExpanded(true)}>Expand all</Button>
825+
&nbsp;
826+
<Button onClick={() => setExpanded(false)}>Collapse all</Button>
829827
</div>
830828
<TreeView label="Tree View">{renderTree({ nodes, expanded })}</TreeView>
831829
</>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/**
2+
* @license
3+
*
4+
* Copyright IBM Corp. 2025, 2025
5+
*
6+
* This source code is licensed under the Apache-2.0 license found in the
7+
* LICENSE file in the root directory of this source tree.
8+
*/
9+
10+
export enum TREE_SIZE {
11+
/**
12+
* Small
13+
*/
14+
SMALL = 'sm',
15+
16+
/**
17+
* Extra small size.
18+
*/
19+
EXTRA_SMALL = 'xs',
20+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
## Live demo
2+
3+
<StorybookDemo
4+
tall
5+
url="https://www.ibm.com/standards/carbon/carbon-web-components"
6+
variants={[
7+
{
8+
label: 'Default',
9+
variant: 'components-tree-view--default'
10+
},
11+
]}
12+
/>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/**
2+
* @license
3+
*
4+
* Copyright IBM Corp. 2025, 2025
5+
*
6+
* This source code is licensed under the Apache-2.0 license found in the
7+
* LICENSE file in the root directory of this source tree.
8+
*/
9+
10+
import './tree-node';
11+
import './tree-view';

0 commit comments

Comments
 (0)