From 546a7f7480406d0091c0462d6b8f9c3d2c3dc9b4 Mon Sep 17 00:00:00 2001 From: Jason Rasmussen Date: Mon, 18 Nov 2024 12:39:46 -0500 Subject: [PATCH] feat: stack component --- src/docs/components/DecorativeBlock.svelte | 43 ++++ src/docs/components/DualThemeLayout.svelte | 5 +- src/docs/constants.ts | 1 + src/lib/components/Card/Card.svelte | 2 +- src/lib/components/Stack/HStack.svelte | 10 + src/lib/components/Stack/Stack.svelte | 68 +++++++ src/lib/components/Stack/VStack.svelte | 10 + src/lib/index.ts | 3 + src/lib/types.ts | 16 ++ src/routes/examples/alert/+page.svelte | 114 +++++------ src/routes/examples/button/+page.svelte | 204 +++++++++---------- src/routes/examples/card/+page.svelte | 200 +++++++++--------- src/routes/examples/checkbox/+page.svelte | 100 +++++---- src/routes/examples/heading/+page.svelte | 58 +++--- src/routes/examples/icon-button/+page.svelte | 176 ++++++++-------- src/routes/examples/logo/+page.svelte | 108 +++++----- src/routes/examples/stack/+page.svelte | 48 +++++ src/routes/examples/text/+page.svelte | 60 +++--- 18 files changed, 695 insertions(+), 531 deletions(-) create mode 100644 src/docs/components/DecorativeBlock.svelte create mode 100644 src/lib/components/Stack/HStack.svelte create mode 100644 src/lib/components/Stack/Stack.svelte create mode 100644 src/lib/components/Stack/VStack.svelte create mode 100644 src/routes/examples/stack/+page.svelte diff --git a/src/docs/components/DecorativeBlock.svelte b/src/docs/components/DecorativeBlock.svelte new file mode 100644 index 0000000..7b54463 --- /dev/null +++ b/src/docs/components/DecorativeBlock.svelte @@ -0,0 +1,43 @@ + + +
diff --git a/src/docs/components/DualThemeLayout.svelte b/src/docs/components/DualThemeLayout.svelte index 3e74f50..f86e8e1 100644 --- a/src/docs/components/DualThemeLayout.svelte +++ b/src/docs/components/DualThemeLayout.svelte @@ -1,6 +1,7 @@ + + + {@render children()} + diff --git a/src/lib/components/Stack/Stack.svelte b/src/lib/components/Stack/Stack.svelte new file mode 100644 index 0000000..65b4906 --- /dev/null +++ b/src/lib/components/Stack/Stack.svelte @@ -0,0 +1,68 @@ + + +
+ {@render children()} +
diff --git a/src/lib/components/Stack/VStack.svelte b/src/lib/components/Stack/VStack.svelte new file mode 100644 index 0000000..d0a11ec --- /dev/null +++ b/src/lib/components/Stack/VStack.svelte @@ -0,0 +1,10 @@ + + + + {@render children()} + diff --git a/src/lib/index.ts b/src/lib/index.ts index 5d38b60..d7b0d4e 100644 --- a/src/lib/index.ts +++ b/src/lib/index.ts @@ -13,5 +13,8 @@ export { default as Heading } from '$lib/components/Heading/Heading.svelte'; export { default as Icon } from '$lib/components/Icon/Icon.svelte'; export { default as IconButton } from '$lib/components/IconButton/IconButton.svelte'; export { default as Logo } from '$lib/components/Logo/Logo.svelte'; +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 Text } from '$lib/components/Text/Text.svelte'; export * from '$lib/types.js'; diff --git a/src/lib/types.ts b/src/lib/types.ts index f396869..fa0134a 100644 --- a/src/lib/types.ts +++ b/src/lib/types.ts @@ -1,3 +1,4 @@ +import type { Snippet } from 'svelte'; import type { HTMLAnchorAttributes, HTMLButtonAttributes } from 'svelte/elements'; export type Color = 'primary' | 'secondary' | 'success' | 'danger' | 'warning' | 'info'; @@ -5,6 +6,7 @@ export type Size = 'tiny' | 'small' | 'medium' | 'large' | 'giant'; export type HeadingSize = Size | 'title'; export type Shape = 'rectangle' | 'semi-round' | 'round'; export type Variants = 'filled' | 'outline' | 'ghost' | 'hero'; +export type Gap = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8; type ButtonOrAnchor = | ({ href?: never } & HTMLButtonAttributes) @@ -35,3 +37,17 @@ export type IconProps = { export type IconButtonProps = ButtonBaseProps & IconProps; export type ButtonProps = ButtonBaseProps & { fullWidth?: boolean }; + +type StackBaseProps = { + class?: string; + children: Snippet; + align?: 'start' | 'center' | 'end'; + gap?: Gap; + wrap?: boolean; +}; + +export type StackProps = StackBaseProps & { + direction?: 'row' | 'column'; +}; +export type HStackProps = StackBaseProps; +export type VStackProps = StackBaseProps; diff --git a/src/routes/examples/alert/+page.svelte b/src/routes/examples/alert/+page.svelte index 70e3e81..b5b5686 100644 --- a/src/routes/examples/alert/+page.svelte +++ b/src/routes/examples/alert/+page.svelte @@ -2,78 +2,64 @@ import DualThemeLayout from '$docs/components/DualThemeLayout.svelte'; import Lorem from '$docs/components/Lorem.svelte'; import { colors } from '$docs/constants.js'; - import Card from '$lib/components/Card/Card.svelte'; - import CardBody from '$lib/components/Card/CardBody.svelte'; - import CardHeader from '$lib/components/Card/CardHeader.svelte'; - import CardTitle from '$lib/components/Card/CardTitle.svelte'; - import { Alert } from '@immich/ui'; + import { Alert, Card, CardBody, CardHeader, CardTitle, VStack } from '@immich/ui'; import { mdiHelpCircleOutline } from '@mdi/js'; {#snippet component()} -
-
- - - Basic - - -
- {#each colors as color} - - {/each} -
-
-
-
+ + + Basic + + + + {#each colors as color} + + {/each} + + + -
- - - Colors - - -
- {#each colors as color} - - - - {/each} -
-
-
-
- -
- - - Custom icon - - - + + + Colors + + + + {#each colors as color} + - - -
+ {/each} + + + + + + + Custom icon + + + + + + + -
- - - Colors - - -
- {#each colors as color} - - - - {/each} -
-
-
-
-
+ + + Colors + + + + {#each colors as color} + + + + {/each} + + + {/snippet}
diff --git a/src/routes/examples/button/+page.svelte b/src/routes/examples/button/+page.svelte index 07eaa5f..e7749f8 100644 --- a/src/routes/examples/button/+page.svelte +++ b/src/routes/examples/button/+page.svelte @@ -1,119 +1,117 @@ {#snippet component()} -
- - - Shapes - - -
- {#each shapes as shape} - - {/each} -
-
-
+ + + Shapes + + + + {#each shapes as shape} + + {/each} + + + - - - Colors - - -
- {#each colors as color} - - {/each} -
-
-
+ + + Colors + + + + {#each colors as color} + + {/each} + + + - - - Outline - - -
- {#each colors as color} - - {/each} -
-
-
+ + + Outline + + + + {#each colors as color} + + {/each} + + + - - - Ghost - - -
- {#each colors as color} - - {/each} -
-
-
+ + + Ghost + + + + {#each colors as color} + + {/each} + + + - - - Hero - - -
- {#each colors as color} - - {/each} -
-
-
+ + + Hero + + + + {#each colors as color} + + {/each} + + + - - - Disabled - - -
- {#each colors as color} - - {/each} -
-
-
+ + + Disabled + + + + {#each colors as color} + + {/each} + + + - - - Sizes - - -
- {#each sizes as size} -
- -
- {/each} -
-
-
+ + + Sizes + + + + {#each sizes as size} +
+ +
+ {/each} +
+
+
- - - Full width - - -
- {#each colors as color} -
- -
- {/each} -
-
-
-
+ + + Full width + + + + {#each colors as color} +
+ +
+ {/each} +
+
+
{/snippet}
diff --git a/src/routes/examples/card/+page.svelte b/src/routes/examples/card/+page.svelte index abd87d7..c8434d7 100644 --- a/src/routes/examples/card/+page.svelte +++ b/src/routes/examples/card/+page.svelte @@ -7,122 +7,106 @@ {#snippet component()} -
-
- - - Title - - + + + Title + + - - - Card with title - - - - - + + + Card with title + + + + + - - - Card with title and footer - - - - - Footer goes here - + + + Card with title and footer + + + + + Footer goes here + - - - Card with title, description, and footer - This is the description - - - - - Footer - + + + Card with title, description, and footer + This is the description + + + + + Footer + -
- {#each colors as color} - - - Outline ({color}) - - - - - - {/each} -
+ {#each colors as color} + + + Outline ({color}) + + + + + + {/each} -
- {#each colors as color} - - - Filled ({color}) - - - - - - {/each} -
+ {#each colors as color} + + + Filled ({color}) + + + + + + {/each} -
- {#each colors as color} - - - Subtle ({color}) - - - - - - {/each} -
+ {#each colors as color} + + + Subtle ({color}) + + + + + + {/each} -
- {#each colors as color} - - - Outline ({color}) - - - - - - {/each} -
+ {#each colors as color} + + + Outline ({color}) + + + + + + {/each} -
- {#each colors as color} - - - Filled ({color}) - - - - - - {/each} -
+ {#each colors as color} + + + Filled ({color}) + + + + + + {/each} -
- {#each colors as color} - - - Subtle ({color}) - - - - - - {/each} -
-
-
+ {#each colors as color} + + + Subtle ({color}) + + + + + + {/each} {/snippet}
diff --git a/src/routes/examples/checkbox/+page.svelte b/src/routes/examples/checkbox/+page.svelte index 77770fb..26041b7 100644 --- a/src/routes/examples/checkbox/+page.svelte +++ b/src/routes/examples/checkbox/+page.svelte @@ -1,62 +1,60 @@ {#snippet component()} -
- - - Colors - - -
- {#each colors as color} -
- - - -
- {/each} -
-
-
+ + + Colors + + + + {#each colors as color} + + + + + + {/each} + + + - - - Sizes - - -
- {#each sizes as size} -
- - - -
- {/each} -
-
-
+ + + Sizes + + + + {#each sizes as size} + + + + + + {/each} + + + - - - Shapes - - -
- {#each shapes as shape} -
- - - -
- {/each} -
-
-
-
+ + + Shapes + + + + {#each shapes as shape} + + + + + + {/each} + + + {/snippet}
diff --git a/src/routes/examples/heading/+page.svelte b/src/routes/examples/heading/+page.svelte index 9207298..652c5e5 100644 --- a/src/routes/examples/heading/+page.svelte +++ b/src/routes/examples/heading/+page.svelte @@ -1,42 +1,40 @@ {#snippet component()} -
- - - Sizes - - -
- {text} (tiny) - {text} (small) - {text} (medium) - {text} (large) - {text} (giant) - {text} (title) -
-
-
+ + + Sizes + + + + {text} (tiny) + {text} (small) + {text} (medium) + {text} (large) + {text} (giant) + {text} (title) + + + - - - Colors - - -
- {#each colors as color} - {text} ({color}) - {/each} -
-
-
-
+ + + Colors + + + + {#each colors as color} + {text} ({color}) + {/each} + + + {/snippet}
diff --git a/src/routes/examples/icon-button/+page.svelte b/src/routes/examples/icon-button/+page.svelte index e4e177f..3f9a60c 100644 --- a/src/routes/examples/icon-button/+page.svelte +++ b/src/routes/examples/icon-button/+page.svelte @@ -1,7 +1,7 @@ {#snippet component({ theme })} -
- - - Logo - - -
- {#each sizes as size} -
- - - -
- {/each} -
-
-
- - - Icon - - - {#each sizes as size} -
- -
- {/each} -
-
- - - Inline - - + + + Logo + + + {#each sizes as size} -
- -
+ + + + + + + + + {/each} -
-
+ +
+
+ + + Icon + + + {#each sizes as size} +
+ +
+ {/each} +
+
+ + + Inline + + + {#each sizes as size} +
+ +
+ {/each} +
+
- - - Stacked - - - {#each sizes as size} -
- -
- {/each} -
-
-
+ + + Stacked + + + {#each sizes as size} +
+ +
+ {/each} +
+
{/snippet}
diff --git a/src/routes/examples/stack/+page.svelte b/src/routes/examples/stack/+page.svelte new file mode 100644 index 0000000..92dca07 --- /dev/null +++ b/src/routes/examples/stack/+page.svelte @@ -0,0 +1,48 @@ + + + + {#snippet component()} + + + Stack + + + + + + + + + + + + + HStack + + + + + + + + + + + + + VStack + + + + + + + + + + {/snippet} + diff --git a/src/routes/examples/text/+page.svelte b/src/routes/examples/text/+page.svelte index a2b1b74..9f4ca1c 100644 --- a/src/routes/examples/text/+page.svelte +++ b/src/routes/examples/text/+page.svelte @@ -1,43 +1,41 @@ {#snippet component()} -
-
- - - Sizes - - -
- {text} (tiny) - {text} (small) - {text} (medium) - {text} (large) - {text} (giant) -
-
-
+ + + + Sizes + + + + {text} (tiny) + {text} (small) + {text} (medium) + {text} (large) + {text} (giant) + + + - - - Colors - - -
- {#each colors as color} - {text} ({color}) - {/each} -
-
-
-
-
+ + + Colors + + + + {#each colors as color} + {text} ({color}) + {/each} + + + + {/snippet}