mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-15 18:31:06 +00:00
TreeView (#725)
* feat(tree-view): add TreeView * fix(tree-view): select initial active node, correct typedefs * docs(tree-view): update examples * chore(tree-view): add test for types * docs(tree-view): rename example * docs(tree-view): improve docs * docs(tree-view): refine examples * docs: fix invalid syntax * chore: rebuild component index/api * docs(layout): increase height of sidenav menu [ci skip]
This commit is contained in:
parent
f4a3646cb4
commit
6ed4aaa86e
25 changed files with 1176 additions and 4 deletions
98
docs/src/pages/framed/TreeView/TreeViewIcons.svelte
Normal file
98
docs/src/pages/framed/TreeView/TreeViewIcons.svelte
Normal file
|
@ -0,0 +1,98 @@
|
|||
<script>
|
||||
import { TreeView } from "carbon-components-svelte";
|
||||
import WatsonMachineLearning16 from "carbon-icons-svelte/lib/WatsonMachineLearning16";
|
||||
import Analytics16 from "carbon-icons-svelte/lib/Analytics16";
|
||||
import Blockchain16 from "carbon-icons-svelte/lib/Blockchain16";
|
||||
import DataBase16 from "carbon-icons-svelte/lib/DataBase16";
|
||||
import SignalStrength16 from "carbon-icons-svelte/lib/SignalStrength16";
|
||||
|
||||
let activeId = 1;
|
||||
let selectedIds = [];
|
||||
let children = [
|
||||
{ id: 0, text: "AI / Machine learning", icon: WatsonMachineLearning16 },
|
||||
{
|
||||
id: 1,
|
||||
text: "Analytics",
|
||||
icon: Analytics16,
|
||||
expanded: true,
|
||||
children: [
|
||||
{
|
||||
id: 2,
|
||||
text: "IBM Analytics Engine",
|
||||
icon: Analytics16,
|
||||
expanded: true,
|
||||
children: [
|
||||
{ id: 3, text: "Apache Spark", icon: Analytics16 },
|
||||
{ id: 4, text: "Hadoop", icon: Analytics16 },
|
||||
],
|
||||
},
|
||||
{ id: 5, text: "IBM Cloud SQL Query", icon: Analytics16 },
|
||||
{ id: 6, text: "IBM Db2 Warehouse on Cloud", icon: Analytics16 },
|
||||
],
|
||||
},
|
||||
{
|
||||
id: 7,
|
||||
text: "Blockchain",
|
||||
icon: Blockchain16,
|
||||
children: [
|
||||
{ id: 8, text: "IBM Blockchain Platform", icon: Blockchain16 },
|
||||
],
|
||||
},
|
||||
{
|
||||
id: 9,
|
||||
text: "Databases",
|
||||
icon: DataBase16,
|
||||
children: [
|
||||
{
|
||||
id: 10,
|
||||
text: "IBM Cloud Databases for Elasticsearch",
|
||||
icon: DataBase16,
|
||||
},
|
||||
{
|
||||
id: 11,
|
||||
text: "IBM Cloud Databases for Enterprise DB",
|
||||
icon: DataBase16,
|
||||
},
|
||||
{ id: 12, text: "IBM Cloud Databases for MongoDB", icon: DataBase16 },
|
||||
{
|
||||
id: 13,
|
||||
text: "IBM Cloud Databases for PostgreSQL",
|
||||
icon: DataBase16,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
id: 14,
|
||||
text: "Integration",
|
||||
icon: SignalStrength16,
|
||||
disabled: true,
|
||||
children: [
|
||||
{
|
||||
id: 15,
|
||||
text: "IBM API Connect",
|
||||
icon: SignalStrength16,
|
||||
disabled: true,
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
</script>
|
||||
|
||||
<TreeView
|
||||
labelText="Cloud Products"
|
||||
children="{children}"
|
||||
bind:activeId
|
||||
bind:selectedIds
|
||||
on:select="{({ detail }) => console.log('select', detail)}"
|
||||
on:toggle="{({ detail }) => console.log('toggle', detail)}"
|
||||
on:focus="{({ detail }) => console.log('focus', detail)}"
|
||||
/>
|
||||
|
||||
<div>Active node id: {activeId}</div>
|
||||
<div>Selected ids: {JSON.stringify(selectedIds)}</div>
|
||||
|
||||
<style>
|
||||
div {
|
||||
margin-top: var(--cds-spacing-05);
|
||||
}
|
||||
</style>
|
Loading…
Add table
Add a link
Reference in a new issue