Add Chips component

This commit is contained in:
venashial
2022-03-20 11:14:46 -07:00
parent 0d68b1a73e
commit b6d6955b39
6 changed files with 128 additions and 6 deletions

View File

@@ -17,6 +17,8 @@
<style lang="postcss">
.example {
margin-bottom: 32px;
&__preview {
padding: 16px;
border-radius: var(--rounded-sm-top);

View File

@@ -1,5 +1,5 @@
<script lang="ts">
const components = ['Button', 'Pagination', 'Link', 'NavRow', 'Badge', 'Avatar'].sort()
const components = ['Button', 'Pagination', 'Link', 'NavRow', 'Badge', 'Avatar', 'Chips'].sort()
</script>
<nav class="sidebar">

View File

@@ -0,0 +1,71 @@
<script lang="ts">
import Chips from "$lib/components/Chips.svelte";
import Example from "../_internal/components/Example.svelte"
let foo = 'modpack'
</script>
### Simple example
<Example code={`
<Chips options={[
{
label: 'One',
value: 'one'
},
{
label: 'Two',
value: 'two'
}]}
/>
`}>
<Chips options={[
{
label: 'One',
value: 'one'
},
{
label: 'Two',
value: 'two'
}]}
/>
</Example>
### Force an option to be selected with `neverEmpty`
<Example code={`
<script>
let foo = 'modpack';
</script>
<Chips neverEmpty bind:value={foo} options={[
{
label: 'Mod',
value: 'mod'
},
{
label: 'Modpack',
value: 'modpack'
},
{
label: 'World',
value: 'world'
}]}
/>
`}>
<Chips neverEmpty bind:value={foo} options={[
{
label: 'Mod',
value: 'mod'
},
{
label: 'Modpack',
value: 'modpack'
},
{
label: 'World',
value: 'world'
}]}
/>
</Example>