@websline/system-components 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -0
- package/dist/components/atoms/avatar/Avatar.svelte +78 -0
- package/dist/components/atoms/avatar/Avatar.svelte.d.ts +65 -0
- package/dist/components/atoms/avatar/avatar.variants.d.ts +37 -0
- package/dist/components/atoms/avatar/avatar.variants.js +20 -0
- package/dist/components/atoms/closeButton/CloseButton.svelte +92 -0
- package/dist/components/atoms/closeButton/CloseButton.svelte.d.ts +25 -0
- package/dist/components/atoms/closeButton/closeButton.variants.d.ts +37 -0
- package/dist/components/atoms/closeButton/closeButton.variants.js +21 -0
- package/dist/components/atoms/form/button/Button.svelte +67 -0
- package/dist/components/atoms/form/button/Button.svelte.d.ts +81 -0
- package/dist/components/atoms/form/button/button.variants.d.ts +58 -0
- package/dist/components/atoms/form/button/button.variants.js +82 -0
- package/dist/components/atoms/form/formField/FormField.svelte +69 -0
- package/dist/components/atoms/form/formField/FormField.svelte.d.ts +73 -0
- package/dist/components/atoms/form/helperText/HelperText.svelte +18 -0
- package/dist/components/atoms/form/helperText/HelperText.svelte.d.ts +15 -0
- package/dist/components/atoms/form/iconButton/IconButton.svelte +69 -0
- package/dist/components/atoms/form/iconButton/IconButton.svelte.d.ts +89 -0
- package/dist/components/atoms/form/iconButton/iconButton.variants.d.ts +64 -0
- package/dist/components/atoms/form/iconButton/iconButton.variants.js +91 -0
- package/dist/components/atoms/form/input/Input.svelte +65 -0
- package/dist/components/atoms/form/input/Input.svelte.d.ts +89 -0
- package/dist/components/atoms/form/input/input.variants.d.ts +22 -0
- package/dist/components/atoms/form/input/input.variants.js +15 -0
- package/dist/components/atoms/form/label/Label.svelte +36 -0
- package/dist/components/atoms/form/label/Label.svelte.d.ts +41 -0
- package/dist/components/atoms/form/textarea/Textarea.svelte +64 -0
- package/dist/components/atoms/form/textarea/Textarea.svelte.d.ts +89 -0
- package/dist/components/atoms/form/textarea/textarea.variants.d.ts +37 -0
- package/dist/components/atoms/form/textarea/textarea.variants.js +20 -0
- package/dist/components/atoms/icon/Icon.svelte +41 -0
- package/dist/components/atoms/icon/Icon.svelte.d.ts +21 -0
- package/dist/components/atoms/icon/components/Academy.svelte +27 -0
- package/dist/components/atoms/icon/components/Academy.svelte.d.ts +41 -0
- package/dist/components/atoms/icon/components/Bold.svelte +27 -0
- package/dist/components/atoms/icon/components/Bold.svelte.d.ts +41 -0
- package/dist/components/atoms/icon/components/Close.svelte +27 -0
- package/dist/components/atoms/icon/components/Close.svelte.d.ts +41 -0
- package/dist/components/atoms/icon/components/Italic.svelte +27 -0
- package/dist/components/atoms/icon/components/Italic.svelte.d.ts +41 -0
- package/dist/components/atoms/icon/components/Link.svelte +27 -0
- package/dist/components/atoms/icon/components/Link.svelte.d.ts +41 -0
- package/dist/components/atoms/icon/components/ListOrdered.svelte +27 -0
- package/dist/components/atoms/icon/components/ListOrdered.svelte.d.ts +41 -0
- package/dist/components/atoms/icon/components/ListUnordered.svelte +26 -0
- package/dist/components/atoms/icon/components/ListUnordered.svelte.d.ts +41 -0
- package/dist/components/atoms/icon/components/Refresh.svelte +27 -0
- package/dist/components/atoms/icon/components/Refresh.svelte.d.ts +41 -0
- package/dist/components/atoms/icon/components/Underline.svelte +26 -0
- package/dist/components/atoms/icon/components/Underline.svelte.d.ts +41 -0
- package/dist/components/atoms/icon/index.d.ts +20 -0
- package/dist/components/atoms/icon/index.js +21 -0
- package/dist/components/atoms/loading/spinner/Spinner.svelte +40 -0
- package/dist/components/atoms/loading/spinner/Spinner.svelte.d.ts +25 -0
- package/dist/components/molecules/notification/Notification.svelte +42 -0
- package/dist/components/molecules/notification/Notification.svelte.d.ts +57 -0
- package/dist/components/molecules/notification/notification.variants.d.ts +67 -0
- package/dist/components/molecules/notification/notification.variants.js +30 -0
- package/dist/components/molecules/richTextEditor/RichTextEditor.svelte +144 -0
- package/dist/components/molecules/richTextEditor/RichTextEditor.svelte.d.ts +87 -0
- package/dist/components/molecules/richTextEditor/RichTextEditorToolbar.svelte +5 -0
- package/dist/components/molecules/richTextEditor/RichTextEditorToolbar.svelte.d.ts +11 -0
- package/dist/components/molecules/richTextEditor/richTextEditor.variants.d.ts +64 -0
- package/dist/components/molecules/richTextEditor/richTextEditor.variants.js +30 -0
- package/dist/components/molecules/toggleGroup/ToggleGroup.svelte +61 -0
- package/dist/components/molecules/toggleGroup/ToggleGroup.svelte.d.ts +49 -0
- package/dist/components/molecules/toggleGroup/ToggleGroupItem.svelte +47 -0
- package/dist/components/molecules/toggleGroup/ToggleGroupItem.svelte.d.ts +25 -0
- package/dist/components/molecules/toggleGroup/toggleGroup.variants.d.ts +35 -0
- package/dist/components/molecules/toggleGroup/toggleGroup.variants.js +21 -0
- package/dist/components/molecules/toggleGroup/toggleGroupItem.variants.d.ts +110 -0
- package/dist/components/molecules/toggleGroup/toggleGroupItem.variants.js +69 -0
- package/dist/components/organisms/notificationGroup/NotificationGroup.svelte +68 -0
- package/dist/components/organisms/notificationGroup/NotificationGroup.svelte.d.ts +6 -0
- package/dist/components/organisms/notificationGroup/notificationGroup.variants.d.ts +24 -0
- package/dist/components/organisms/notificationGroup/notificationGroup.variants.js +11 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.js +32 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +1 -0
- package/dist/utils/notification.d.ts +1 -0
- package/dist/utils/notification.js +11 -0
- package/package.json +95 -0
package/README.md
ADDED
|
File without changes
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import { avatarVariants } from "./avatar.variants.js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @typedef {Object} Props
|
|
6
|
+
* @property {string} [as="div"] The HTML element to use for the avatar
|
|
7
|
+
* @property {string} [class=""] Additional CSS classes to apply to the component
|
|
8
|
+
* @property {boolean} [lazy=true] Whether the avatar should be lazy-loaded
|
|
9
|
+
* @property {string} [name=""] The name of the avatar
|
|
10
|
+
* @property {"circle" | "square"} [shape="square"] The shape of the avatar
|
|
11
|
+
* @property {"small" | "medium" | "large" | "extraLarge"} [size="medium"] Avatar size
|
|
12
|
+
* @property {string} [src=""] The source URL of the avatar image
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/** @type {Props} */
|
|
16
|
+
let {
|
|
17
|
+
as = "button",
|
|
18
|
+
class: className = "",
|
|
19
|
+
lazy = true,
|
|
20
|
+
name,
|
|
21
|
+
shape = "square",
|
|
22
|
+
size = "medium",
|
|
23
|
+
src,
|
|
24
|
+
...rest
|
|
25
|
+
} = $props();
|
|
26
|
+
|
|
27
|
+
let initials = $derived.by(() => {
|
|
28
|
+
if (name) {
|
|
29
|
+
return (
|
|
30
|
+
name
|
|
31
|
+
.split(" ")
|
|
32
|
+
.map((word) => word.charAt(0).toUpperCase())
|
|
33
|
+
.join("")
|
|
34
|
+
?.slice(0, 2) || ""
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
return "";
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
let avatarSize = $derived.by(() => {
|
|
41
|
+
switch (size) {
|
|
42
|
+
case "small":
|
|
43
|
+
return 24;
|
|
44
|
+
case "medium":
|
|
45
|
+
return 40;
|
|
46
|
+
case "large":
|
|
47
|
+
return 56;
|
|
48
|
+
case "extraLarge":
|
|
49
|
+
return 64;
|
|
50
|
+
default:
|
|
51
|
+
return 40;
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
let { base, image, fallback } = avatarVariants();
|
|
56
|
+
|
|
57
|
+
let showImage = $derived(Boolean(src));
|
|
58
|
+
</script>
|
|
59
|
+
|
|
60
|
+
<svelte:element
|
|
61
|
+
this={as}
|
|
62
|
+
class={base({ as, class: className, shape })}
|
|
63
|
+
style={`width: ${avatarSize}px; height: ${avatarSize}px;`}
|
|
64
|
+
type={as === "button" ? "button" : undefined}
|
|
65
|
+
{...src && showImage ? {} : { role: "img", "aria-label": name || "" }}
|
|
66
|
+
{...rest}>
|
|
67
|
+
{#if src && showImage}
|
|
68
|
+
<img
|
|
69
|
+
alt={name || ""}
|
|
70
|
+
class={image()}
|
|
71
|
+
decoding="async"
|
|
72
|
+
loading={lazy ? "lazy" : "eager"}
|
|
73
|
+
{src}
|
|
74
|
+
onerror={() => (showImage = false)} />
|
|
75
|
+
{:else}
|
|
76
|
+
<span class={fallback()}>{initials}</span>
|
|
77
|
+
{/if}
|
|
78
|
+
</svelte:element>
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
export default Avatar;
|
|
2
|
+
type Avatar = {
|
|
3
|
+
$on?(type: string, callback: (e: any) => void): () => void;
|
|
4
|
+
$set?(props: Partial<Props>): void;
|
|
5
|
+
};
|
|
6
|
+
declare const Avatar: import("svelte").Component<{
|
|
7
|
+
/**
|
|
8
|
+
* The HTML element to use for the avatar
|
|
9
|
+
*/
|
|
10
|
+
as?: string;
|
|
11
|
+
/**
|
|
12
|
+
* Additional CSS classes to apply to the component
|
|
13
|
+
*/
|
|
14
|
+
class?: string;
|
|
15
|
+
/**
|
|
16
|
+
* Whether the avatar should be lazy-loaded
|
|
17
|
+
*/
|
|
18
|
+
lazy?: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* The name of the avatar
|
|
21
|
+
*/
|
|
22
|
+
name?: string;
|
|
23
|
+
/**
|
|
24
|
+
* The shape of the avatar
|
|
25
|
+
*/
|
|
26
|
+
shape?: "circle" | "square";
|
|
27
|
+
/**
|
|
28
|
+
* Avatar size
|
|
29
|
+
*/
|
|
30
|
+
size?: "small" | "medium" | "large" | "extraLarge";
|
|
31
|
+
/**
|
|
32
|
+
* The source URL of the avatar image
|
|
33
|
+
*/
|
|
34
|
+
src?: string;
|
|
35
|
+
}, {}, "">;
|
|
36
|
+
type Props = {
|
|
37
|
+
/**
|
|
38
|
+
* The HTML element to use for the avatar
|
|
39
|
+
*/
|
|
40
|
+
as?: string;
|
|
41
|
+
/**
|
|
42
|
+
* Additional CSS classes to apply to the component
|
|
43
|
+
*/
|
|
44
|
+
class?: string;
|
|
45
|
+
/**
|
|
46
|
+
* Whether the avatar should be lazy-loaded
|
|
47
|
+
*/
|
|
48
|
+
lazy?: boolean;
|
|
49
|
+
/**
|
|
50
|
+
* The name of the avatar
|
|
51
|
+
*/
|
|
52
|
+
name?: string;
|
|
53
|
+
/**
|
|
54
|
+
* The shape of the avatar
|
|
55
|
+
*/
|
|
56
|
+
shape?: "circle" | "square";
|
|
57
|
+
/**
|
|
58
|
+
* Avatar size
|
|
59
|
+
*/
|
|
60
|
+
size?: "small" | "medium" | "large" | "extraLarge";
|
|
61
|
+
/**
|
|
62
|
+
* The source URL of the avatar image
|
|
63
|
+
*/
|
|
64
|
+
src?: string;
|
|
65
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export const avatarVariants: import("tailwind-variants").TVReturnType<{
|
|
2
|
+
as: {
|
|
3
|
+
button: string;
|
|
4
|
+
};
|
|
5
|
+
shape: {
|
|
6
|
+
circle: string;
|
|
7
|
+
square: string;
|
|
8
|
+
};
|
|
9
|
+
}, {
|
|
10
|
+
base: string;
|
|
11
|
+
image: string;
|
|
12
|
+
fallback: string;
|
|
13
|
+
}, undefined, {
|
|
14
|
+
as: {
|
|
15
|
+
button: string;
|
|
16
|
+
};
|
|
17
|
+
shape: {
|
|
18
|
+
circle: string;
|
|
19
|
+
square: string;
|
|
20
|
+
};
|
|
21
|
+
}, {
|
|
22
|
+
base: string;
|
|
23
|
+
image: string;
|
|
24
|
+
fallback: string;
|
|
25
|
+
}, import("tailwind-variants").TVReturnType<{
|
|
26
|
+
as: {
|
|
27
|
+
button: string;
|
|
28
|
+
};
|
|
29
|
+
shape: {
|
|
30
|
+
circle: string;
|
|
31
|
+
square: string;
|
|
32
|
+
};
|
|
33
|
+
}, {
|
|
34
|
+
base: string;
|
|
35
|
+
image: string;
|
|
36
|
+
fallback: string;
|
|
37
|
+
}, undefined, unknown, unknown, undefined>>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { tv } from "tailwind-variants";
|
|
2
|
+
|
|
3
|
+
const avatarVariants = tv({
|
|
4
|
+
slots: {
|
|
5
|
+
base: "overflow-hidden flex",
|
|
6
|
+
image: "object-cover w-full h-full",
|
|
7
|
+
fallback: "bg-blue-100 w-full h-full flex items-center justify-center heading-h6",
|
|
8
|
+
},
|
|
9
|
+
variants: {
|
|
10
|
+
as: {
|
|
11
|
+
button: "cursor-pointer",
|
|
12
|
+
},
|
|
13
|
+
shape: {
|
|
14
|
+
circle: "rounded-full",
|
|
15
|
+
square: "rounded",
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
export { avatarVariants };
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import { Icon } from "../../../index.js";
|
|
3
|
+
import { closeButtonVariants } from "./closeButton.variants.js";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @typedef {Object} Props
|
|
7
|
+
* @property {string} [class=""] Additional CSS classes to apply to the component
|
|
8
|
+
* @property {"circle" | "square"} [shape="round"] Button shape
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/** @type {Props} */
|
|
12
|
+
let {
|
|
13
|
+
autoClose = false,
|
|
14
|
+
class: className = "",
|
|
15
|
+
durationInSeconds = 6,
|
|
16
|
+
onClose,
|
|
17
|
+
shape = "square",
|
|
18
|
+
...rest
|
|
19
|
+
} = $props();
|
|
20
|
+
|
|
21
|
+
let barEl = $state();
|
|
22
|
+
let animate = $derived(autoClose);
|
|
23
|
+
|
|
24
|
+
const handleMouseOver = () => {
|
|
25
|
+
if (!barEl) {
|
|
26
|
+
animate = true;
|
|
27
|
+
calculatedDurationInSeconds = 2 * 100;
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const parent = barEl.parentElement;
|
|
32
|
+
const parentW = parent.getBoundingClientRect().width;
|
|
33
|
+
const currentW = barEl.getBoundingClientRect().width;
|
|
34
|
+
|
|
35
|
+
barEl.style.animation = "none";
|
|
36
|
+
barEl.style.width = `${currentW}px`;
|
|
37
|
+
|
|
38
|
+
void barEl.offsetWidth;
|
|
39
|
+
|
|
40
|
+
barEl.style.transition = "width 300ms";
|
|
41
|
+
barEl.style.width = `${parentW}px`;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
let { bar, button } = closeButtonVariants();
|
|
45
|
+
|
|
46
|
+
let calculatedDurationInSeconds = $derived(durationInSeconds * 1000);
|
|
47
|
+
|
|
48
|
+
const handleClose = () => {
|
|
49
|
+
onClose();
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const handleAnimationComplete = () => {
|
|
53
|
+
if (autoClose) onClose();
|
|
54
|
+
};
|
|
55
|
+
</script>
|
|
56
|
+
|
|
57
|
+
<button
|
|
58
|
+
class={button({
|
|
59
|
+
animate,
|
|
60
|
+
class: className,
|
|
61
|
+
shape,
|
|
62
|
+
})}
|
|
63
|
+
onclick={handleClose}
|
|
64
|
+
onmouseenter={handleMouseOver}
|
|
65
|
+
{...rest}>
|
|
66
|
+
<Icon class="relative z-10" name="close" size={16} />
|
|
67
|
+
{#if animate}
|
|
68
|
+
<span
|
|
69
|
+
bind:this={barEl}
|
|
70
|
+
class={bar()}
|
|
71
|
+
style={`animation-duration: ${calculatedDurationInSeconds}ms`}
|
|
72
|
+
onanimationend={handleAnimationComplete}>
|
|
73
|
+
</span>
|
|
74
|
+
{/if}
|
|
75
|
+
</button>
|
|
76
|
+
|
|
77
|
+
<style>
|
|
78
|
+
span {
|
|
79
|
+
animation-fill-mode: forwards;
|
|
80
|
+
animation-name: fill;
|
|
81
|
+
animation-timing-function: linear;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
@keyframes fill {
|
|
85
|
+
from {
|
|
86
|
+
width: 0%;
|
|
87
|
+
}
|
|
88
|
+
to {
|
|
89
|
+
width: 100%;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
</style>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export default CloseButton;
|
|
2
|
+
type CloseButton = {
|
|
3
|
+
$on?(type: string, callback: (e: any) => void): () => void;
|
|
4
|
+
$set?(props: Partial<Props>): void;
|
|
5
|
+
};
|
|
6
|
+
declare const CloseButton: import("svelte").Component<{
|
|
7
|
+
/**
|
|
8
|
+
* Additional CSS classes to apply to the component
|
|
9
|
+
*/
|
|
10
|
+
class?: string;
|
|
11
|
+
/**
|
|
12
|
+
* Button shape
|
|
13
|
+
*/
|
|
14
|
+
shape?: "circle" | "square";
|
|
15
|
+
}, {}, "">;
|
|
16
|
+
type Props = {
|
|
17
|
+
/**
|
|
18
|
+
* Additional CSS classes to apply to the component
|
|
19
|
+
*/
|
|
20
|
+
class?: string;
|
|
21
|
+
/**
|
|
22
|
+
* Button shape
|
|
23
|
+
*/
|
|
24
|
+
shape?: "circle" | "square";
|
|
25
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export const closeButtonVariants: import("tailwind-variants").TVReturnType<{
|
|
2
|
+
shape: {
|
|
3
|
+
circle: {
|
|
4
|
+
button: string;
|
|
5
|
+
};
|
|
6
|
+
square: {
|
|
7
|
+
button: string;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
}, {
|
|
11
|
+
button: string;
|
|
12
|
+
bar: string;
|
|
13
|
+
}, undefined, {
|
|
14
|
+
shape: {
|
|
15
|
+
circle: {
|
|
16
|
+
button: string;
|
|
17
|
+
};
|
|
18
|
+
square: {
|
|
19
|
+
button: string;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
}, {
|
|
23
|
+
button: string;
|
|
24
|
+
bar: string;
|
|
25
|
+
}, import("tailwind-variants").TVReturnType<{
|
|
26
|
+
shape: {
|
|
27
|
+
circle: {
|
|
28
|
+
button: string;
|
|
29
|
+
};
|
|
30
|
+
square: {
|
|
31
|
+
button: string;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
}, {
|
|
35
|
+
button: string;
|
|
36
|
+
bar: string;
|
|
37
|
+
}, undefined, unknown, unknown, undefined>>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { tv } from "tailwind-variants";
|
|
2
|
+
|
|
3
|
+
const closeButtonVariants = tv({
|
|
4
|
+
slots: {
|
|
5
|
+
button:
|
|
6
|
+
"cursor-pointer select-none p-1 transition duration-200 bg-white dark:bg-neutral-800 dark:text-white overflow-hidden relative",
|
|
7
|
+
bar: "absolute bg-gray-300 dark:bg-neutral-700 inset-[0px] z-0",
|
|
8
|
+
},
|
|
9
|
+
variants: {
|
|
10
|
+
shape: {
|
|
11
|
+
circle: {
|
|
12
|
+
button: "rounded-full",
|
|
13
|
+
},
|
|
14
|
+
square: {
|
|
15
|
+
button: "rounded-md",
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
export { closeButtonVariants };
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import { Spinner } from "../../../../index.js";
|
|
3
|
+
import { buttonVariants } from "./button.variants.js";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @typedef {Object} Props
|
|
7
|
+
* @property {string} [as="button"] The HTML element to use for the button
|
|
8
|
+
* @property {string} [class=""] Additional CSS classes to apply to the component
|
|
9
|
+
* @property {"primary" | "secondary" | "tertiary" | "success" | "danger"} [color="primary"] Button color
|
|
10
|
+
* @property {boolean} [disabled=false] Whether the button is disabled
|
|
11
|
+
* @property {boolean} [fullWidth=false] Whether the button should take the full width of its container
|
|
12
|
+
* @property {boolean} [loading=false] Whether the button is in a loading state, for example after a form submission
|
|
13
|
+
* @property {"small" | "medium" | "large"} [size="medium"] Button size
|
|
14
|
+
* @property {string} [type="button"] Button type, e.g. "button", "submit", "reset"
|
|
15
|
+
* @property {"filled" | "outlined"} [variant="filled"] Button style
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/** @type {Props} */
|
|
19
|
+
let {
|
|
20
|
+
as = "button",
|
|
21
|
+
children,
|
|
22
|
+
class: className = "",
|
|
23
|
+
color = "primary",
|
|
24
|
+
disabled = false,
|
|
25
|
+
fullWidth = false,
|
|
26
|
+
loading = false,
|
|
27
|
+
size = "medium",
|
|
28
|
+
type = "button",
|
|
29
|
+
variant = "filled",
|
|
30
|
+
...rest
|
|
31
|
+
} = $props();
|
|
32
|
+
|
|
33
|
+
let isButton = $derived(as === "button");
|
|
34
|
+
|
|
35
|
+
let tagSpecificProps = $derived.by(() => {
|
|
36
|
+
if (isButton) {
|
|
37
|
+
return {
|
|
38
|
+
disabled: disabled || loading,
|
|
39
|
+
type,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return {
|
|
44
|
+
"aria-disabled": disabled || loading ? "true" : undefined,
|
|
45
|
+
};
|
|
46
|
+
});
|
|
47
|
+
</script>
|
|
48
|
+
|
|
49
|
+
<svelte:element
|
|
50
|
+
this={as}
|
|
51
|
+
aria-busy={loading}
|
|
52
|
+
class={buttonVariants({
|
|
53
|
+
color,
|
|
54
|
+
class: className,
|
|
55
|
+
disabled,
|
|
56
|
+
fullWidth,
|
|
57
|
+
loading,
|
|
58
|
+
size,
|
|
59
|
+
variant,
|
|
60
|
+
})}
|
|
61
|
+
{...tagSpecificProps}
|
|
62
|
+
{...rest}>
|
|
63
|
+
{#if loading}
|
|
64
|
+
<Spinner size="small" />
|
|
65
|
+
{/if}
|
|
66
|
+
{@render children?.()}
|
|
67
|
+
</svelte:element>
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
export default Button;
|
|
2
|
+
type Button = {
|
|
3
|
+
$on?(type: string, callback: (e: any) => void): () => void;
|
|
4
|
+
$set?(props: Partial<Props>): void;
|
|
5
|
+
};
|
|
6
|
+
declare const Button: import("svelte").Component<{
|
|
7
|
+
/**
|
|
8
|
+
* The HTML element to use for the button
|
|
9
|
+
*/
|
|
10
|
+
as?: string;
|
|
11
|
+
/**
|
|
12
|
+
* Additional CSS classes to apply to the component
|
|
13
|
+
*/
|
|
14
|
+
class?: string;
|
|
15
|
+
/**
|
|
16
|
+
* Button color
|
|
17
|
+
*/
|
|
18
|
+
color?: "primary" | "secondary" | "tertiary" | "success" | "danger";
|
|
19
|
+
/**
|
|
20
|
+
* Whether the button is disabled
|
|
21
|
+
*/
|
|
22
|
+
disabled?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Whether the button should take the full width of its container
|
|
25
|
+
*/
|
|
26
|
+
fullWidth?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Whether the button is in a loading state, for example after a form submission
|
|
29
|
+
*/
|
|
30
|
+
loading?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Button size
|
|
33
|
+
*/
|
|
34
|
+
size?: "small" | "medium" | "large";
|
|
35
|
+
/**
|
|
36
|
+
* Button type, e.g. "button", "submit", "reset"
|
|
37
|
+
*/
|
|
38
|
+
type?: string;
|
|
39
|
+
/**
|
|
40
|
+
* Button style
|
|
41
|
+
*/
|
|
42
|
+
variant?: "filled" | "outlined";
|
|
43
|
+
}, {}, "">;
|
|
44
|
+
type Props = {
|
|
45
|
+
/**
|
|
46
|
+
* The HTML element to use for the button
|
|
47
|
+
*/
|
|
48
|
+
as?: string;
|
|
49
|
+
/**
|
|
50
|
+
* Additional CSS classes to apply to the component
|
|
51
|
+
*/
|
|
52
|
+
class?: string;
|
|
53
|
+
/**
|
|
54
|
+
* Button color
|
|
55
|
+
*/
|
|
56
|
+
color?: "primary" | "secondary" | "tertiary" | "success" | "danger";
|
|
57
|
+
/**
|
|
58
|
+
* Whether the button is disabled
|
|
59
|
+
*/
|
|
60
|
+
disabled?: boolean;
|
|
61
|
+
/**
|
|
62
|
+
* Whether the button should take the full width of its container
|
|
63
|
+
*/
|
|
64
|
+
fullWidth?: boolean;
|
|
65
|
+
/**
|
|
66
|
+
* Whether the button is in a loading state, for example after a form submission
|
|
67
|
+
*/
|
|
68
|
+
loading?: boolean;
|
|
69
|
+
/**
|
|
70
|
+
* Button size
|
|
71
|
+
*/
|
|
72
|
+
size?: "small" | "medium" | "large";
|
|
73
|
+
/**
|
|
74
|
+
* Button type, e.g. "button", "submit", "reset"
|
|
75
|
+
*/
|
|
76
|
+
type?: string;
|
|
77
|
+
/**
|
|
78
|
+
* Button style
|
|
79
|
+
*/
|
|
80
|
+
variant?: "filled" | "outlined";
|
|
81
|
+
};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
export const buttonVariants: import("tailwind-variants").TVReturnType<{
|
|
2
|
+
disabled: {
|
|
3
|
+
true: string;
|
|
4
|
+
};
|
|
5
|
+
fullWidth: {
|
|
6
|
+
true: string;
|
|
7
|
+
};
|
|
8
|
+
loading: {
|
|
9
|
+
true: string;
|
|
10
|
+
};
|
|
11
|
+
size: {
|
|
12
|
+
small: string;
|
|
13
|
+
medium: string;
|
|
14
|
+
large: string;
|
|
15
|
+
};
|
|
16
|
+
variant: {
|
|
17
|
+
filled: string;
|
|
18
|
+
outlined: string;
|
|
19
|
+
};
|
|
20
|
+
}, undefined, "flex items-center rounded cursor-pointer transition duration-200 select-none", {
|
|
21
|
+
disabled: {
|
|
22
|
+
true: string;
|
|
23
|
+
};
|
|
24
|
+
fullWidth: {
|
|
25
|
+
true: string;
|
|
26
|
+
};
|
|
27
|
+
loading: {
|
|
28
|
+
true: string;
|
|
29
|
+
};
|
|
30
|
+
size: {
|
|
31
|
+
small: string;
|
|
32
|
+
medium: string;
|
|
33
|
+
large: string;
|
|
34
|
+
};
|
|
35
|
+
variant: {
|
|
36
|
+
filled: string;
|
|
37
|
+
outlined: string;
|
|
38
|
+
};
|
|
39
|
+
}, undefined, import("tailwind-variants").TVReturnType<{
|
|
40
|
+
disabled: {
|
|
41
|
+
true: string;
|
|
42
|
+
};
|
|
43
|
+
fullWidth: {
|
|
44
|
+
true: string;
|
|
45
|
+
};
|
|
46
|
+
loading: {
|
|
47
|
+
true: string;
|
|
48
|
+
};
|
|
49
|
+
size: {
|
|
50
|
+
small: string;
|
|
51
|
+
medium: string;
|
|
52
|
+
large: string;
|
|
53
|
+
};
|
|
54
|
+
variant: {
|
|
55
|
+
filled: string;
|
|
56
|
+
outlined: string;
|
|
57
|
+
};
|
|
58
|
+
}, undefined, "flex items-center rounded cursor-pointer transition duration-200 select-none", unknown, unknown, undefined>>;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { tv } from "tailwind-variants";
|
|
2
|
+
|
|
3
|
+
const buttonVariants = tv({
|
|
4
|
+
base: "flex items-center rounded cursor-pointer transition duration-200 select-none",
|
|
5
|
+
variants: {
|
|
6
|
+
disabled: {
|
|
7
|
+
true: "opacity-40 pointer-events-none",
|
|
8
|
+
},
|
|
9
|
+
fullWidth: {
|
|
10
|
+
true: "w-full justify-center",
|
|
11
|
+
},
|
|
12
|
+
loading: {
|
|
13
|
+
true: "pointer-events-none",
|
|
14
|
+
},
|
|
15
|
+
size: {
|
|
16
|
+
small: "py-1.25 px-3 gap-2 button-small",
|
|
17
|
+
medium: "py-1.5 px-3 gap-2 button-default",
|
|
18
|
+
large: "py-2.5 px-3 gap-3 button-default",
|
|
19
|
+
},
|
|
20
|
+
variant: {
|
|
21
|
+
filled: "border-transparent border-1",
|
|
22
|
+
outlined: "border-1",
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
compoundVariants: [
|
|
26
|
+
{
|
|
27
|
+
color: "primary",
|
|
28
|
+
variant: "filled",
|
|
29
|
+
class:
|
|
30
|
+
"bg-blue-500 text-white hover:bg-blue-600 dark:bg-blue-400 dark:hover:bg-blue-500",
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
color: "primary",
|
|
34
|
+
variant: "outlined",
|
|
35
|
+
class:
|
|
36
|
+
"text-blue-500 border-blue-500 hover:bg-blue-600 hover:border-blue-600 hover:text-white dark:text-blue-400 dark:border-blue-400 dark:hover:bg-blue-500 dark:hover:border-blue-500",
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
color: "secondary",
|
|
40
|
+
variant: "filled",
|
|
41
|
+
class:
|
|
42
|
+
"bg-neutral-900 text-white hover:bg-neutral-700 dark:bg-neutral-200 dark:text-neutral-900 dark:hover:bg-neutral-500",
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
color: "secondary",
|
|
46
|
+
variant: "outlined",
|
|
47
|
+
class:
|
|
48
|
+
"text-neutral-900 hover:bg-neutral-700 hover:text-white hover:border-neutral-700 dark:border-white dark:text-white dark:hover:bg-neutral-500 dark:hover:border-neutral-500 dark:hover:text-inherit",
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
color: "tertiary",
|
|
52
|
+
class:
|
|
53
|
+
"relative !px-0 after:content-[''] after:absolute after:left-0 after:bottom-0 after:h-[1.5px] after:w-0 after:bg-blue-500 hover:after:w-full after:transition-all after:duration-300 dark:text-white dark:after:bg-blue-400",
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
color: "success",
|
|
57
|
+
variant: "filled",
|
|
58
|
+
class:
|
|
59
|
+
"bg-green-500 text-white hover:bg-green-700 dark:bg-green-500 dark:hover:bg-green-700",
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
color: "success",
|
|
63
|
+
variant: "outlined",
|
|
64
|
+
class:
|
|
65
|
+
"text-green-500 border-green-500 hover:bg-green-700 hover:border-green-700 hover:text-white dark:text-green-500 dark:border-green-500 dark:hover:bg-green-700 dark:hover:border-green-700",
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
color: "danger",
|
|
69
|
+
variant: "filled",
|
|
70
|
+
class:
|
|
71
|
+
"bg-red-500 text-white hover:bg-red-700 dark:bg-red-500 dark:hover:bg-red-700",
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
color: "danger",
|
|
75
|
+
variant: "outlined",
|
|
76
|
+
class:
|
|
77
|
+
"text-red-500 border-red-500 hover:bg-red-700 hover:border-red-700 hover:text-white dark:text-red-500 dark:border-red-500 dark:hover:bg-red-700 dark:hover:border-red-700",
|
|
78
|
+
},
|
|
79
|
+
],
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
export { buttonVariants };
|