mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-15 02:11:05 +00:00
docs: add ClickableTile
example, notes on keyed props (#1184)
* docs(clickable-tile): add "Prevent default behavior" example * docs: add note that `items` object requires a unique `id` * docs: remove note on selectedId * docs(data-table): explain how header keys work
This commit is contained in:
parent
1017e80198
commit
233edf3358
5 changed files with 32 additions and 8 deletions
|
@ -13,6 +13,20 @@ source: Tile/ClickableTile.svelte
|
||||||
Carbon Design System
|
Carbon Design System
|
||||||
</ClickableTile>
|
</ClickableTile>
|
||||||
|
|
||||||
|
### Prevent default behavior
|
||||||
|
|
||||||
|
Use the forwarded `click` event and invoke `e.preventDefault()` to prevent the native link behavior.
|
||||||
|
|
||||||
|
<ClickableTile
|
||||||
|
href="/"
|
||||||
|
on:click={(e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
// custom behavior
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Carbon Design System
|
||||||
|
</ClickableTile>
|
||||||
|
|
||||||
### Light variant
|
### Light variant
|
||||||
|
|
||||||
<ClickableTile light href="https://www.carbondesignsystem.com/">
|
<ClickableTile light href="https://www.carbondesignsystem.com/">
|
||||||
|
|
|
@ -3,10 +3,10 @@
|
||||||
import Preview from "../../components/Preview.svelte";
|
import Preview from "../../components/Preview.svelte";
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
`ComboBox` is keyed for performance reasons.
|
||||||
|
|
||||||
<InlineNotification svx-ignore lowContrast title="Note:" kind="info" hideCloseButton>
|
<InlineNotification svx-ignore lowContrast title="Note:" kind="info" hideCloseButton>
|
||||||
<div class="body-short-01">
|
<div class="body-short-01">Every <code>items</code> object must have a unique "id" property.</div>
|
||||||
Since version 0.53, <strong>selectedIndex</strong> has been replaced with <strong>selectedId</strong>.
|
|
||||||
</div>
|
|
||||||
</InlineNotification>
|
</InlineNotification>
|
||||||
|
|
||||||
### Default
|
### Default
|
||||||
|
|
|
@ -10,7 +10,7 @@ components: ["DataTable", "Pagination","Toolbar", "ToolbarContent", "ToolbarSear
|
||||||
const pagination = { pageSize: 5, page: 1}
|
const pagination = { pageSize: 5, page: 1}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
`DataTable` is keyed for both rendering and sorting purposes.
|
`DataTable` is keyed for performance reasons.
|
||||||
|
|
||||||
<InlineNotification svx-ignore lowContrast title="Note:" kind="info" hideCloseButton>
|
<InlineNotification svx-ignore lowContrast title="Note:" kind="info" hideCloseButton>
|
||||||
<div class="body-short-01">Every <code>headers</code> object must have a unique "key" property.</div>
|
<div class="body-short-01">Every <code>headers</code> object must have a unique "key" property.</div>
|
||||||
|
@ -22,6 +22,10 @@ components: ["DataTable", "Pagination","Toolbar", "ToolbarContent", "ToolbarSear
|
||||||
|
|
||||||
### Default
|
### Default
|
||||||
|
|
||||||
|
The key value in `headers` corresponds to the key value defined in `rows`.
|
||||||
|
|
||||||
|
For example, the header key `"name"` will use the value of `rows[index].name`.
|
||||||
|
|
||||||
<DataTable
|
<DataTable
|
||||||
headers="{[
|
headers="{[
|
||||||
{ key: "name", value: "Name" },
|
{ key: "name", value: "Name" },
|
||||||
|
|
|
@ -7,10 +7,10 @@ components: ["Dropdown", "DropdownSkeleton"]
|
||||||
import Preview from "../../components/Preview.svelte";
|
import Preview from "../../components/Preview.svelte";
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
`Dropdown` is keyed for performance reasons.
|
||||||
|
|
||||||
<InlineNotification svx-ignore lowContrast title="Note:" kind="info" hideCloseButton>
|
<InlineNotification svx-ignore lowContrast title="Note:" kind="info" hideCloseButton>
|
||||||
<div class="body-short-01">
|
<div class="body-short-01">Every <code>items</code> object must have a unique "id" property.</div>
|
||||||
Since version 0.53, <strong>selectedIndex</strong> has been replaced with <strong>selectedId</strong>.
|
|
||||||
</div>
|
|
||||||
</InlineNotification>
|
</InlineNotification>
|
||||||
|
|
||||||
### Default
|
### Default
|
||||||
|
|
|
@ -1,8 +1,14 @@
|
||||||
<script>
|
<script>
|
||||||
import { MultiSelect } from "carbon-components-svelte";
|
import { MultiSelect, InlineNotification } from "carbon-components-svelte";
|
||||||
import Preview from "../../components/Preview.svelte";
|
import Preview from "../../components/Preview.svelte";
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
`MultiSelect` is keyed for performance reasons.
|
||||||
|
|
||||||
|
<InlineNotification svx-ignore lowContrast title="Note:" kind="info" hideCloseButton>
|
||||||
|
<div class="body-short-01">Every <code>items</code> object must have a unique "id" property.</div>
|
||||||
|
</InlineNotification>
|
||||||
|
|
||||||
### Default
|
### Default
|
||||||
|
|
||||||
By default, items will be ordered alphabetically based on the `item.text` value. To prevent this, see [#no-alphabetical-ordering](#no-alphabetical-ordering).
|
By default, items will be ordered alphabetically based on the `item.text` value. To prevent this, see [#no-alphabetical-ordering](#no-alphabetical-ordering).
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue