From 682d277213b3ae9e2349413a7ccaa20df1e09d89 Mon Sep 17 00:00:00 2001 From: Jason Rasmussen Date: Mon, 23 Dec 2024 10:46:47 -0500 Subject: [PATCH] feat: switch --- src/docs/components/ExampleLayout.svelte | 12 ++- src/docs/components/Lorem.svelte | 21 ++-- src/docs/constants.ts | 4 + .../AppShell/AppShellSidebar.svelte | 2 +- .../components/Scrollable/Scrollable.svelte | 3 +- src/lib/components/Switch/Switch.svelte | 99 +++++++++++++++++++ src/lib/index.ts | 1 + src/routes/components/button/+page.svelte | 5 +- src/routes/components/field/+page.svelte | 5 +- src/routes/components/navbar/+page.svelte | 2 +- .../components/navbar/BasicExample.svelte | 2 +- .../components/navbar/GroupExample.svelte | 3 +- src/routes/components/scrollable/+page.svelte | 9 ++ .../components/scrollable/BasicExample.svelte | 22 +++++ src/routes/components/switch/+page.svelte | 20 ++++ .../components/switch/BasicExample.svelte | 11 +++ .../components/switch/ColorExample.svelte | 12 +++ .../components/switch/FormExample.svelte | 17 ++++ 18 files changed, 231 insertions(+), 19 deletions(-) create mode 100644 src/lib/components/Switch/Switch.svelte create mode 100644 src/routes/components/scrollable/+page.svelte create mode 100644 src/routes/components/scrollable/BasicExample.svelte create mode 100644 src/routes/components/switch/+page.svelte create mode 100644 src/routes/components/switch/BasicExample.svelte create mode 100644 src/routes/components/switch/ColorExample.svelte create mode 100644 src/routes/components/switch/FormExample.svelte diff --git a/src/docs/components/ExampleLayout.svelte b/src/docs/components/ExampleLayout.svelte index ed63c6d..1b58b52 100644 --- a/src/docs/components/ExampleLayout.svelte +++ b/src/docs/components/ExampleLayout.svelte @@ -1,14 +1,16 @@
@@ -25,8 +27,10 @@
- - + + {name} + {@render children?.()} + diff --git a/src/docs/components/Lorem.svelte b/src/docs/components/Lorem.svelte index ead253f..ace3f67 100644 --- a/src/docs/components/Lorem.svelte +++ b/src/docs/components/Lorem.svelte @@ -1,12 +1,19 @@ -{#each Array(count) as i} -

- Lorem ipsum dolor sit amet consectetur adipisicing elit. A ipsam tenetur accusantium impedit - beatae omnis necessitatibus. Voluptatum blanditiis libero impedit, harum eius inventore nihil, - officia voluptate dolorum error consequatur animi. -

-{/each} +{text} diff --git a/src/docs/constants.ts b/src/docs/constants.ts index 4af3afb..010d852 100644 --- a/src/docs/constants.ts +++ b/src/docs/constants.ts @@ -15,7 +15,9 @@ import { mdiListBoxOutline, mdiMenu, mdiNumeric, + mdiPanVertical, mdiPartyPopper, + mdiToggleSwitch, mdiViewSequential, } from '@mdi/js'; import type { Component } from 'svelte'; @@ -47,6 +49,7 @@ export const componentGroups = [ { name: 'AppShell', icon: mdiApplicationOutline }, { name: 'Card', icon: mdiCardOutline }, { name: 'Navbar', icon: mdiMenu }, + { name: 'Scrollable', icon: mdiPanVertical }, { name: 'Stack', icon: mdiViewSequential }, ], }, @@ -61,6 +64,7 @@ export const componentGroups = [ { name: 'Input', icon: mdiFormTextbox }, { name: 'LoadingSpinner', icon: mdiDotsCircle }, { name: 'PasswordInput', icon: mdiFormTextboxPassword }, + { name: 'Switch', icon: mdiToggleSwitch }, ], }, { diff --git a/src/lib/components/AppShell/AppShellSidebar.svelte b/src/lib/components/AppShell/AppShellSidebar.svelte index 0978ffd..2cb64ee 100644 --- a/src/lib/components/AppShell/AppShellSidebar.svelte +++ b/src/lib/components/AppShell/AppShellSidebar.svelte @@ -17,7 +17,7 @@ -
+
{@render children?.()}
@@ -18,6 +18,7 @@ /* width */ .immich-scrollbar::-webkit-scrollbar { width: 8px; + height: 8px; } /* Track */ diff --git a/src/lib/components/Switch/Switch.svelte b/src/lib/components/Switch/Switch.svelte new file mode 100644 index 0000000..8017786 --- /dev/null +++ b/src/lib/components/Switch/Switch.svelte @@ -0,0 +1,99 @@ + + + diff --git a/src/lib/index.ts b/src/lib/index.ts index b8a40f7..d9eefae 100644 --- a/src/lib/index.ts +++ b/src/lib/index.ts @@ -30,6 +30,7 @@ export { default as HStack } from '$lib/components/Stack/HStack.svelte'; export { default as Stack } from '$lib/components/Stack/Stack.svelte'; export { default as VStack } from '$lib/components/Stack/VStack.svelte'; export { default as SupporterBadge } from '$lib/components/SupporterBadge/SupporterBadge.svelte'; +export { default as Switch } from '$lib/components/Switch/Switch.svelte'; export { default as Text } from '$lib/components/Text/Text.svelte'; export * from '$lib/types.js'; export * from '$lib/utilities/byte-units.js'; diff --git a/src/routes/components/button/+page.svelte b/src/routes/components/button/+page.svelte index aad2f85..3fce7ad 100644 --- a/src/routes/components/button/+page.svelte +++ b/src/routes/components/button/+page.svelte @@ -1,5 +1,6 @@ - + + A button component, which can also be used to render links + diff --git a/src/routes/components/field/+page.svelte b/src/routes/components/field/+page.svelte index 4344461..8691cdf 100644 --- a/src/routes/components/field/+page.svelte +++ b/src/routes/components/field/+page.svelte @@ -1,9 +1,12 @@ - + + A metadata component for tracking common form field information + diff --git a/src/routes/components/navbar/+page.svelte b/src/routes/components/navbar/+page.svelte index d824b4f..fda8938 100644 --- a/src/routes/components/navbar/+page.svelte +++ b/src/routes/components/navbar/+page.svelte @@ -11,4 +11,4 @@ ]; - + diff --git a/src/routes/components/navbar/BasicExample.svelte b/src/routes/components/navbar/BasicExample.svelte index bdaca84..71b9378 100644 --- a/src/routes/components/navbar/BasicExample.svelte +++ b/src/routes/components/navbar/BasicExample.svelte @@ -3,6 +3,6 @@ import { mdiHome } from '@mdi/js'; -
+
diff --git a/src/routes/components/navbar/GroupExample.svelte b/src/routes/components/navbar/GroupExample.svelte index 953b0b8..df0dbab 100644 --- a/src/routes/components/navbar/GroupExample.svelte +++ b/src/routes/components/navbar/GroupExample.svelte @@ -1,6 +1,5 @@ diff --git a/src/routes/components/scrollable/+page.svelte b/src/routes/components/scrollable/+page.svelte new file mode 100644 index 0000000..327dfff --- /dev/null +++ b/src/routes/components/scrollable/+page.svelte @@ -0,0 +1,9 @@ + + + diff --git a/src/routes/components/scrollable/BasicExample.svelte b/src/routes/components/scrollable/BasicExample.svelte new file mode 100644 index 0000000..0eaf5e9 --- /dev/null +++ b/src/routes/components/scrollable/BasicExample.svelte @@ -0,0 +1,22 @@ + + + + Vertical +
+ + + + + +
+ + Horizontal + + + + + +
diff --git a/src/routes/components/switch/+page.svelte b/src/routes/components/switch/+page.svelte new file mode 100644 index 0000000..814de4e --- /dev/null +++ b/src/routes/components/switch/+page.svelte @@ -0,0 +1,20 @@ + + + + A boolean input element + diff --git a/src/routes/components/switch/BasicExample.svelte b/src/routes/components/switch/BasicExample.svelte new file mode 100644 index 0000000..2cbc2f1 --- /dev/null +++ b/src/routes/components/switch/BasicExample.svelte @@ -0,0 +1,11 @@ + + + + + + + + + diff --git a/src/routes/components/switch/ColorExample.svelte b/src/routes/components/switch/ColorExample.svelte new file mode 100644 index 0000000..76f2279 --- /dev/null +++ b/src/routes/components/switch/ColorExample.svelte @@ -0,0 +1,12 @@ + + + + + + + + + + diff --git a/src/routes/components/switch/FormExample.svelte b/src/routes/components/switch/FormExample.svelte new file mode 100644 index 0000000..93c7638 --- /dev/null +++ b/src/routes/components/switch/FormExample.svelte @@ -0,0 +1,17 @@ + + + + + + + + + + + + Disabled + + +