-
-
Notifications
You must be signed in to change notification settings - Fork 262
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(tree-view): add
showNode
accessor
Closes #1377
- Loading branch information
Showing
7 changed files
with
150 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<script> | ||
import { Button, ButtonSet, TreeView } from "carbon-components-svelte"; | ||
const nodeSpark = { id: 3, text: "Apache Spark" }; | ||
const nodeBlockchain = { id: 8, text: "IBM Blockchain Platform" }; | ||
let treeview = null; | ||
let children = [ | ||
{ id: 0, text: "AI / Machine learning" }, | ||
{ | ||
id: 1, | ||
text: "Analytics", | ||
children: [ | ||
{ | ||
id: 2, | ||
text: "IBM Analytics Engine", | ||
children: [nodeSpark, { id: 4, text: "Hadoop" }], | ||
}, | ||
{ id: 5, text: "IBM Cloud SQL Query" }, | ||
{ id: 6, text: "IBM Db2 Warehouse on Cloud" }, | ||
], | ||
}, | ||
{ | ||
id: 7, | ||
text: "Blockchain", | ||
children: [{ id: 8, text: "IBM Blockchain Platform" }], | ||
}, | ||
]; | ||
</script> | ||
|
||
<ButtonSet style="margin-bottom: var(--cds-spacing-05)"> | ||
{#each [nodeSpark, nodeBlockchain] as { id, text }} | ||
<Button | ||
on:click="{() => { | ||
treeview?.showNode(id); | ||
}}" | ||
> | ||
Show "{text}" | ||
</Button> | ||
{/each} | ||
<Button kind="tertiary" on:click="{treeview.collapseAll}">Collapse all</Button | ||
> | ||
</ButtonSet> | ||
|
||
<TreeView | ||
bind:this="{treeview}" | ||
labelText="Cloud Products" | ||
children="{children}" | ||
/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -58,6 +58,7 @@ | |
treeview.collapseNodes((node) => { | ||
return node.disabled; | ||
}); | ||
treeview.show(1); | ||
} | ||
</script> | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters