|
1 | 1 | <script lang="ts"> |
2 | 2 | import NeoNumberStep from '../../src/lib/inputs/NeoNumberStep.svelte'; |
3 | 3 |
|
4 | | - import type { NeoCollapseGroupProps } from '~/collapse/neo-collapse-group.model'; |
| 4 | + import SphereBackdrop from '../utils/SphereBackdrop.svelte'; |
| 5 | +
|
| 6 | + import type { NeoAccordionProps } from '~/collapse/neo-accordion.model'; |
5 | 7 |
|
6 | 8 | import NeoButton from '~/buttons/NeoButton.svelte'; |
| 9 | + import NeoButtonGroup from '~/buttons/NeoButtonGroup.svelte'; |
| 10 | + import NeoAccordion from '~/collapse/NeoAccordion.svelte'; |
7 | 11 | import NeoCollapse from '~/collapse/NeoCollapse.svelte'; |
8 | 12 | import NeoCollapseGroup from '~/collapse/NeoCollapseGroup.svelte'; |
9 | 13 | import NeoSkeletonMedia from '~/skeletons/NeoSkeletonMedia.svelte'; |
10 | | -
|
11 | | - const options = $state<NeoCollapseGroupProps>({ |
| 14 | + import { |
| 15 | + DefaultShadowElevation, |
| 16 | + DefaultShadowHoverElevation, |
| 17 | + getDefaultElevation, |
| 18 | + getDefaultHoverElevation, |
| 19 | + MaxShadowElevation, |
| 20 | + MinShadowElevation, |
| 21 | + } from '~/utils/shadow.utils'; |
| 22 | +
|
| 23 | + const options = $state<NeoAccordionProps>({ |
12 | 24 | disabled: false, |
13 | | - min: 0, |
14 | | - max: 3, |
| 25 | + readonly: false, |
| 26 | + segmented: true, |
| 27 | +
|
| 28 | + borderless: false, |
| 29 | + rounded: false, |
| 30 | + pressed: false, |
| 31 | + glass: false, |
| 32 | + tinted: false, |
| 33 | +
|
| 34 | + elevation: 0, |
| 35 | + hover: 0, |
| 36 | +
|
| 37 | + group: { |
| 38 | + min: 0, |
| 39 | + max: 3, |
| 40 | + }, |
15 | 41 | }); |
16 | 42 |
|
| 43 | + const onPressed = () => { |
| 44 | + options.elevation = getDefaultElevation(options.pressed); |
| 45 | + options.hover = getDefaultHoverElevation(options.pressed); |
| 46 | + }; |
| 47 | +
|
| 48 | + const onElevation = () => { |
| 49 | + if (options.elevation + options.hover < MinShadowElevation) options.hover += 1; |
| 50 | + if (options.elevation + options.hover > MaxShadowElevation) options.hover -= 1; |
| 51 | + }; |
| 52 | +
|
17 | 53 | let controlled = $state(false); |
18 | 54 | </script> |
19 | 55 |
|
20 | 56 | <div class="row"> |
21 | | - <NeoButton rounded toggle bind:checked={options.disabled}>Disabled</NeoButton> |
| 57 | + <NeoButtonGroup rounded={options.rounded}> |
| 58 | + <NeoButton toggle bind:checked={options.disabled}>Disabled</NeoButton> |
| 59 | + <NeoButton toggle bind:checked={options.readonly}>Readonly</NeoButton> |
| 60 | + <NeoButton toggle bind:checked={options.segmented}>Segmented</NeoButton> |
| 61 | + <NeoButton toggle bind:checked={options.borderless}>Borderless</NeoButton> |
| 62 | + <NeoButton toggle bind:checked={options.rounded}>Rounded</NeoButton> |
| 63 | + <NeoButton toggle bind:checked={options.pressed} onclick={onPressed}>Pressed</NeoButton> |
| 64 | + <NeoButton toggle bind:checked={options.glass}>Glass</NeoButton> |
| 65 | + <NeoButton toggle bind:checked={options.tinted}>Tinted</NeoButton> |
| 66 | + </NeoButtonGroup> |
| 67 | + |
| 68 | + <NeoNumberStep |
| 69 | + label="Elevation" |
| 70 | + placement="left" |
| 71 | + center |
| 72 | + bind:value={options.elevation} |
| 73 | + min={MinShadowElevation} |
| 74 | + max={MaxShadowElevation} |
| 75 | + defaultValue={DefaultShadowElevation} |
| 76 | + rounded={options.rounded} |
| 77 | + oninput={onElevation} |
| 78 | + nullable={false} |
| 79 | + floating={false} |
| 80 | + groupProps={{ style: 'margin-left: 6rem' }} |
| 81 | + /> |
| 82 | + <NeoNumberStep |
| 83 | + label="Hover" |
| 84 | + placement="left" |
| 85 | + center |
| 86 | + bind:value={options.hover} |
| 87 | + min={MinShadowElevation - options.elevation} |
| 88 | + max={MaxShadowElevation - options.elevation} |
| 89 | + defaultValue={DefaultShadowHoverElevation} |
| 90 | + rounded={options.rounded} |
| 91 | + nullable={false} |
| 92 | + floating={false} |
| 93 | + groupProps={{ style: 'margin-left: 4rem' }} |
| 94 | + /> |
22 | 95 |
|
23 | 96 | <NeoNumberStep |
24 | 97 | label="Minimum" |
25 | 98 | placement="left" |
26 | 99 | center |
27 | | - bind:value={options.min} |
| 100 | + bind:value={options.group.min} |
28 | 101 | min={0} |
29 | 102 | max={3} |
30 | 103 | defaultValue={0} |
|
38 | 111 | label="Maximum" |
39 | 112 | placement="left" |
40 | 113 | center |
41 | | - bind:value={options.max} |
| 114 | + bind:value={options.group.max} |
42 | 115 | min={0} |
43 | 116 | max={3} |
44 | 117 | defaultValue={3} |
|
59 | 132 | <div class="row"> |
60 | 133 | <div class="column content"> |
61 | 134 | <span class="label">Default</span> |
62 | | - <NeoCollapseGroup {...options}> |
63 | | - <NeoCollapse label="Section 1" children={content} /> |
64 | | - <NeoCollapse label="Section 2" children={content} /> |
65 | | - <NeoCollapse label="Section 3" children={content} /> |
66 | | - </NeoCollapseGroup> |
| 135 | + |
| 136 | + <SphereBackdrop glass={options.glass} style="width: 100%"> |
| 137 | + <NeoAccordion {...options}> |
| 138 | + <NeoCollapse label="Section 1" children={content} /> |
| 139 | + <NeoCollapse label="Section 2" children={content} /> |
| 140 | + <NeoCollapse label="Section 3" children={content} /> |
| 141 | + </NeoAccordion> |
| 142 | + </SphereBackdrop> |
67 | 143 | </div> |
68 | 144 | </div> |
69 | 145 |
|
70 | 146 | <div class="row"> |
71 | 147 | <div class="column content"> |
72 | 148 | <span class="label">Description</span> |
73 | | - <NeoCollapseGroup {...options}> |
74 | | - <NeoCollapse id="section 1" label="Section 1" description="This is a description" children={content} /> |
75 | | - <NeoCollapse id="section 2" label="Section 2" description="This is a description" children={content} /> |
76 | | - <NeoCollapse id="section 3" label="Section 3" description="This is a description" children={content} /> |
77 | | - </NeoCollapseGroup> |
| 149 | + <SphereBackdrop glass={options.glass} style="width: 100%"> |
| 150 | + <NeoAccordion {...options}> |
| 151 | + <NeoCollapse id="section 1" label="Section 1" description="This is a description" children={content} /> |
| 152 | + <NeoCollapse id="section 2" label="Section 2" description="This is a description" children={content} /> |
| 153 | + <NeoCollapse id="section 3" label="Section 3" description="This is a description" children={content} /> |
| 154 | + </NeoAccordion> |
| 155 | + </SphereBackdrop> |
| 156 | + </div> |
| 157 | +</div> |
| 158 | + |
| 159 | +<div class="row"> |
| 160 | + <div class="column content"> |
| 161 | + <span class="label">Separated</span> |
| 162 | + |
| 163 | + <SphereBackdrop glass={options.glass} style="width: 100%"> |
| 164 | + <NeoCollapseGroup {...options.group}> |
| 165 | + <NeoAccordion {...options} group={undefined}> |
| 166 | + <NeoCollapse label="Section 1" children={content} /> |
| 167 | + </NeoAccordion> |
| 168 | + <NeoAccordion {...options} group={undefined}> |
| 169 | + <NeoCollapse label="Section 2" children={content} /> |
| 170 | + </NeoAccordion> |
| 171 | + <NeoAccordion {...options} group={undefined}> |
| 172 | + <NeoCollapse label="Section 3" children={content} /> |
| 173 | + </NeoAccordion> |
| 174 | + </NeoCollapseGroup> |
| 175 | + </SphereBackdrop> |
78 | 176 | </div> |
79 | 177 | </div> |
80 | 178 |
|
81 | 179 | <div class="row"> |
82 | | - <div class="column"> |
83 | | - <span class="label">Controlled</span> |
| 180 | + <div class="column content"> |
| 181 | + <span class="label">External trigger</span> |
84 | 182 | <NeoButton text toggle hover="-1" active="-2" bind:checked={controlled}>Toggle</NeoButton> |
85 | | - <NeoCollapseGroup {...options}> |
86 | | - <NeoCollapse children={content} open={controlled} /> |
87 | | - </NeoCollapseGroup> |
| 183 | + <SphereBackdrop glass={options.glass} style="width: 100%"> |
| 184 | + <NeoAccordion {...options}> |
| 185 | + <NeoCollapse children={content} open={controlled} /> |
| 186 | + </NeoAccordion> |
| 187 | + </SphereBackdrop> |
88 | 188 | </div> |
89 | 189 | </div> |
90 | 190 |
|
|
93 | 193 | {/snippet} |
94 | 194 |
|
95 | 195 | <div class="row"> |
96 | | - <div class="column content"> |
| 196 | + <div class="column horizontal"> |
97 | 197 | <span class="label">Horizontal</span> |
98 | | - <div class="row content"> |
99 | | - <NeoCollapseGroup {...options}> |
| 198 | + <SphereBackdrop glass={options.glass}> |
| 199 | + <NeoAccordion horizontal {...options}> |
100 | 200 | <NeoCollapse horizontal label="Click Me" description="Section 1" children={horizontalContent} /> |
101 | 201 | <NeoCollapse horizontal label="Click Me" description="Section 2" children={horizontalContent} /> |
102 | 202 | <NeoCollapse horizontal label="Click Me" description="Section 3" children={horizontalContent} /> |
103 | | - </NeoCollapseGroup> |
104 | | - </div> |
| 203 | + </NeoAccordion> |
| 204 | + </SphereBackdrop> |
105 | 205 | </div> |
106 | 206 | </div> |
107 | 207 |
|
|
119 | 219 | &.content { |
120 | 220 | width: min(80vw, 80ch); |
121 | 221 | } |
| 222 | +
|
| 223 | + &.horizontal { |
| 224 | + :global(.neo-accordion .neo-collapse-trigger) { |
| 225 | + min-height: 15rem; |
| 226 | + } |
| 227 | + } |
122 | 228 | } |
123 | 229 |
|
124 | 230 | .row { |
125 | 231 | @include flex.row($center: true, $gap: var(--neo-gap-xl), $flex: 0 1 auto); |
126 | 232 |
|
127 | 233 | margin: 2rem 0; |
128 | | -
|
129 | | - &.content { |
130 | | - flex-wrap: nowrap; |
131 | | - height: 20rem; |
132 | | - } |
133 | 234 | } |
134 | 235 | </style> |
0 commit comments