@immich/ui 0.3.0 → 0.4.0
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/dist/common/use-context.svelte.d.ts +5 -0
- package/dist/common/use-context.svelte.js +19 -0
- package/dist/components/Alert/Alert.svelte +50 -0
- package/dist/components/Alert/Alert.svelte.d.ts +9 -0
- package/dist/components/Button/Button.svelte +8 -0
- package/dist/components/Button/Button.svelte.d.ts +4 -0
- package/dist/components/Card/Card.svelte +187 -0
- package/dist/components/Card/Card.svelte.d.ts +11 -0
- package/dist/components/Card/CardBody.svelte +20 -0
- package/dist/components/Card/CardBody.svelte.d.ts +6 -0
- package/dist/components/Card/CardDescription.svelte +16 -0
- package/dist/components/Card/CardDescription.svelte.d.ts +6 -0
- package/dist/components/Card/CardFooter.svelte +15 -0
- package/dist/components/Card/CardFooter.svelte.d.ts +5 -0
- package/dist/components/Card/CardHeader.svelte +15 -0
- package/dist/components/Card/CardHeader.svelte.d.ts +5 -0
- package/dist/components/Card/CardTitle.svelte +17 -0
- package/dist/components/Card/CardTitle.svelte.d.ts +8 -0
- package/dist/components/{Checkbox.svelte → Form/Checkbox.svelte} +20 -30
- package/dist/components/{Checkbox.svelte.d.ts → Form/Checkbox.svelte.d.ts} +1 -1
- package/dist/components/{Input.svelte → Form/Input.svelte} +1 -1
- package/dist/components/{Label.svelte → Form/Label.svelte} +1 -1
- package/dist/components/Heading/Heading.svelte +53 -0
- package/dist/components/Heading/Heading.svelte.d.ts +9 -0
- package/dist/components/Icon/Icon.svelte +52 -0
- package/dist/components/Icon/Icon.svelte.d.ts +4 -0
- package/dist/components/IconButton/IconButton.svelte +11 -0
- package/dist/components/IconButton/IconButton.svelte.d.ts +3 -0
- package/dist/components/{Logo.svelte → Logo/Logo.svelte} +11 -10
- package/dist/components/{Logo.svelte.d.ts → Logo/Logo.svelte.d.ts} +1 -1
- package/dist/components/Stack/HStack.svelte +10 -0
- package/dist/components/Stack/HStack.svelte.d.ts +8 -0
- package/dist/components/Stack/Stack.svelte +68 -0
- package/dist/components/Stack/Stack.svelte.d.ts +3 -0
- package/dist/components/Stack/VStack.svelte +10 -0
- package/dist/components/Stack/VStack.svelte.d.ts +8 -0
- package/dist/components/Text/Text.svelte +49 -0
- package/dist/components/Text/Text.svelte.d.ts +11 -0
- package/dist/constants.d.ts +6 -0
- package/dist/constants.js +7 -0
- package/dist/index.d.ts +19 -1
- package/dist/index.js +19 -1
- package/dist/{components → internal}/Button.svelte +79 -71
- package/dist/internal/Button.svelte.d.ts +6 -0
- package/dist/internal/Child.svelte +21 -0
- package/dist/internal/Child.svelte.d.ts +8 -0
- package/dist/types.d.ts +48 -0
- package/dist/utils.d.ts +2 -0
- package/dist/utils.js +1 -0
- package/package.json +2 -1
- package/dist/components/Button.svelte.d.ts +0 -15
- package/dist/components/Card.svelte +0 -20
- package/dist/components/Card.svelte.d.ts +0 -4
- package/dist/components/CardBody.svelte +0 -16
- package/dist/components/CardBody.svelte.d.ts +0 -4
- package/dist/components/CardDescription.svelte +0 -16
- package/dist/components/CardDescription.svelte.d.ts +0 -4
- package/dist/components/CardFooter.svelte +0 -16
- package/dist/components/CardFooter.svelte.d.ts +0 -4
- package/dist/components/CardHeader.svelte +0 -17
- package/dist/components/CardHeader.svelte.d.ts +0 -4
- package/dist/components/CardTitle.svelte +0 -25
- package/dist/components/CardTitle.svelte.d.ts +0 -7
- package/dist/components/Icon.svelte +0 -62
- package/dist/components/Icon.svelte.d.ts +0 -20
- package/dist/components/index.d.ts +0 -12
- package/dist/components/index.js +0 -12
- /package/dist/components/{Input.svelte.d.ts → Form/Input.svelte.d.ts} +0 -0
- /package/dist/components/{Label.svelte.d.ts → Form/Label.svelte.d.ts} +0 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ContextKey } from '../constants.js';
|
|
2
|
+
import { withPrefix } from '../utils.js';
|
|
3
|
+
import { setContext } from 'svelte';
|
|
4
|
+
import { SvelteMap } from 'svelte/reactivity';
|
|
5
|
+
export const withChildrenSnippets = (key) => {
|
|
6
|
+
const map = $state(new SvelteMap());
|
|
7
|
+
setContext(withPrefix(key), {
|
|
8
|
+
register: async (child, snippet) => {
|
|
9
|
+
if (map.has(child)) {
|
|
10
|
+
console.warn(`Snippet with key ${child} already exists in the context`);
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
map.set(child, snippet);
|
|
14
|
+
},
|
|
15
|
+
});
|
|
16
|
+
return {
|
|
17
|
+
getChildren: (key) => map.get(key),
|
|
18
|
+
};
|
|
19
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import Card from '../Card/Card.svelte';
|
|
3
|
+
import CardHeader from '../Card/CardHeader.svelte';
|
|
4
|
+
import Icon from '../Icon/Icon.svelte';
|
|
5
|
+
import Text from '../Text/Text.svelte';
|
|
6
|
+
import type { Color } from '../../types.js';
|
|
7
|
+
import {
|
|
8
|
+
mdiAlertOutline,
|
|
9
|
+
mdiCheckCircleOutline,
|
|
10
|
+
mdiCloseCircleOutline,
|
|
11
|
+
mdiInformationOutline,
|
|
12
|
+
} from '@mdi/js';
|
|
13
|
+
import type { Snippet } from 'svelte';
|
|
14
|
+
|
|
15
|
+
type Props = {
|
|
16
|
+
color?: Color;
|
|
17
|
+
icon?: string;
|
|
18
|
+
title: string;
|
|
19
|
+
children?: Snippet;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const { color = 'info', icon: iconOverride, title, children }: Props = $props();
|
|
23
|
+
|
|
24
|
+
const icons: Partial<Record<Color, string>> = {
|
|
25
|
+
success: mdiCheckCircleOutline,
|
|
26
|
+
warning: mdiAlertOutline,
|
|
27
|
+
danger: mdiCloseCircleOutline,
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const icon = $derived(iconOverride || (icons[color] ?? mdiInformationOutline));
|
|
31
|
+
</script>
|
|
32
|
+
|
|
33
|
+
<Card {color} variant="subtle">
|
|
34
|
+
<CardHeader>
|
|
35
|
+
<div class="flex gap-2">
|
|
36
|
+
{#if icon}
|
|
37
|
+
<div>
|
|
38
|
+
<Icon {icon} size="1.5em" class="h-7" />
|
|
39
|
+
</div>
|
|
40
|
+
{/if}
|
|
41
|
+
|
|
42
|
+
<div class="flex flex-col gap-2">
|
|
43
|
+
<Text size="large" fontWeight={children ? 'bold' : undefined}>{title}</Text>
|
|
44
|
+
{#if children}
|
|
45
|
+
{@render children()}
|
|
46
|
+
{/if}
|
|
47
|
+
</div>
|
|
48
|
+
</div>
|
|
49
|
+
</CardHeader>
|
|
50
|
+
</Card>
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { withChildrenSnippets } from '../../common/use-context.svelte.js';
|
|
3
|
+
import IconButton from '../IconButton/IconButton.svelte';
|
|
4
|
+
import { ContextKey } from '../../constants.js';
|
|
5
|
+
import type { Color, Shape } from '../../types.js';
|
|
6
|
+
import { cleanClass } from '../../utils.js';
|
|
7
|
+
import { mdiChevronDown } from '@mdi/js';
|
|
8
|
+
import { type Snippet } from 'svelte';
|
|
9
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
10
|
+
import { tv } from 'tailwind-variants';
|
|
11
|
+
|
|
12
|
+
type Props = HTMLAttributes<HTMLDivElement> & {
|
|
13
|
+
color?: Color;
|
|
14
|
+
shape?: Shape;
|
|
15
|
+
variant?: 'filled' | 'outline' | 'subtle';
|
|
16
|
+
expandable?: boolean;
|
|
17
|
+
children: Snippet;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
let {
|
|
21
|
+
color = 'secondary',
|
|
22
|
+
class: className,
|
|
23
|
+
expandable = false,
|
|
24
|
+
variant,
|
|
25
|
+
children,
|
|
26
|
+
...restProps
|
|
27
|
+
}: Props = $props();
|
|
28
|
+
|
|
29
|
+
const cardStyles = tv({
|
|
30
|
+
base: 'rounded-2xl bg-light text-dark shadow-sm dark:border-gray-600 w-full overflow-hidden',
|
|
31
|
+
variants: {
|
|
32
|
+
defaultStyle: {
|
|
33
|
+
true: 'border border-gray-300 dark:border-gray-600',
|
|
34
|
+
false: '',
|
|
35
|
+
default: '',
|
|
36
|
+
},
|
|
37
|
+
outlineColor: {
|
|
38
|
+
primary: 'border border-primary',
|
|
39
|
+
secondary: 'border border-gray-300 dark:border-gray-600',
|
|
40
|
+
success: 'border border-success',
|
|
41
|
+
danger: 'border border-danger',
|
|
42
|
+
warning: 'border border-warning',
|
|
43
|
+
info: 'border border-info',
|
|
44
|
+
},
|
|
45
|
+
subtleColor: {
|
|
46
|
+
primary: 'bg-primary/50 dark:bg-primary/25',
|
|
47
|
+
secondary: 'bg-dark/15 text-dark',
|
|
48
|
+
success: 'bg-success/25 dark:bg-success/50',
|
|
49
|
+
danger: 'bg-danger/25 dark:bg-danger/50',
|
|
50
|
+
warning: 'bg-warning/25 dark:bg-warning/50',
|
|
51
|
+
info: 'bg-info/25',
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
const headerContainerStyles = tv({
|
|
57
|
+
variants: {
|
|
58
|
+
bottomPadding: {
|
|
59
|
+
true: '',
|
|
60
|
+
false: 'pb-0',
|
|
61
|
+
},
|
|
62
|
+
filledColor: {
|
|
63
|
+
primary: 'bg-primary text-light rounded-t-xl',
|
|
64
|
+
secondary: 'bg-dark text-light rounded-t-xl',
|
|
65
|
+
success: 'bg-success text-light rounded-t-xl',
|
|
66
|
+
danger: 'bg-danger text-light rounded-t-xl',
|
|
67
|
+
warning: 'bg-warning text-black rounded-t-xl',
|
|
68
|
+
info: 'bg-info text-light rounded-t-xl',
|
|
69
|
+
},
|
|
70
|
+
outlineColor: {
|
|
71
|
+
primary: 'text-primary',
|
|
72
|
+
secondary: 'text-dark',
|
|
73
|
+
success: 'text-success',
|
|
74
|
+
danger: 'text-danger',
|
|
75
|
+
warning: 'text-warning',
|
|
76
|
+
info: 'text-info',
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
const iconStyles = tv({
|
|
82
|
+
variants: {
|
|
83
|
+
filledColor: {
|
|
84
|
+
primary: 'text-light',
|
|
85
|
+
secondary: 'text-light',
|
|
86
|
+
success: 'text-light',
|
|
87
|
+
danger: 'text-light',
|
|
88
|
+
warning: 'text-dark',
|
|
89
|
+
info: 'text-light',
|
|
90
|
+
},
|
|
91
|
+
outlineColor: {
|
|
92
|
+
primary: 'text-primary',
|
|
93
|
+
secondary: 'text-dark',
|
|
94
|
+
success: 'text-success',
|
|
95
|
+
danger: 'text-danger',
|
|
96
|
+
warning: 'text-warning',
|
|
97
|
+
info: 'text-info',
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
let expanded = $state(!expandable);
|
|
103
|
+
const onToggle = () => {
|
|
104
|
+
expanded = !expanded;
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
const { getChildren: getChildSnippet } = withChildrenSnippets(ContextKey.Card);
|
|
108
|
+
const headerChildren = $derived(getChildSnippet(ContextKey.CardHeader));
|
|
109
|
+
const bodyChildren = $derived(getChildSnippet(ContextKey.CardBody));
|
|
110
|
+
const footerChildren = $derived(getChildSnippet(ContextKey.CardFooter));
|
|
111
|
+
|
|
112
|
+
const headerClasses = 'flex flex-col space-y-1.5';
|
|
113
|
+
const headerContainerClasses = $derived(
|
|
114
|
+
cleanClass(
|
|
115
|
+
headerContainerStyles({
|
|
116
|
+
bottomPadding: variant === 'filled' || !bodyChildren,
|
|
117
|
+
outlineColor: variant === 'outline' ? color : undefined,
|
|
118
|
+
filledColor: variant === 'filled' ? color : undefined,
|
|
119
|
+
}),
|
|
120
|
+
),
|
|
121
|
+
);
|
|
122
|
+
</script>
|
|
123
|
+
|
|
124
|
+
{#snippet header()}
|
|
125
|
+
{#if expandable}
|
|
126
|
+
<button type="button" onclick={onToggle} class="w-full">
|
|
127
|
+
<div class={cleanClass(headerContainerClasses, 'flex items-center justify-between px-4')}>
|
|
128
|
+
<div class={cleanClass(headerClasses, 'py-4')}>
|
|
129
|
+
{@render headerChildren?.()}
|
|
130
|
+
</div>
|
|
131
|
+
<div>
|
|
132
|
+
<IconButton
|
|
133
|
+
class={iconStyles({
|
|
134
|
+
filledColor: variant === 'filled' ? color : undefined,
|
|
135
|
+
outlineColor: variant === 'outline' ? color : undefined,
|
|
136
|
+
}) as Color}
|
|
137
|
+
icon={mdiChevronDown}
|
|
138
|
+
flopped={expanded}
|
|
139
|
+
variant="ghost"
|
|
140
|
+
shape="round"
|
|
141
|
+
size="large"
|
|
142
|
+
/>
|
|
143
|
+
</div>
|
|
144
|
+
</div>
|
|
145
|
+
</button>
|
|
146
|
+
{:else}
|
|
147
|
+
<div class={cleanClass(headerClasses, headerContainerClasses, 'p-4')}>
|
|
148
|
+
{@render headerChildren?.()}
|
|
149
|
+
</div>
|
|
150
|
+
{/if}
|
|
151
|
+
{/snippet}
|
|
152
|
+
|
|
153
|
+
{#snippet body()}
|
|
154
|
+
{@render bodyChildren?.()}
|
|
155
|
+
{/snippet}
|
|
156
|
+
|
|
157
|
+
{#snippet footer()}
|
|
158
|
+
<div class="flex items-center p-4 pt-0">
|
|
159
|
+
{@render footerChildren?.()}
|
|
160
|
+
</div>
|
|
161
|
+
{/snippet}
|
|
162
|
+
|
|
163
|
+
<div
|
|
164
|
+
class={cleanClass(
|
|
165
|
+
cardStyles({
|
|
166
|
+
defaultStyle: variant === undefined,
|
|
167
|
+
outlineColor: variant === 'outline' || variant === 'filled' ? color : undefined,
|
|
168
|
+
subtleColor: variant === 'subtle' ? color : undefined,
|
|
169
|
+
}),
|
|
170
|
+
className,
|
|
171
|
+
)}
|
|
172
|
+
{...restProps}
|
|
173
|
+
>
|
|
174
|
+
{#if headerChildren}
|
|
175
|
+
{@render header()}
|
|
176
|
+
{/if}
|
|
177
|
+
|
|
178
|
+
{#if bodyChildren && expanded}
|
|
179
|
+
{@render body()}
|
|
180
|
+
{/if}
|
|
181
|
+
|
|
182
|
+
{#if footerChildren}
|
|
183
|
+
{@render footer()}
|
|
184
|
+
{/if}
|
|
185
|
+
|
|
186
|
+
{@render children()}
|
|
187
|
+
</div>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Color, Shape } from '../../types.js';
|
|
2
|
+
import { type Snippet } from 'svelte';
|
|
3
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
4
|
+
declare const Card: import("svelte").Component<HTMLAttributes<HTMLDivElement> & {
|
|
5
|
+
color?: Color;
|
|
6
|
+
shape?: Shape;
|
|
7
|
+
variant?: "filled" | "outline" | "subtle";
|
|
8
|
+
expandable?: boolean;
|
|
9
|
+
children: Snippet;
|
|
10
|
+
}, {}, "">;
|
|
11
|
+
export default Card;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { ContextKey } from '../../constants.js';
|
|
3
|
+
import Child from '../../internal/Child.svelte';
|
|
4
|
+
import { cleanClass } from '../../utils.js';
|
|
5
|
+
import type { Snippet } from 'svelte';
|
|
6
|
+
import { twMerge } from 'tailwind-merge';
|
|
7
|
+
|
|
8
|
+
type Props = {
|
|
9
|
+
class?: string;
|
|
10
|
+
children: Snippet;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
let { class: className, children }: Props = $props();
|
|
14
|
+
</script>
|
|
15
|
+
|
|
16
|
+
<Child for={ContextKey.Card} as={ContextKey.CardBody}>
|
|
17
|
+
<div class={twMerge(cleanClass('p-4', className))}>
|
|
18
|
+
{@render children?.()}
|
|
19
|
+
</div>
|
|
20
|
+
</Child>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import Text from '../Text/Text.svelte';
|
|
3
|
+
import { cleanClass } from '../../utils.js';
|
|
4
|
+
import type { Snippet } from 'svelte';
|
|
5
|
+
|
|
6
|
+
type Props = {
|
|
7
|
+
class?: string;
|
|
8
|
+
children: Snippet;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
let { children, class: className }: Props = $props();
|
|
12
|
+
</script>
|
|
13
|
+
|
|
14
|
+
<Text size="small" class={cleanClass('text-dark/75', className)}>
|
|
15
|
+
{@render children?.()}
|
|
16
|
+
</Text>
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { ContextKey } from '../../constants.js';
|
|
3
|
+
import Child from '../../internal/Child.svelte';
|
|
4
|
+
import type { Snippet } from 'svelte';
|
|
5
|
+
|
|
6
|
+
type Props = {
|
|
7
|
+
children: Snippet;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
let { children }: Props = $props();
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<Child for={ContextKey.Card} as={ContextKey.CardFooter}>
|
|
14
|
+
{@render children?.()}
|
|
15
|
+
</Child>
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { ContextKey } from '../../constants.js';
|
|
3
|
+
import Child from '../../internal/Child.svelte';
|
|
4
|
+
import type { Snippet } from 'svelte';
|
|
5
|
+
|
|
6
|
+
type Props = {
|
|
7
|
+
children: Snippet;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
let { children }: Props = $props();
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<Child for={ContextKey.Card} as={ContextKey.CardHeader}>
|
|
14
|
+
{@render children?.()}
|
|
15
|
+
</Child>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import Heading from '../Heading/Heading.svelte';
|
|
3
|
+
import type { HeadingSize } from '../../types.js';
|
|
4
|
+
import type { Snippet } from 'svelte';
|
|
5
|
+
|
|
6
|
+
type Props = {
|
|
7
|
+
class?: string;
|
|
8
|
+
size?: HeadingSize;
|
|
9
|
+
children: Snippet;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const { size = 'small', class: className, children }: Props = $props();
|
|
13
|
+
</script>
|
|
14
|
+
|
|
15
|
+
<Heading {size} class={className}>
|
|
16
|
+
{@render children?.()}
|
|
17
|
+
</Heading>
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { Checkbox as CheckboxPrimitive, type WithoutChildrenOrChild } from 'bits-ui';
|
|
3
3
|
import { mdiCheck, mdiMinus } from '@mdi/js';
|
|
4
|
-
import Icon from '
|
|
4
|
+
import Icon from '../Icon/Icon.svelte';
|
|
5
5
|
import { tv } from 'tailwind-variants';
|
|
6
|
-
import type { Color, Shape, Size } from '
|
|
7
|
-
import { cleanClass } from '
|
|
6
|
+
import type { Color, Shape, Size } from '../../types.js';
|
|
7
|
+
import { cleanClass } from '../../utils.js';
|
|
8
8
|
|
|
9
9
|
type CheckboxProps = WithoutChildrenOrChild<CheckboxPrimitive.RootProps> & {
|
|
10
10
|
color?: Color;
|
|
@@ -40,30 +40,17 @@
|
|
|
40
40
|
},
|
|
41
41
|
size: {
|
|
42
42
|
tiny: 'size-4',
|
|
43
|
-
small: 'size-
|
|
44
|
-
medium: 'size-
|
|
45
|
-
large: 'size-
|
|
46
|
-
giant: 'size-
|
|
43
|
+
small: 'size-5',
|
|
44
|
+
medium: 'size-6',
|
|
45
|
+
large: 'size-8',
|
|
46
|
+
giant: 'size-10',
|
|
47
47
|
},
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
{ size: 'giant', shape: 'semi-round', class: 'rounded-2xl' },
|
|
55
|
-
],
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
const parent = tv({
|
|
59
|
-
base: 'flex items-center justify-center text-current',
|
|
60
|
-
variants: {
|
|
61
|
-
size: {
|
|
62
|
-
tiny: 'size-4',
|
|
63
|
-
small: 'size-6',
|
|
64
|
-
medium: 'size-8',
|
|
65
|
-
large: 'size-16',
|
|
66
|
-
giant: 'size-32',
|
|
48
|
+
roundedSize: {
|
|
49
|
+
tiny: 'rounded-md',
|
|
50
|
+
small: 'rounded-md',
|
|
51
|
+
medium: 'rounded-md',
|
|
52
|
+
large: 'rounded-lg',
|
|
53
|
+
giant: 'rounded-xl',
|
|
67
54
|
},
|
|
68
55
|
},
|
|
69
56
|
});
|
|
@@ -87,16 +74,19 @@
|
|
|
87
74
|
|
|
88
75
|
<CheckboxPrimitive.Root
|
|
89
76
|
bind:ref
|
|
90
|
-
class={cleanClass(
|
|
77
|
+
class={cleanClass(
|
|
78
|
+
container({ size, color, shape, roundedSize: shape === 'semi-round' ? size : undefined }),
|
|
79
|
+
className,
|
|
80
|
+
)}
|
|
91
81
|
bind:checked
|
|
92
82
|
{...restProps}
|
|
93
83
|
>
|
|
94
84
|
{#snippet children({ checked })}
|
|
95
|
-
<div class={
|
|
85
|
+
<div class={cleanClass('flex items-center justify-center text-current')}>
|
|
96
86
|
{#if checked === true}
|
|
97
|
-
<Icon
|
|
87
|
+
<Icon icon={mdiCheck} size="100%" class={cleanClass(icon({ color }))} />
|
|
98
88
|
{:else if checked === 'indeterminate'}
|
|
99
|
-
<Icon
|
|
89
|
+
<Icon icon={mdiMinus} size="100%" class={cleanClass(icon({ color }))} />
|
|
100
90
|
{/if}
|
|
101
91
|
</div>
|
|
102
92
|
{/snippet}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Checkbox as CheckboxPrimitive } from 'bits-ui';
|
|
2
|
-
import type { Color, Shape, Size } from '
|
|
2
|
+
import type { Color, Shape, Size } from '../../types.js';
|
|
3
3
|
declare const Checkbox: import("svelte").Component<Omit<Omit<CheckboxPrimitive.RootProps, "child">, "children"> & {
|
|
4
4
|
color?: Color;
|
|
5
5
|
shape?: Shape;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Color, HeadingSize } from '../../types.js';
|
|
3
|
+
import { cleanClass } from '../../utils.js';
|
|
4
|
+
import type { Snippet } from 'svelte';
|
|
5
|
+
import { tv } from 'tailwind-variants';
|
|
6
|
+
|
|
7
|
+
type Props = {
|
|
8
|
+
size: HeadingSize;
|
|
9
|
+
color?: Color;
|
|
10
|
+
class?: string;
|
|
11
|
+
children: Snippet;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const { color, size, class: className, children }: Props = $props();
|
|
15
|
+
|
|
16
|
+
const sizes = {
|
|
17
|
+
title: 'h1',
|
|
18
|
+
giant: 'h2',
|
|
19
|
+
large: 'h3',
|
|
20
|
+
medium: 'h4',
|
|
21
|
+
small: 'h5',
|
|
22
|
+
tiny: 'h6',
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const styles = tv({
|
|
26
|
+
base: 'leading-none tracking-tight',
|
|
27
|
+
variants: {
|
|
28
|
+
color: {
|
|
29
|
+
primary: 'text-primary',
|
|
30
|
+
secondary: 'text-dark',
|
|
31
|
+
success: 'text-success',
|
|
32
|
+
danger: 'text-danger',
|
|
33
|
+
warning: 'text-warning',
|
|
34
|
+
info: 'text-info',
|
|
35
|
+
},
|
|
36
|
+
size: {
|
|
37
|
+
tiny: 'text-lg font-bold',
|
|
38
|
+
small: 'text-xl font-bold',
|
|
39
|
+
medium: 'text-2xl font-bold',
|
|
40
|
+
large: 'text-3xl font-bold',
|
|
41
|
+
giant: 'text-4xl font-bold',
|
|
42
|
+
title: 'text-5xl font-bold',
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
const tag = $derived(sizes[size] ?? 'h6');
|
|
48
|
+
const classList = $derived(cleanClass(styles({ color, size }), className));
|
|
49
|
+
</script>
|
|
50
|
+
|
|
51
|
+
<svelte:element this={tag} class={classList} role="heading">
|
|
52
|
+
{@render children()}
|
|
53
|
+
</svelte:element>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Color, HeadingSize } from '../../types.js';
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
declare const Heading: import("svelte").Component<{
|
|
4
|
+
size: HeadingSize;
|
|
5
|
+
color?: Color;
|
|
6
|
+
class?: string;
|
|
7
|
+
children: Snippet;
|
|
8
|
+
}, {}, "">;
|
|
9
|
+
export default Heading;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { IconProps } from '../../types.js';
|
|
3
|
+
import { cleanClass } from '../../utils.js';
|
|
4
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
5
|
+
|
|
6
|
+
const {
|
|
7
|
+
size = '1em',
|
|
8
|
+
viewBox = '0 0 24 24',
|
|
9
|
+
class: className = '',
|
|
10
|
+
flipped = false,
|
|
11
|
+
flopped = false,
|
|
12
|
+
spin = false,
|
|
13
|
+
strokeColor = 'transparent',
|
|
14
|
+
strokeWidth = 2,
|
|
15
|
+
role = 'img',
|
|
16
|
+
title,
|
|
17
|
+
icon,
|
|
18
|
+
color = 'currentColor',
|
|
19
|
+
description,
|
|
20
|
+
...restProps
|
|
21
|
+
}: IconProps & HTMLAttributes<EventTarget> = $props();
|
|
22
|
+
</script>
|
|
23
|
+
|
|
24
|
+
<svg
|
|
25
|
+
width={size}
|
|
26
|
+
height={size}
|
|
27
|
+
{viewBox}
|
|
28
|
+
class={cleanClass(
|
|
29
|
+
className,
|
|
30
|
+
flipped && '-scale-x-100',
|
|
31
|
+
flopped && 'rotate-180',
|
|
32
|
+
spin && 'animate-spin',
|
|
33
|
+
)}
|
|
34
|
+
stroke={strokeColor}
|
|
35
|
+
stroke-width={strokeWidth}
|
|
36
|
+
{role}
|
|
37
|
+
{...restProps}
|
|
38
|
+
>
|
|
39
|
+
{#if title}
|
|
40
|
+
<title>{title}</title>
|
|
41
|
+
{/if}
|
|
42
|
+
{#if description}
|
|
43
|
+
<desc>{description}</desc>
|
|
44
|
+
{/if}
|
|
45
|
+
<path d={icon} fill={color} />
|
|
46
|
+
</svg>
|
|
47
|
+
|
|
48
|
+
<style>
|
|
49
|
+
svg {
|
|
50
|
+
transition: transform 0.2s ease;
|
|
51
|
+
}
|
|
52
|
+
</style>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import Button from '../../internal/Button.svelte';
|
|
3
|
+
import Icon from '../Icon/Icon.svelte';
|
|
4
|
+
import type { IconButtonProps } from '../../types.js';
|
|
5
|
+
|
|
6
|
+
const { icon, flipped, flopped, ...buttonProps }: IconButtonProps = $props();
|
|
7
|
+
</script>
|
|
8
|
+
|
|
9
|
+
<Button icon {...buttonProps}>
|
|
10
|
+
<Icon {icon} {flipped} {flopped} size="66%"></Icon>
|
|
11
|
+
</Button>
|