carbon-components-svelte/tests/Dropdown.test.svelte

96 lines
1.6 KiB
Svelte

<script lang="ts">
import { Dropdown, DropdownSkeleton } from "../types";
</script>
<Dropdown
direction="top"
titleText="Contact"
selectedId="0"
items="{[
{ id: 0, text: 'Slack' },
{ id: '1', text: 'Email' },
{ id: '2', text: 'Fax' },
]}"
on:select="{(e) => {
console.log(e.detail.selectedId);
}}"
translateWithId="{(id) => {
console.log(id); // "open" | "close"
return id;
}}"
let:item
let:index
>
{item.id}
{index}
</Dropdown>
<Dropdown
itemToString="{(item) => {
return item.text + ' (' + item.id + ')';
}}"
titleText="Contact"
selectedId="0"
items="{[
{ id: '0', text: 'Slack' },
{ id: '1', text: 'Email' },
{ id: '2', text: 'Fax' },
]}"
/>
<Dropdown
light
titleText="Contact"
selectedId="0"
items="{[
{ id: '0', text: 'Slack' },
{ id: '1', text: 'Email' },
{ id: '2', text: 'Fax' },
]}"
/>
<Dropdown
type="inline"
titleText="Contact"
selectedId="0"
items="{[
{ id: '0', text: 'Slack' },
{ id: '1', text: 'Email' },
{ id: '2', text: 'Fax' },
]}"
/>
<Dropdown
size="xl"
titleText="Contact"
selectedId="0"
items="{[
{ id: '0', text: 'Slack' },
{ id: '1', text: 'Email' },
{ id: '2', text: 'Fax' },
]}"
/>
<Dropdown
size="sm"
titleText="Contact"
selectedId="0"
items="{[
{ id: '0', text: 'Slack' },
{ id: '1', text: 'Email' },
{ id: '2', text: 'Fax' },
]}"
/>
<Dropdown
disabled
titleText="Contact"
selectedId="0"
items="{[
{ id: '0', text: 'Slack' },
{ id: '1', text: 'Email' },
{ id: '2', text: 'Fax' },
]}"
/>
<DropdownSkeleton />