Skip to content
This repository was archived by the owner on Sep 26, 2022. It is now read-only.

Commit a7d2cb5

Browse files
docs(Select): add basic usage and explanation
Signed-off-by: Florian-Schoenherr <[email protected]>
1 parent 7490744 commit a7d2cb5

File tree

5 files changed

+32
-17
lines changed

5 files changed

+32
-17
lines changed

packages/docs/src/components/doc/Playground.svelte

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -107,15 +107,6 @@
107107
val.join(', ') :
108108
val)}>
109109
{label}
110-
<div slot="item" let:item>
111-
{#if controls[label].format}
112-
<ListItem value={item.value}>
113-
{item.name}
114-
</ListItem>
115-
{:else}
116-
<ListItem value={item}>{item}</ListItem>
117-
{/if}
118-
</div>
119110
</Select>
120111
{:else if controls[label].type === 'text'}
121112
<TextField bind:value={values[label]} class="mt-4">{label}</TextField>

packages/docs/src/examples/Select/basic.svelte

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
<script>
22
import { Row, Col, Select } from 'svelte-materialify/src';
33
4-
const items = [
5-
{ name: 'Foo', value: 'foo' },
6-
{ name: 'Bar', value: 'bar' },
7-
{ name: 'Fizz', value: 'fizz' },
8-
{ name: 'Buzz', value: 'buzz' },
9-
];
4+
const items = ['foo', 'bar', 'fizz', 'buzz'];
105
</script>
116

127
<Row>

packages/docs/src/examples/Select/multiple.svelte

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
{ name: 'Fizz', value: 'fizz' },
88
{ name: 'Buzz', value: 'buzz' },
99
];
10+
const items2 = ['foo', 'bar', 'fizz', 'buzz'];
1011
</script>
1112

1213
<Row>
@@ -15,7 +16,7 @@
1516
<Select multiple filled {items}>Filled</Select>
1617
</Col>
1718
<Col>
18-
<Select multiple solo {items} placeholder="Solo" />
19-
<Select multiple outlined {items}>Outlined</Select>
19+
<Select multiple solo items={items2} placeholder="Solo" />
20+
<Select multiple outlined items={items2}>Outlined</Select>
2021
</Col>
2122
</Row>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<script>
2+
import { Row, Select } from 'svelte-materialify/src';
3+
4+
const items = [
5+
{ name: 'Foo!', value: 'foo' },
6+
{ name: 'Bar!', value: 'bar' },
7+
{ name: 'Fizz!', value: 'fizz' },
8+
{ name: 'Buzz!', value: 'buzz' },
9+
];
10+
let value;
11+
</script>
12+
13+
<Row noGutters class="mt-2">
14+
<Select {items} bind:value>Regular</Select>
15+
<p>chosen value: {value}</p>
16+
</Row>

packages/docs/src/routes/components/selects.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,18 @@ Below is a collection of simple to complex examples.
2424
This is a basic example on how to use `Select`.
2525
<Components.Example file="Select/basic" />
2626

27+
### Name-Value
28+
29+
If you want the `name` that the user sees to differ from the `value` in code, your items should be defined like this:
30+
```js
31+
const items = [
32+
{ name: 'Foo!', value: 'foo' },
33+
{ name: 'Bar!', value: 'bar' }
34+
]
35+
```
36+
as an example:
37+
<Components.Example file="Select/namevalue" />
38+
2739
### Disabled
2840

2941
You cannot use disabled `Select`.

0 commit comments

Comments
 (0)