|
1 | 1 | <script lang="ts"> |
2 | | - import { type Component } from "svelte"; |
3 | 2 | import { Badge, badge, Button, Radio, Label, type BadgeProps, uiHelpers } from "$lib"; |
4 | 3 | import { ClockSolid } from "flowbite-svelte-icons"; |
5 | 4 | import { blur, fly, slide, scale } from "svelte/transition"; |
|
23 | 22 | eager: true |
24 | 23 | }) as Record<string, string>; |
25 | 24 |
|
26 | | - const exampleArr = [ |
27 | | - { name: "Dismissing with custom icon", component: ExampleComponents.DismissingWithCustomIcon }, |
28 | | - { name: "Dismissing with events", component: ExampleComponents.DismissingWithEvents }, |
29 | | - { name: "Notification badge", component: ExampleComponents.NotificationBadge }, |
30 | | - { name: "Button with badge", component: ExampleComponents.ButtonWithBadge }, |
31 | | - { name: "Badge with icon only", component: ExampleComponents.BadgeWithIconOnly }, |
32 | | - { name: "Opening badge", component: ExampleComponents.OpeningBadge }, |
33 | | - { name: "Dynamic color", component: ExampleComponents.DynamicColor } |
34 | | - ]; |
35 | | - let selectedExample: string | number = $state(exampleArr[0].name); |
36 | | - let svelteCode = $derived(getExampleFileName(selectedExample, exampleArr)); |
37 | | -
|
38 | | - function findObject(arr: { name: string; component: Component }[], name: string) { |
39 | | - const matchingObject = arr.find((obj) => obj.name === name); |
40 | | - return matchingObject ? matchingObject.component : null; |
41 | | - } |
42 | | - const SelectedComponent = $derived(findObject(exampleArr, selectedExample)); |
43 | | - // end of dynamic svelte component |
44 | | -
|
45 | 25 | // interactive example |
46 | 26 | const colors = Object.keys(badge.variants.color); |
47 | 27 | let color: BadgeProps["color"] = $state("primary"); |
|
200 | 180 | {/snippet} |
201 | 181 | </CodeWrapper> |
202 | 182 |
|
203 | | -<H2>Examples</H2> |
| 183 | +<H2>Dismissing with custom icon</H2> |
| 184 | +<CodeWrapper> |
| 185 | + <ExampleComponents.DismissingWithCustomIcon /> |
| 186 | + {#snippet codeblock()} |
| 187 | + <HighlightCompo codeLang="ts" code={exampleModules["./examples/DismissingWithCustomIcon.svelte"] as string} /> |
| 188 | + {/snippet} |
| 189 | +</CodeWrapper> |
204 | 190 |
|
| 191 | +<H2>Dismissing with events</H2> |
205 | 192 | <CodeWrapper> |
206 | | - <div class="mb-8 flex flex-wrap"> |
207 | | - <Label class="mb-4 w-full font-bold">Example</Label> |
208 | | - {#each exampleArr as style} |
209 | | - <Radio labelClass="w-[230px] my-1" onclick={() => (exampleExpand = false)} name="block_style" bind:group={selectedExample} value={style.name}>{style.name}</Radio> |
210 | | - {/each} |
211 | | - </div> |
212 | | - <SelectedComponent /> |
| 193 | + <ExampleComponents.DismissingWithEvents /> |
| 194 | + {#snippet codeblock()} |
| 195 | + <HighlightCompo codeLang="ts" code={exampleModules["./examples/DismissingWithEvents.svelte"] as string} /> |
| 196 | + {/snippet} |
| 197 | +</CodeWrapper> |
| 198 | + |
| 199 | +<H2>Notification badge</H2> |
| 200 | +<CodeWrapper> |
| 201 | + <ExampleComponents.NotificationBadge /> |
| 202 | + {#snippet codeblock()} |
| 203 | + <HighlightCompo codeLang="ts" code={exampleModules["./examples/NotificationBadge.svelte"] as string} /> |
| 204 | + {/snippet} |
| 205 | +</CodeWrapper> |
| 206 | + |
| 207 | +<H2>Button with badge</H2> |
| 208 | +<CodeWrapper> |
| 209 | + <ExampleComponents.ButtonWithBadge /> |
| 210 | + {#snippet codeblock()} |
| 211 | + <HighlightCompo codeLang="ts" code={exampleModules["./examples/ButtonWithBadge.svelte"] as string} /> |
| 212 | + {/snippet} |
| 213 | +</CodeWrapper> |
| 214 | + |
| 215 | +<H2>Badge with icon only</H2> |
| 216 | +<CodeWrapper> |
| 217 | + <ExampleComponents.BadgeWithIconOnly /> |
| 218 | + {#snippet codeblock()} |
| 219 | + <HighlightCompo codeLang="ts" code={exampleModules["./examples/BadgeWithIconOnly.svelte"] as string} /> |
| 220 | + {/snippet} |
| 221 | +</CodeWrapper> |
| 222 | + |
| 223 | +<H2>Opening badge</H2> |
| 224 | +<CodeWrapper> |
| 225 | + <ExampleComponents.OpeningBadge /> |
| 226 | + {#snippet codeblock()} |
| 227 | + <HighlightCompo codeLang="ts" code={exampleModules["./examples/OpeningBadge.svelte"] as string} /> |
| 228 | + {/snippet} |
| 229 | +</CodeWrapper> |
| 230 | + |
| 231 | +<H2>Dynamic color</H2> |
| 232 | +<CodeWrapper> |
| 233 | + <ExampleComponents.DynamicColor /> |
213 | 234 | {#snippet codeblock()} |
214 | | - <DynamicCodeBlockHighlight replaceLib {handleExpandClick} expand={exampleExpand} {showExpandButton} code={exampleModules[`./examples/${svelteCode}`] as string} /> |
| 235 | + <HighlightCompo codeLang="ts" code={exampleModules["./examples/DynamicColor.svelte"] as string} /> |
215 | 236 | {/snippet} |
216 | 237 | </CodeWrapper> |
217 | 238 |
|
|
0 commit comments