diff --git a/src/lib/components/Checkbox.svelte b/src/lib/components/Form/Checkbox.svelte
similarity index 97%
rename from src/lib/components/Checkbox.svelte
rename to src/lib/components/Form/Checkbox.svelte
index 23334d8..1ec85f6 100644
--- a/src/lib/components/Checkbox.svelte
+++ b/src/lib/components/Form/Checkbox.svelte
@@ -1,7 +1,7 @@
-
-
diff --git a/src/lib/components/Icon/Icon.svelte b/src/lib/components/Icon/Icon.svelte
new file mode 100644
index 0000000..970a814
--- /dev/null
+++ b/src/lib/components/Icon/Icon.svelte
@@ -0,0 +1,52 @@
+
+
+
+
+
diff --git a/src/lib/components/IconButton.svelte b/src/lib/components/IconButton/IconButton.svelte
similarity index 53%
rename from src/lib/components/IconButton.svelte
rename to src/lib/components/IconButton/IconButton.svelte
index 54d0c53..38f3dda 100644
--- a/src/lib/components/IconButton.svelte
+++ b/src/lib/components/IconButton/IconButton.svelte
@@ -1,11 +1,11 @@
-
+
diff --git a/src/lib/components/Logo.svelte b/src/lib/components/Logo/Logo.svelte
similarity index 100%
rename from src/lib/components/Logo.svelte
rename to src/lib/components/Logo/Logo.svelte
diff --git a/src/lib/components/index.ts b/src/lib/components/index.ts
deleted file mode 100644
index f967a29..0000000
--- a/src/lib/components/index.ts
+++ /dev/null
@@ -1,13 +0,0 @@
-export { default as Button } from '$lib/components/Button.svelte';
-export { default as Card } from '$lib/components/Card.svelte';
-export { default as CardBody } from '$lib/components/CardBody.svelte';
-export { default as CardDescription } from '$lib/components/CardDescription.svelte';
-export { default as CardFooter } from '$lib/components/CardFooter.svelte';
-export { default as CardHeader } from '$lib/components/CardHeader.svelte';
-export { default as CardTitle } from '$lib/components/CardTitle.svelte';
-export { default as Checkbox } from '$lib/components/Checkbox.svelte';
-export { default as Icon } from '$lib/components/Icon.svelte';
-export { default as IconButton } from '$lib/components/IconButton.svelte';
-export { default as Input } from '$lib/components/Input.svelte';
-export { default as Label } from '$lib/components/Label.svelte';
-export { default as Logo } from '$lib/components/Logo.svelte';
diff --git a/src/lib/constants.ts b/src/lib/constants.ts
new file mode 100644
index 0000000..5e3aae0
--- /dev/null
+++ b/src/lib/constants.ts
@@ -0,0 +1,6 @@
+export enum ContextKey {
+ Card = 'card',
+ CardHeader = 'card-header',
+ CardBody = 'card-body',
+ CardFooter = 'card-footer',
+}
diff --git a/src/lib/index.ts b/src/lib/index.ts
index bb7d297..5e826bb 100644
--- a/src/lib/index.ts
+++ b/src/lib/index.ts
@@ -1,2 +1,14 @@
-export * from '$lib/components/index.js';
+export { default as Button } from '$lib/components/Button/Button.svelte';
+export { default as Card } from '$lib/components/Card/Card.svelte';
+export { default as CardBody } from '$lib/components/Card/CardBody.svelte';
+export { default as CardDescription } from '$lib/components/Card/CardDescription.svelte';
+export { default as CardFooter } from '$lib/components/Card/CardFooter.svelte';
+export { default as CardHeader } from '$lib/components/Card/CardHeader.svelte';
+export { default as CardTitle } from '$lib/components/Card/CardTitle.svelte';
+export { default as Checkbox } from '$lib/components/Form/Checkbox.svelte';
+export { default as Icon } from '$lib/components/Icon/Icon.svelte';
+export { default as IconButton } from '$lib/components/IconButton/IconButton.svelte';
+export { default as Input } from '$lib/components/Form/Input.svelte';
+export { default as Label } from '$lib/components/Form/Label.svelte';
+export { default as Logo } from '$lib/components/Logo/Logo.svelte';
export * from '$lib/types.js';
diff --git a/src/lib/internal/Child.svelte b/src/lib/internal/Child.svelte
new file mode 100644
index 0000000..439b738
--- /dev/null
+++ b/src/lib/internal/Child.svelte
@@ -0,0 +1,20 @@
+
diff --git a/src/lib/internal/InternalButton.svelte b/src/lib/internal/InternalButton.svelte
index 106266e..03637a4 100644
--- a/src/lib/internal/InternalButton.svelte
+++ b/src/lib/internal/InternalButton.svelte
@@ -3,6 +3,7 @@
import { cleanClass } from '$lib/utils.js';
import { Button as ButtonPrimitive } from 'bits-ui';
import type { HTMLAnchorAttributes, HTMLButtonAttributes } from 'svelte/elements';
+ import { twMerge } from 'tailwind-merge';
import { tv } from 'tailwind-variants';
const buttonVariants = tv({
@@ -95,19 +96,21 @@
const classList = $derived(
cleanClass(
- buttonVariants({
- shape,
- fullWidth,
- textPadding: icon ? undefined : size,
- textSize: size,
- iconSize: icon ? size : undefined,
- roundedSize: shape === 'semi-round' ? size : undefined,
- filledColor: variant === 'filled' ? color : undefined,
- outlineColor: variant === 'outline' ? color : undefined,
- heroColor: variant === 'hero' ? color : undefined,
- ghostColor: variant === 'ghost' ? color : undefined,
- }),
- className,
+ twMerge(
+ buttonVariants({
+ shape,
+ fullWidth,
+ textPadding: icon ? undefined : size,
+ textSize: size,
+ iconSize: icon ? size : undefined,
+ roundedSize: shape === 'semi-round' ? size : undefined,
+ filledColor: variant === 'filled' ? color : undefined,
+ outlineColor: variant === 'outline' ? color : undefined,
+ heroColor: variant === 'hero' ? color : undefined,
+ ghostColor: variant === 'ghost' ? color : undefined,
+ }),
+ className,
+ ),
),
);
diff --git a/src/lib/types.ts b/src/lib/types.ts
index 079dfb2..4e794b6 100644
--- a/src/lib/types.ts
+++ b/src/lib/types.ts
@@ -3,6 +3,7 @@ import type { HTMLAnchorAttributes, HTMLButtonAttributes } from 'svelte/elements
export type Color = 'primary' | 'secondary' | 'success' | 'danger' | 'warning' | 'info';
export type Size = 'tiny' | 'small' | 'medium' | 'large' | 'giant';
export type Shape = 'rectangle' | 'semi-round' | 'round';
+export type Variants = 'filled' | 'outline' | 'ghost' | 'hero';
type ButtonOrAnchor =
| ({ href?: never } & HTMLButtonAttributes)
@@ -13,13 +14,25 @@ type ButtonBaseProps = {
color?: Color;
size?: Size;
shape?: Shape;
- variant?: 'filled' | 'outline' | 'ghost' | 'hero';
+ variant?: Variants;
} & ButtonOrAnchor;
-export type IconButtonProps = ButtonBaseProps & {
- /** icon from `@mdi/js` (svg string) */
+export type IconProps = {
icon: string;
+ title?: string;
+ description?: string;
+ size?: string;
+ color?: Color | 'currentColor' | string;
+ flipped?: boolean;
+ flopped?: boolean;
+ spin?: boolean;
+ class?: string;
+ viewBox?: string;
+ strokeWidth?: number;
+ strokeColor?: string;
};
+
+export type IconButtonProps = ButtonBaseProps & IconProps;
export type ButtonProps = ButtonBaseProps & { fullWidth?: boolean };
export type InternalButtonProps = ButtonProps & {
/** when true, button width to height ratio is 1:1 */
diff --git a/src/lib/utils.ts b/src/lib/utils.ts
index 7c42b9d..1ec1c5c 100644
--- a/src/lib/utils.ts
+++ b/src/lib/utils.ts
@@ -1,3 +1,5 @@
+import type { ContextKey } from '$lib/constants.js';
+
export const cleanClass = (...classNames: unknown[]) => {
return classNames
.filter((className) => {
@@ -9,3 +11,5 @@ export const cleanClass = (...classNames: unknown[]) => {
})
.join(' ');
};
+
+export const withPrefix = (key: ContextKey) => `immich-ui-${key}`;
diff --git a/src/routes/examples/card/+page.svelte b/src/routes/examples/card/+page.svelte
index f6d717f..728bf06 100644
--- a/src/routes/examples/card/+page.svelte
+++ b/src/routes/examples/card/+page.svelte
@@ -1,5 +1,7 @@
@@ -8,13 +10,9 @@
-
-
- Lorem, ipsum dolor sit amet consectetur adipisicing elit. Quibusdam maxime illo sequi
- ipsam possimus rem harum nostrum esse itaque vero blanditiis eius sit ducimus
- doloremque, omnis, assumenda mollitia officia aliquid.
-
-
+
+ Title
+
@@ -22,11 +20,7 @@
Card with title
-
- Lorem, ipsum dolor sit amet consectetur adipisicing elit. Quibusdam maxime illo sequi
- ipsam possimus rem harum nostrum esse itaque vero blanditiis eius sit ducimus
- doloremque, omnis, assumenda mollitia officia aliquid.
-
+
@@ -35,11 +29,7 @@
Card with title and footer
-
- Lorem, ipsum dolor sit amet consectetur adipisicing elit. Quibusdam maxime illo sequi
- ipsam possimus rem harum nostrum esse itaque vero blanditiis eius sit ducimus
- doloremque, omnis, assumenda mollitia officia aliquid.
-
+ Footer goes here
@@ -50,14 +40,62 @@
This is the description
-
- Lorem, ipsum dolor sit amet consectetur adipisicing elit. Quibusdam maxime illo sequi
- ipsam possimus rem harum nostrum esse itaque vero blanditiis eius sit ducimus
- doloremque, omnis, assumenda mollitia officia aliquid.
-