|
1 | 1 | <script lang="ts">
|
2 |
| - import { TextField } from 'svelte-ux'; |
| 2 | + import { cls, Field, TextField, ToggleGroup, ToggleOption } from 'svelte-ux'; |
3 | 3 | import { computedStyles, styleProps } from '@layerstack/svelte-actions';
|
4 | 4 |
|
5 | 5 | import Preview from '$docs/Preview.svelte';
|
6 | 6 | import Code from '$docs/Code.svelte';
|
7 | 7 | import Json from '$docs/Json.svelte';
|
8 | 8 |
|
9 | 9 | let _styles: CSSStyleDeclaration;
|
| 10 | + let backgroundClass = 'bg-primary'; |
| 11 | + let outlineStyle = 'solid'; |
| 12 | +
|
10 | 13 | let background = '#ddd';
|
11 | 14 | let border = '1px solid #aaa';
|
12 | 15 | </script>
|
|
27 | 30 | </h2>
|
28 | 31 |
|
29 | 32 | <Preview>
|
30 |
| - <div class="bg-primary" use:computedStyles={(styles) => (_styles = styles)}></div> |
31 |
| - <Json value={_styles} defaultExpandedPaths={[]} /> |
| 33 | + <div class="grid gap-3"> |
| 34 | + <div |
| 35 | + use:computedStyles={(styles) => (_styles = styles)} |
| 36 | + class={cls('size-10 rounded outline-offset-2', backgroundClass)} |
| 37 | + style:outline-style={outlineStyle} |
| 38 | + ></div> |
| 39 | + |
| 40 | + <div class="grid grid-cols-2 gap-3"> |
| 41 | + <Field label="Background Class"> |
| 42 | + <ToggleGroup bind:value={backgroundClass} variant="outline" inset> |
| 43 | + <ToggleOption value="bg-primary">primary</ToggleOption> |
| 44 | + <ToggleOption value="bg-secondary">secondary</ToggleOption> |
| 45 | + </ToggleGroup> |
| 46 | + </Field> |
| 47 | + |
| 48 | + <Field label="Outline Style"> |
| 49 | + <ToggleGroup bind:value={outlineStyle} variant="outline" inset> |
| 50 | + <ToggleOption value="solid">solid</ToggleOption> |
| 51 | + <ToggleOption value="dashed">dashed</ToggleOption> |
| 52 | + <ToggleOption value="dotted">dotted</ToggleOption> |
| 53 | + </ToggleGroup> |
| 54 | + </Field> |
| 55 | + </div> |
| 56 | + |
| 57 | + <Field label="Focal styles"> |
| 58 | + <Json |
| 59 | + value={{ backgroundColor: _styles?.backgroundColor, outlineStyle: _styles?.outlineStyle }} |
| 60 | + defaultExpandedPaths={[]} |
| 61 | + /> |
| 62 | + </Field> |
| 63 | + |
| 64 | + <Field label="All styles"> |
| 65 | + <Json value={_styles} defaultExpandedPaths={[]} /> |
| 66 | + </Field> |
| 67 | + </div> |
32 | 68 | </Preview>
|
33 | 69 |
|
34 | 70 | <h2>styleProps <small>Reactively set style properties using a single object.</small></h2>
|
|
37 | 73 | {@const styles = { '--background': background, '--border': border }}
|
38 | 74 | <div class="grid gap-4" use:styleProps={styles}>
|
39 | 75 | <div
|
40 |
| - class="w-10 h-10 rounded" |
| 76 | + class="size-10 rounded" |
41 | 77 | style:background-color="var(--background)"
|
42 | 78 | style:border="var(--border)"
|
43 | 79 | ></div>
|
|
0 commit comments