lapikit 0.1.0 → 0.1.2

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.
@@ -0,0 +1,29 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"
2
+ ><defs
3
+ ><linearGradient id="a" x1="50%" x2="50%" y1="5.271%" y2="91.793%"
4
+ ><stop offset="0%" stop-color="currentColor" /><stop
5
+ offset="100%"
6
+ stop-color="currentColor"
7
+ stop-opacity=".55"
8
+ /></linearGradient
9
+ ><linearGradient id="b" x1="50%" x2="50%" y1="15.24%" y2="87.15%"
10
+ ><stop offset="0%" stop-color="currentColor" stop-opacity="0" /><stop
11
+ offset="100%"
12
+ stop-color="currentColor"
13
+ stop-opacity=".55"
14
+ /></linearGradient
15
+ ></defs
16
+ ><g fill="none"
17
+ ><path
18
+ d="M24 0v24H0V0zM12.593 23.258l-.011.002-.071.035-.02.004-.014-.004-.071-.035c-.01-.004-.019-.001-.024.005l-.004.01-.017.428.005.02.01.013.104.074.015.004.012-.004.104-.074.012-.016.004-.017-.017-.427c-.002-.01-.009-.017-.017-.018m.265-.113-.013.002-.185.093-.01.01-.003.011.018.43.005.012.008.007.201.093c.012.004.023 0 .029-.008l.004-.014-.034-.614c-.003-.012-.01-.02-.02-.022m-.715.002a.023.023 0 0 0-.027.006l-.006.014-.034.614c0 .012.007.02.017.024l.015-.002.201-.093.01-.008.004-.011.017-.43-.003-.012-.01-.01z"
19
+ /><path
20
+ fill="url(#a)"
21
+ d="M8.749.021a1.5 1.5 0 0 1 .497 2.958A7.502 7.502 0 0 0 3 10.375a7.5 7.5 0 0 0 7.5 7.5v3c-5.799 0-10.5-4.7-10.5-10.5C0 5.23 3.726.865 8.749.021"
22
+ transform="translate(1.5 1.625)"
23
+ /><path
24
+ fill="url(#b)"
25
+ d="M15.392 2.673a1.5 1.5 0 0 1 2.119-.115A10.475 10.475 0 0 1 21 10.375c0 5.8-4.701 10.5-10.5 10.5v-3a7.5 7.5 0 0 0 5.007-13.084 1.5 1.5 0 0 1-.115-2.118"
26
+ transform="translate(1.5 1.625)"
27
+ /></g
28
+ ></svg
29
+ >
@@ -0,0 +1,26 @@
1
+ export default LoadingFill;
2
+ type LoadingFill = SvelteComponent<{
3
+ [x: string]: never;
4
+ }, {
5
+ [evt: string]: CustomEvent<any>;
6
+ }, {}> & {
7
+ $$bindings?: string | undefined;
8
+ };
9
+ declare const LoadingFill: $$__sveltets_2_IsomorphicComponent<{
10
+ [x: string]: never;
11
+ }, {
12
+ [evt: string]: CustomEvent<any>;
13
+ }, {}, {}, string>;
14
+ interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
15
+ new (options: import("svelte").ComponentConstructorOptions<Props>): import("svelte").SvelteComponent<Props, Events, Slots> & {
16
+ $$bindings?: Bindings;
17
+ } & Exports;
18
+ (internal: unknown, props: {
19
+ $$events?: Events;
20
+ $$slots?: Slots;
21
+ }): Exports & {
22
+ $set?: any;
23
+ $on?: any;
24
+ };
25
+ z_$$bindings?: Bindings;
26
+ }
@@ -0,0 +1,14 @@
1
+ <script lang="ts">
2
+ import { BROWSER } from 'esm-env';
3
+ import { updateThemeStore } from '../../stores/index.js';
4
+ import type { Snippet } from 'svelte';
5
+ let { children }: { children: Snippet } = $props();
6
+
7
+ $effect.pre(() => {
8
+ if (!BROWSER) return;
9
+ const local = localStorage.getItem('@lapikit/theme');
10
+ if (local !== null) updateThemeStore(local as 'dark' | 'light' | 'auto');
11
+ });
12
+ </script>
13
+
14
+ {@render children?.()}
@@ -0,0 +1,7 @@
1
+ import type { Snippet } from 'svelte';
2
+ type $$ComponentProps = {
3
+ children: Snippet;
4
+ };
5
+ declare const App: import("svelte").Component<$$ComponentProps, {}, "">;
6
+ type App = ReturnType<typeof App>;
7
+ export default App;
@@ -0,0 +1,4 @@
1
+ import type { Snippet } from 'svelte';
2
+ export interface AppProps {
3
+ children?: Snippet;
4
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,276 @@
1
+ .kit-btn {
2
+ --btn-color: var(--on, var(--kit-on-neutral));
3
+ --btn-background: var(--base, var(--kit-neutral));
4
+ --btn-radius: var(--shape, var(--kit-radius-md));
5
+
6
+ display: inline-flex;
7
+ align-items: center;
8
+ justify-content: center;
9
+ white-space: nowrap;
10
+ padding-top: var(--btn-spacing-x);
11
+ padding-bottom: var(--btn-spacing-x);
12
+ padding-right: var(--btn-spacing-y);
13
+ padding-left: var(--btn-spacing-y);
14
+ cursor: pointer;
15
+
16
+ border-width: 1px;
17
+ border-style: solid;
18
+ border-radius: var(--btn-radius);
19
+
20
+ /* theme */
21
+ color: var(--btn-color);
22
+ background-color: var(--btn-background);
23
+ border-color: var(--btn-background);
24
+ }
25
+
26
+ .kit-btn .kit-btn-content,
27
+ .kit-btn .kit-btn-loading {
28
+ display: inline-flex;
29
+ align-items: center;
30
+ justify-content: center;
31
+ white-space: nowrap;
32
+ gap: var(--btn-gap);
33
+ }
34
+
35
+ .kit-btn:active:hover,
36
+ .kit-btn:active:focus {
37
+ animation: button-click 0s ease-out;
38
+ transform: scale(0.97);
39
+ }
40
+
41
+ /* size */
42
+ .kit-btn[breakpoint]kit-btn--size-xs {
43
+ --btn-height: 1.75rem;
44
+ --btn-multiplier-y: 2;
45
+ --btn-gap: 0.25rem;
46
+ font-size: 0.75rem;
47
+ gap: var(--btn-gap);
48
+ }
49
+
50
+ .kit-btn[breakpoint]kit-btn--size-sm {
51
+ --btn-height: 2rem;
52
+ --btn-multiplier-y: 3;
53
+ --btn-gap: 0.5rem;
54
+ font-size: 0.875rem;
55
+ gap: var(--btn-gap);
56
+ }
57
+
58
+ .kit-btn[breakpoint]kit-btn--size-md {
59
+ --btn-height: 2.25rem;
60
+ --btn-multiplier-y: 4;
61
+ --btn-gap: 0.5rem;
62
+ font-size: 0.875rem;
63
+ gap: var(--btn-gap);
64
+ }
65
+
66
+ .kit-btn[breakpoint]kit-btn--size-lg {
67
+ --btn-height: 2.5rem;
68
+ --btn-multiplier-y: 5;
69
+ --btn-gap: 0.5rem;
70
+ font-size: 1rem;
71
+ gap: var(--btn-gap);
72
+ }
73
+
74
+ .kit-btn[breakpoint]kit-btn--size-xl {
75
+ --btn-height: 2.75rem;
76
+ --btn-multiplier-y: 6;
77
+ --btn-gap: 0.675rem;
78
+ font-size: 1.125rem;
79
+ gap: var(--btn-gap);
80
+ }
81
+
82
+ /* density */
83
+ .kit-btn:not(.kit-btn--icon)[breakpoint]kit-btn--density-default {
84
+ height: calc(var(--btn-height));
85
+ min-width: calc(var(--btn-height));
86
+ --btn-spacing-x: 0;
87
+ --btn-spacing-y: calc(var(--kit-spacing) * var(--btn-multiplier-y));
88
+ }
89
+ .kit-btn.kit-btn--icon[breakpoint]kit-btn--density-default {
90
+ height: calc(var(--btn-height));
91
+ width: calc(var(--btn-height));
92
+ --btn-spacing-x: 0;
93
+ --btn-spacing-y: 0;
94
+ }
95
+
96
+ .kit-btn:not(.kit-btn--icon)[breakpoint]kit-btn--density-compact {
97
+ height: calc(var(--btn-height) - 0.25rem);
98
+ min-width: calc(var(--btn-height - 0.25rem));
99
+ --btn-spacing-x: 0;
100
+ --btn-spacing-y: calc(var(--kit-spacing) * var(--btn-multiplier-y) - 0.25rem);
101
+ }
102
+ .kit-btn.kit-btn--icon[breakpoint]kit-btn--density-compact {
103
+ height: calc(var(--btn-height) - 0.25rem);
104
+ width: calc(var(--btn-height) - 0.25rem);
105
+ --btn-spacing-x: 0;
106
+ --btn-spacing-y: 0;
107
+ }
108
+
109
+ .kit-btn:not(.kit-btn--icon)[breakpoint]kit-btn--density-comfortable {
110
+ height: calc(var(--btn-height) + 0.25rem);
111
+ min-width: calc(var(--btn-height) + 0.25rem);
112
+ --btn-spacing-x: 0;
113
+ --btn-spacing-y: calc(var(--kit-spacing) * var(--btn-multiplier-y) + 0.25rem);
114
+ }
115
+ .kit-btn.kit-btn--icon[breakpoint]kit-btn--density-comfortable {
116
+ height: calc(var(--btn-height) + 0.25rem);
117
+ width: calc(var(--btn-height) + 0.25rem);
118
+ --btn-spacing-x: 0;
119
+ --btn-spacing-y: 0;
120
+ }
121
+
122
+ /* variant */
123
+ .kit-btn[breakpoint]kit-btn--variant-outline {
124
+ --btn-color: var(--base, var(--kit-neutral));
125
+ background-color: transparent;
126
+ border: 1px solid currentColor;
127
+ }
128
+
129
+ .kit-btn[breakpoint]kit-btn--variant-text {
130
+ --btn-color: var(--base, var(--kit-neutral));
131
+ background-color: transparent;
132
+ border-color: transparent;
133
+ }
134
+
135
+ .kit-btn[breakpoint]kit-btn--variant-dash {
136
+ --btn-color: var(--base, var(--kit-neutral));
137
+ background-color: transparent;
138
+ border: 1px dashed currentColor;
139
+ }
140
+
141
+ .kit-btn[breakpoint]kit-btn--variant-link {
142
+ --btn-color: var(--base, var(--kit-neutral));
143
+ background-color: transparent;
144
+ border-color: transparent;
145
+ }
146
+
147
+ /* state */
148
+ .kit-btn.kit-btn--info:not([class*='btn--variant-']) {
149
+ --on: var(--kit-on-info);
150
+ --base: var(--kit-info);
151
+ }
152
+ .kit-btn.kit-btn--info[class*='btn--variant-'] {
153
+ --base: var(--kit-info);
154
+ }
155
+
156
+ .kit-btn.kit-btn--success:not([class*='btn--variant-']) {
157
+ --on: var(--kit-on-success);
158
+ --base: var(--kit-success);
159
+ }
160
+ .kit-btn.kit-btn--success[class*='btn--variant-'] {
161
+ --base: var(--kit-success);
162
+ }
163
+
164
+ .kit-btn.kit-btn--warning:not([class*='btn--variant-']) {
165
+ --on: var(--kit-on-warning);
166
+ --base: var(--kit-warning);
167
+ }
168
+ .kit-btn.kit-btn--warning[class*='btn--variant-'] {
169
+ --base: var(--kit-warning);
170
+ }
171
+
172
+ .kit-btn.kit-btn--error:not([class*='btn--variant-']) {
173
+ --on: var(--kit-on-error);
174
+ --base: var(--kit-error);
175
+ }
176
+ .kit-btn.kit-btn--error[class*='btn--variant-'] {
177
+ --base: var(--kit-error);
178
+ }
179
+
180
+ /* types */
181
+ .kit-btn:where(.kit-btn:is(input[type='checkbox'])),
182
+ .kit-btn:where(.kit-btn:is(input[type='radio'])) {
183
+ width: auto;
184
+ -webkit-appearance: none;
185
+ -moz-appearance: none;
186
+ appearance: none;
187
+ vertical-align: inherit;
188
+ }
189
+ .kit-btn:is(input[type='checkbox']):after,
190
+ .kit-btn:is(input[type='radio']):after {
191
+ --btn-content: attr(aria-label);
192
+ content: var(--btn-content);
193
+ }
194
+
195
+ .kit-btn:is(input[type='checkbox']):focus,
196
+ .kit-btn:is(input[type='radio']):focus {
197
+ outline: none;
198
+ outline-offset: inherit;
199
+ box-shadow: none;
200
+ }
201
+
202
+ .kit-btn:is(input[type='checkbox']):checked,
203
+ .kit-btn:is(input[type='radio']):checked {
204
+ background-image: initial;
205
+ }
206
+
207
+ /* events */
208
+ .kit-btn.kit-btn--active:not([class*='btn--variant-']),
209
+ .kit-btn:not([class*='btn--variant-']):is(input[type='radio']):checked,
210
+ .kit-btn:not([class*='btn--variant-']):is(input[type='checkbox']):checked {
211
+ background-color: color-mix(in oklab, var(--btn-background) 90%, var(--kit-scrim));
212
+ border-color: color-mix(in oklab, var(--btn-background) 90%, var(--kit-scrim));
213
+ }
214
+ .kit-btn.kit-btn--active[class*='btn--variant-'],
215
+ .kit-btn[class*='btn--variant-']:is(input[type='radio']):checked,
216
+ .kit-btn[class*='btn--variant-']:is(input[type='checkbox']):checked {
217
+ background-color: color-mix(in oklab, currentColor 15%, transparent);
218
+ border-color: color-mix(in oklab, currentColor 15%, transparent);
219
+ }
220
+
221
+ .kit-btn:hover:not([class*='btn--variant-']),
222
+ .kit-btn:not([class*='btn--variant-']):is(input[type='radio']):hover,
223
+ .kit-btn:not([class*='btn--variant-']):is(input[type='checkbox']):hover {
224
+ background-color: color-mix(in oklab, var(--btn-background) 85%, var(--kit-scrim));
225
+ border-color: color-mix(in oklab, var(--btn-background) 85%, var(--kit-scrim));
226
+ }
227
+ .kit-btn:hover[class*='btn--variant-'],
228
+ .kit-btn[class*='btn--variant-']:is(input[type='radio']):hover,
229
+ .kit-btn[class*='btn--variant-']:is(input[type='checkbox']):hover {
230
+ background-color: color-mix(in oklab, currentColor 25%, transparent);
231
+ }
232
+
233
+ /* icon */
234
+ .kit-btn i:before {
235
+ color: var(--btn-color);
236
+ }
237
+
238
+ /* disabled */
239
+ .kit-btn.kit-btn--disabled,
240
+ .kit-btn[disabled],
241
+ input.kit-btn.kit-btn--disabled,
242
+ input.kit-btn[disabled] {
243
+ pointer-events: none;
244
+ user-select: none;
245
+ cursor: default;
246
+ }
247
+ .kit-btn:not([class*='btn--variant-']).kit-btn--disabled {
248
+ color: color-mix(in oklab, var(--btn-color) 40%, transparent) !important;
249
+ background-color: color-mix(in oklab, var(--btn-background) 70%, transparent) !important;
250
+ border-color: color-mix(in oklab, var(--btn-background) 70%, transparent) !important;
251
+ }
252
+ .kit-btn:not([class*='btn--variant-']).kit-btn--disabled i:before {
253
+ color: color-mix(in oklab, var(--btn-color) 40%, transparent) !important;
254
+ }
255
+ .kit-btn[class*='btn--variant-'].kit-btn--disabled,
256
+ .kit-btn[class*='btn--variant-'].kit-btn--disabled i:before {
257
+ color: color-mix(in oklab, var(--btn-background) 40%, transparent) !important;
258
+ }
259
+
260
+ /* loading */
261
+ .kit-btn.kit-btn--loading {
262
+ pointer-events: none;
263
+ user-select: none;
264
+ cursor: default;
265
+ }
266
+ .kit-btn.kit-btn--loading > .kit-btn-content {
267
+ color: transparent;
268
+ opacity: 0;
269
+ }
270
+ .kit-btn.kit-btn--loading > .kit-btn-loading {
271
+ position: absolute;
272
+ min-width: fit-content;
273
+ }
274
+ .kit-btn.kit-btn--loading > .kit-btn-loading .kit-icon-load {
275
+ animation: icon-rotate 1s ease-out infinite;
276
+ }
@@ -0,0 +1,94 @@
1
+ <script lang="ts">
2
+ import { getAssets } from '../../internal/index.js';
3
+ import Icon from '../icon/icon.svelte';
4
+ import type { BtnProps } from './types.js';
5
+
6
+ // external
7
+ import LoadingFill from '../../assets/icons/loading-fill.svelte';
8
+
9
+ let {
10
+ children,
11
+ ref = $bindable(),
12
+ is = 'button',
13
+ href,
14
+ dark,
15
+ light,
16
+ active,
17
+ variant,
18
+ error,
19
+ info,
20
+ success,
21
+ warning,
22
+ density = 'default',
23
+ disabled,
24
+ size = 'md',
25
+ type = 'button',
26
+ background,
27
+ color,
28
+ label,
29
+ loading,
30
+ rounded,
31
+ icon,
32
+ load,
33
+ ...rest
34
+ }: BtnProps = $props();
35
+
36
+ const assets = getAssets();
37
+
38
+ $effect(() => {
39
+ if (type === 'radio') is = 'input';
40
+ if (type === 'checkbox') is = 'input';
41
+ if (type === 'submit') is = 'input';
42
+ if (type === 'reset') is = 'input';
43
+ });
44
+ </script>
45
+
46
+ <svelte:element
47
+ this={href ? 'a' : is}
48
+ bind:this={ref}
49
+ {...rest}
50
+ href={href && !disabled ? href : undefined}
51
+ class={[
52
+ 'kit-btn',
53
+ light && 'light',
54
+ dark && 'dark',
55
+ size && assets.className('btn', 'size', size),
56
+ variant && assets.className('btn', 'variant', variant),
57
+ density && assets.className('btn', 'density', density),
58
+ error && 'kit-btn--error',
59
+ info && 'kit-btn--info',
60
+ success && 'kit-btn--success',
61
+ warning && 'kit-btn--warning',
62
+ disabled && 'kit-btn--disabled',
63
+ active && 'kit-btn--active',
64
+ loading && 'kit-btn--loading',
65
+ icon && 'kit-btn--icon',
66
+ rest.class
67
+ ]}
68
+ tabindex={href && disabled ? -1 : 0}
69
+ aria-disabled={href ? disabled : undefined}
70
+ aria-label={type !== 'button' ? label : undefined}
71
+ disabled={href ? undefined : disabled}
72
+ type={href ? undefined : type}
73
+ style:--base={assets.color(background)}
74
+ style:--on={assets.color(color)}
75
+ style:--shape={assets.shape(rounded)}
76
+ >
77
+ {#if loading}
78
+ <div class="kit-btn-loading">
79
+ {#if load}
80
+ {@render load?.()}
81
+ {:else}
82
+ <Icon class="kit-icon-load">
83
+ <LoadingFill />
84
+ </Icon>
85
+ {/if}
86
+ </div>
87
+ {/if}
88
+
89
+ {#if !label}
90
+ <span class="kit-btn-content">
91
+ {@render children?.()}
92
+ </span>
93
+ {/if}
94
+ </svelte:element>
@@ -0,0 +1,4 @@
1
+ import type { BtnProps } from './types.js';
2
+ declare const Button: import("svelte").Component<BtnProps, {}, "ref">;
3
+ type Button = ReturnType<typeof Button>;
4
+ export default Button;
@@ -0,0 +1,27 @@
1
+ import type { Component } from '../../internal/types.js';
2
+ import type { Snippet } from 'svelte';
3
+ export interface BtnProps extends Component {
4
+ ref?: HTMLElement | null;
5
+ is?: 'button' | 'a' | 'input';
6
+ dark?: boolean;
7
+ light?: boolean;
8
+ href?: string;
9
+ variant?: 'outline' | 'text' | 'dash' | 'link';
10
+ density?: 'compact' | 'comfortable' | 'default';
11
+ active?: boolean;
12
+ loading?: boolean;
13
+ error?: boolean;
14
+ info?: boolean;
15
+ warning?: boolean;
16
+ success?: boolean;
17
+ disabled?: boolean;
18
+ color?: string;
19
+ background?: string;
20
+ size?: string | {
21
+ [key: string]: string;
22
+ };
23
+ type?: 'button' | 'submit' | 'reset' | 'radio' | 'checkbox';
24
+ label?: string;
25
+ icon?: boolean;
26
+ load?: Snippet;
27
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,76 @@
1
+ .kit-icon {
2
+ --icon-size: 1rem;
3
+ --icon-color: var(--base, var(--kit-on-neutral));
4
+
5
+ display: inline-flex;
6
+ align-items: center;
7
+ justify-content: center;
8
+ transition: color 0.5s;
9
+ text-indent: 0;
10
+ }
11
+
12
+ .kit-icon:before {
13
+ font-size: calc(var(--icon-size-multiplier) * var(--icon-size));
14
+ color: var(--icon-color);
15
+ }
16
+
17
+ .kit-icon svg {
18
+ color: var(--icon-color);
19
+ }
20
+
21
+ .kit-icon svg,
22
+ .kit-icon img {
23
+ width: calc(var(--icon-size-multiplier) * var(--icon-size));
24
+ height: calc(var(--icon-size-multiplier) * var(--icon-size));
25
+ }
26
+
27
+ /* size */
28
+ .kit-icon[breakpoint]kit-icon--size-xs {
29
+ --icon-size-multiplier: 0.875;
30
+ }
31
+
32
+ .kit-icon[breakpoint]kit-icon--size-sm {
33
+ --icon-size-multiplier: 1;
34
+ }
35
+
36
+ .kit-icon[breakpoint]kit-icon--size-md {
37
+ --icon-size-multiplier: 1.125;
38
+ }
39
+
40
+ .kit-icon[breakpoint]kit-icon--size-lg {
41
+ --icon-size-multiplier: 1.25;
42
+ }
43
+
44
+ .kit-icon[breakpoint]kit-icon--size-xl {
45
+ --icon-size-multiplier: 1.5;
46
+ }
47
+
48
+ /* state */
49
+ .kit-icon.kit-icon--info {
50
+ --base: var(--kit-info);
51
+ }
52
+ .kit-icon.kit-icon--success {
53
+ --base: var(--kit-success);
54
+ }
55
+ .kit-icon.kit-icon--warning {
56
+ --base: var(--kit-warning);
57
+ }
58
+ .kit-icon.kit-icon--error {
59
+ --base: var(--kit-error);
60
+ }
61
+
62
+ /* disabled */
63
+ .kit-icon.kit-icon--disabled {
64
+ -webkit-user-select: none;
65
+ user-select: none;
66
+ pointer-events: none;
67
+ }
68
+
69
+ .kit-icon.kit-icon--disabled img {
70
+ opacity: 0.38;
71
+ }
72
+
73
+ .kit-icon.kit-icon--disabled svg,
74
+ .kit-icon.kit-icon--disabled:before {
75
+ color: color-mix(in oklab, var(--icon-color) 40%, transparent) !important;
76
+ }
@@ -0,0 +1,49 @@
1
+ <script lang="ts">
2
+ import { getAssets } from '../../internal/assets.svelte.js';
3
+ import type { IconProps } from './types.js';
4
+ let {
5
+ children,
6
+ ref = $bindable(),
7
+ is = 'i',
8
+ light,
9
+ dark,
10
+ icon,
11
+ size = 'md',
12
+ error,
13
+ info,
14
+ success,
15
+ warning,
16
+ disabled,
17
+ alt,
18
+ color,
19
+ ...rest
20
+ }: IconProps = $props();
21
+
22
+ const assets = getAssets();
23
+ </script>
24
+
25
+ <svelte:element
26
+ this={icon && icon.includes('/') ? 'div' : is}
27
+ bind:this={ref}
28
+ {...rest}
29
+ class={[
30
+ 'kit-icon',
31
+ icon && !icon.includes('/') && icon,
32
+ light && 'light',
33
+ dark && 'dark',
34
+ info && 'kit-icon--info',
35
+ success && 'kit-icon--success',
36
+ warning && 'kit-icon--warning',
37
+ error && 'kit-icon--error',
38
+ disabled && 'kit-icon--disabled',
39
+ size && assets.className('icon', 'size', size),
40
+ rest.class
41
+ ]}
42
+ style:--base={assets.color(color)}
43
+ >
44
+ {#if icon && icon.includes('/')}
45
+ <img src={icon} {alt} />
46
+ {:else}
47
+ {@render children?.()}
48
+ {/if}
49
+ </svelte:element>
@@ -0,0 +1,4 @@
1
+ import type { IconProps } from './types.js';
2
+ declare const Icon: import("svelte").Component<IconProps, {}, "ref">;
3
+ type Icon = ReturnType<typeof Icon>;
4
+ export default Icon;
@@ -0,0 +1,16 @@
1
+ import type { Component } from '../../internal/types.js';
2
+ export interface IconProps extends Component {
3
+ ref?: HTMLElement | null;
4
+ is?: 'i' | 'div';
5
+ dark?: boolean;
6
+ light?: boolean;
7
+ error?: boolean;
8
+ info?: boolean;
9
+ warning?: boolean;
10
+ success?: boolean;
11
+ disabled?: boolean;
12
+ color?: string;
13
+ size?: string | {
14
+ [key: string]: string;
15
+ };
16
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,3 @@
1
+ export { default as App } from './app/app.svelte';
2
+ export { default as Btn } from './button/button.svelte';
3
+ export { default as Icon } from './icon/icon.svelte';
@@ -0,0 +1,4 @@
1
+ // components
2
+ export { default as App } from './app/app.svelte';
3
+ export { default as Btn } from './button/button.svelte';
4
+ export { default as Icon } from './icon/icon.svelte';
@@ -0,0 +1,7 @@
1
+ export declare function getAssets(): {
2
+ shape(params?: string): string | undefined;
3
+ className(key: string, type: string, value: string | boolean | Array<string> | {
4
+ [key: string]: string;
5
+ }): string | undefined;
6
+ color(color?: string): string | undefined;
7
+ };
@@ -0,0 +1,41 @@
1
+ import { x11ColorNames } from '../utils/x11.js';
2
+ export function getAssets() {
3
+ return {
4
+ shape(params) {
5
+ if (params) {
6
+ if (params === 'none' || params == '0')
7
+ return '0';
8
+ return `var(--kit-radius-${params})`;
9
+ }
10
+ },
11
+ className(key, type, value) {
12
+ if (typeof value === 'string')
13
+ return `kit-${key}--${type}-${value}`;
14
+ else if (typeof value === 'boolean' && value)
15
+ return `kit-${key}--${type}`;
16
+ else if (typeof value === 'object') {
17
+ if (Array.isArray(value)) {
18
+ return value
19
+ .map((media) => `${media === '_default' ? '' : `${media}:`}kit--${type}`)
20
+ .join(' ');
21
+ }
22
+ else {
23
+ return Object.entries(value)
24
+ .map(([media, value]) => `${media === '_default' ? '' : `${media}:`}kit-${key}--${type}-${value}`)
25
+ .join(' ');
26
+ }
27
+ }
28
+ },
29
+ color(color) {
30
+ if (color) {
31
+ if (color.includes('#') ||
32
+ color.includes('rgb') ||
33
+ color.includes('rgba') ||
34
+ color.includes('oklch') ||
35
+ x11ColorNames.includes(color.toLowerCase()))
36
+ return color;
37
+ return `var(--kit-${color})`;
38
+ }
39
+ }
40
+ };
41
+ }
@@ -1,2 +1,3 @@
1
1
  export * from './terminal.js';
2
2
  export * from './ansi.js';
3
+ export * from './assets.svelte.js';
@@ -1,2 +1,3 @@
1
1
  export * from './terminal.js';
2
2
  export * from './ansi.js';
3
+ export * from './assets.svelte.js';
@@ -1,3 +1,16 @@
1
+ import type { Snippet } from 'svelte';
2
+ type IdElementType = string | undefined;
3
+ type ClassNameType = string | string[] | undefined;
4
+ type StylePropertiesType = string | undefined;
5
+ export interface Base {
6
+ id?: IdElementType;
7
+ class?: ClassNameType;
8
+ style?: StylePropertiesType;
9
+ [key: string]: any;
10
+ }
11
+ export interface Component extends Base {
12
+ children?: Snippet;
13
+ }
1
14
  export type FontFamily = {
2
15
  [key: string]: string | string[];
3
16
  };
package/dist/preset.js CHANGED
@@ -7,17 +7,29 @@ export const config = {
7
7
  colorScheme: 'dark', // 'light' | 'dark' | 'auto'
8
8
  colors: {
9
9
  primary: { light: 'oklch(45% 0.24 277.023)', dark: 'oklch(45% 0.24 277.023)' },
10
+ 'on-primary': { light: 'oklch(14% 0.005 285.823)', dark: 'oklch(14% 0.005 285.823)' },
10
11
  secondary: { light: 'oklch(65% 0.241 354.308)', dark: 'oklch(65% 0.241 354.308)' },
12
+ 'on-secondary': { light: 'oklch(14% 0.005 285.823)', dark: 'oklch(14% 0.005 285.823)' },
11
13
  tertiary: { light: 'oklch(77% 0.152 181.912)', dark: 'oklch(77% 0.152 181.912)' },
14
+ 'on-tertiary': { light: 'oklch(14% 0.005 285.823)', dark: 'oklch(14% 0.005 285.823)' },
12
15
  neutral: { light: 'oklch(14% 0.005 285.823)', dark: 'oklch(14% 0.005 285.823)' },
16
+ 'on-neutral': { light: 'oklch(100% 0 0)', dark: 'oklch(100% 0 0)' },
13
17
  info: { light: 'oklch(74% 0.16 232.661)', dark: 'oklch(74% 0.16 232.661)' },
18
+ 'on-info': { light: 'oklch(14% 0.005 285.823)', dark: 'oklch(14% 0.005 285.823)' },
14
19
  success: { light: 'oklch(76% 0.177 163.223)', dark: 'oklch(76% 0.177 163.223)' },
20
+ 'on-success': { light: 'oklch(14% 0.005 285.823)', dark: 'oklch(14% 0.005 285.823)' },
15
21
  warning: { light: 'oklch(82% 0.189 84.429)', dark: 'oklch(82% 0.189 84.429)' },
22
+ 'on-warning': { light: 'oklch(14% 0.005 285.823)', dark: 'oklch(14% 0.005 285.823)' },
16
23
  error: { light: 'oklch(71% 0.194 13.428)', dark: 'oklch(71% 0.194 13.428)' },
24
+ 'on-error': { light: 'oklch(14% 0.005 285.823)', dark: 'oklch(14% 0.005 285.823)' },
17
25
  base: { light: 'oklch(100% 0 0)', dark: 'oklch(25.33% 0.016 252.42)' },
26
+ 'on-base': { light: 'oklch(14% 0.005 285.823)', dark: 'oklch(100% 0 0)' },
18
27
  surface: { light: 'oklch(98% 0 0)', dark: 'oklch(23.26% 0.014 253.1)' },
28
+ 'on-surface': { light: 'oklch(14% 0.005 285.823)', dark: 'oklch(100% 0 0)' },
19
29
  container: { light: 'oklch(95% 0 0)', dark: 'oklch(21.15% 0.012 254.09)' },
20
- shadow: 'black'
30
+ 'on-container': { light: 'oklch(14% 0.005 285.823)', dark: 'oklch(100% 0 0)' },
31
+ shadow: 'black',
32
+ scrim: 'oklch(0.00% 0.000 0)'
21
33
  }
22
34
  },
23
35
  breakpoints: {
@@ -25,7 +37,7 @@ export const config = {
25
37
  tabletBreakpoint: 'md',
26
38
  laptopBreakpoint: 'xl',
27
39
  thresholds: {
28
- none: 0, // 0px
40
+ _default: 0, // 0px
29
41
  xs: '28rem', //448px
30
42
  sm: '40rem', //640px
31
43
  md: '48rem', //768px
@@ -0,0 +1,4 @@
1
+ import { type Writable } from 'svelte/store';
2
+ export declare const colorScheme: Writable<'auto' | 'dark' | 'light'>;
3
+ export declare function updateThemeStore(update: 'auto' | 'dark' | 'light'): void;
4
+ export declare function setColorScheme(scheme: 'auto' | 'dark' | 'light'): void;
@@ -0,0 +1,23 @@
1
+ import { writable } from 'svelte/store';
2
+ // states
3
+ const _default = 'light';
4
+ const isBrowser = typeof window !== 'undefined';
5
+ export const colorScheme = writable(_default);
6
+ export function updateThemeStore(update) {
7
+ colorScheme.update(() => {
8
+ if (isBrowser) {
9
+ const ref = document.documentElement.classList;
10
+ if (update === 'auto')
11
+ ref.remove('light', 'dark');
12
+ else {
13
+ ref.remove(update === 'dark' ? 'light' : 'dark');
14
+ ref.add(update === 'dark' ? 'dark' : 'light');
15
+ }
16
+ localStorage.setItem('@lapikit/theme', update);
17
+ }
18
+ return update;
19
+ });
20
+ }
21
+ export function setColorScheme(scheme) {
22
+ updateThemeStore(scheme);
23
+ }
@@ -0,0 +1,20 @@
1
+ @keyframes button-click {
2
+ 0% {
3
+ transform: scale(0.98);
4
+ }
5
+ 40% {
6
+ transform: scale(1.02);
7
+ }
8
+ 100% {
9
+ transform: scale(1);
10
+ }
11
+ }
12
+
13
+ @keyframes icon-rotate {
14
+ 0% {
15
+ transform: rotate(10deg);
16
+ }
17
+ 100% {
18
+ transform: rotate(380deg);
19
+ }
20
+ }
package/dist/style/css.js CHANGED
@@ -8,9 +8,9 @@ import { colors, component, devices, variables } from './parser/index.js';
8
8
  import { terminal } from '../internal/terminal.js';
9
9
  const __filename = fileURLToPath(import.meta.url);
10
10
  const __dirname = dirname(__filename);
11
- const __components = path.resolve('src/components');
12
11
  export const processCSS = async (config) => {
13
12
  const _normalize = fs.readFileSync(path.resolve(__dirname, './normalize.css'), 'utf-8');
13
+ const _animation = fs.readFileSync(path.resolve(__dirname, './animation.css'), 'utf-8');
14
14
  let styles = ``;
15
15
  if (config.options.normalize)
16
16
  styles += `${_normalize}\n`;
@@ -21,8 +21,8 @@ export const processCSS = async (config) => {
21
21
  styles += `${variablesStyles}\n`;
22
22
  styles += `${colorScheme.className}\n`;
23
23
  styles += `${deviceDisplay}\n`;
24
- if (fs.existsSync(__components) && fs.statSync(__components).isDirectory())
25
- styles += component(config);
24
+ styles += component(config);
25
+ styles += `${_animation}\n`;
26
26
  if (config.options.minify) {
27
27
  styles = minify(styles);
28
28
  terminal('success', 'css minified');
@@ -65,10 +65,21 @@ export const colors = (config) => {
65
65
  // class
66
66
  let classStyles = '';
67
67
  for (const [property] of Object.entries(schemes.light)) {
68
+ // classStyles += `.${property}:not([class*='--variant-']) {\n`;
69
+ // classStyles += `--background-color: var(--kit-${property});\n`;
70
+ // classStyles += `--color: var(--kit-on-${property}, var(--kit-${property}));\n`;
71
+ // classStyles += `}\n`;
72
+ // classStyles += `.${property}[class*='--variant-'] {\n`;
73
+ // classStyles += `--color: var(--kit-${property});\n`;
74
+ // classStyles += `}\n`;
68
75
  classStyles += `.${property} {\n`;
69
- classStyles += `--background-color: var(--kit-${property});\n`;
70
- classStyles += `--color: var(--kit-${property});\n`;
76
+ classStyles += `--base: var(--kit-${property});\n`;
77
+ classStyles += `--on: var(--kit-on-${property}, var(--kit-${property}));\n`;
71
78
  classStyles += `}\n`;
79
+ // classStyles += `.${property}:not([class*='kit-']) {\n`;
80
+ // classStyles += `background-color: var(--kit-${property});\n`;
81
+ // classStyles += `color: var(--kit-on-${property}, var(--kit-${property}));\n`;
82
+ // classStyles += `}\n`;
72
83
  }
73
84
  return {
74
85
  root: cssVariables,
@@ -1,4 +1,4 @@
1
1
  export declare const x11Colors: {
2
2
  [key: string]: string;
3
3
  };
4
- export declare const x11ColorNames: string[];
4
+ export declare const x11ColorNames: Array<string>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lapikit",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "license": "MIT",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -42,12 +42,18 @@
42
42
  "type": "module",
43
43
  "exports": {
44
44
  ".": {
45
- "types": "./dist/index.d.ts",
46
- "svelte": "./dist/index.js"
45
+ "types": "./dist/index.d.ts"
46
+ },
47
+ "./components": {
48
+ "svelte": "./dist/components/index.js",
49
+ "default": "./dist/components/index.js"
47
50
  },
48
51
  "./vite": {
49
52
  "default": "./dist/plugin/vitejs.js"
50
53
  },
54
+ "./stores": {
55
+ "default": "./dist/stores/index.js"
56
+ },
51
57
  "./css": "./dist/styles.css"
52
58
  },
53
59
  "peerDependencies": {