lapikit 0.1.0 → 0.1.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/dist/components/app/app.svelte +14 -0
- package/dist/components/app/app.svelte.d.ts +7 -0
- package/dist/components/app/types.d.ts +4 -0
- package/dist/components/app/types.js +1 -0
- package/dist/components/button/button.css +240 -0
- package/dist/components/button/button.svelte +81 -0
- package/dist/components/button/button.svelte.d.ts +4 -0
- package/dist/components/button/types.d.ts +24 -0
- package/dist/components/button/types.js +1 -0
- package/dist/components/index.d.ts +2 -0
- package/dist/components/index.js +3 -0
- package/dist/internal/assets.svelte.d.ts +7 -0
- package/dist/internal/assets.svelte.js +41 -0
- package/dist/internal/index.d.ts +1 -0
- package/dist/internal/index.js +1 -0
- package/dist/internal/types.d.ts +13 -0
- package/dist/preset.js +14 -2
- package/dist/stores/index.d.ts +4 -0
- package/dist/stores/index.js +23 -0
- package/dist/style/animation.css +11 -0
- package/dist/style/css.js +3 -3
- package/dist/style/parser/color.js +13 -2
- package/dist/utils/x11.d.ts +1 -1
- package/package.json +9 -3
|
@@ -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 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,240 @@
|
|
|
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:active:hover,
|
|
27
|
+
.kit-btn:active:focus {
|
|
28
|
+
animation: button-click 0s ease-out;
|
|
29
|
+
transform: scale(0.97);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/* size */
|
|
33
|
+
.kit-btn[breakpoint]kit-btn--size-xs {
|
|
34
|
+
--btn-height: 1.75rem;
|
|
35
|
+
--btn-multiplier-y: 2;
|
|
36
|
+
font-size: 0.75rem;
|
|
37
|
+
gap: 0.25rem;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.kit-btn[breakpoint]kit-btn--size-sm {
|
|
41
|
+
--btn-height: 2rem;
|
|
42
|
+
--btn-multiplier-y: 3;
|
|
43
|
+
font-size: 0.875rem;
|
|
44
|
+
gap: 0.5rem;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.kit-btn[breakpoint]kit-btn--size-md {
|
|
48
|
+
--btn-height: 2.25rem;
|
|
49
|
+
--btn-multiplier-y: 4;
|
|
50
|
+
font-size: 0.875rem;
|
|
51
|
+
gap: 0.5rem;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.kit-btn[breakpoint]kit-btn--size-lg {
|
|
55
|
+
--btn-height: 2.5rem;
|
|
56
|
+
--btn-multiplier-y: 5;
|
|
57
|
+
font-size: 1rem;
|
|
58
|
+
gap: 0.5rem;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.kit-btn[breakpoint]kit-btn--size-xl {
|
|
62
|
+
--btn-height: 2.75rem;
|
|
63
|
+
--btn-multiplier-y: 6;
|
|
64
|
+
font-size: 1.125rem;
|
|
65
|
+
gap: 0.675rem;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/* density */
|
|
69
|
+
.kit-btn[breakpoint]kit-btn--density-default {
|
|
70
|
+
height: calc(var(--btn-height));
|
|
71
|
+
min-width: calc(var(--btn-height));
|
|
72
|
+
--btn-spacing-x: 0;
|
|
73
|
+
--btn-spacing-y: calc(var(--kit-spacing) * var(--btn-multiplier-y));
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.kit-btn[breakpoint]kit-btn--density-compact {
|
|
77
|
+
height: calc(var(--btn-height) - 0.25rem);
|
|
78
|
+
min-width: calc(var(--btn-height - 0.25rem));
|
|
79
|
+
--btn-spacing-x: 0;
|
|
80
|
+
--btn-spacing-y: calc(var(--kit-spacing) * var(--btn-multiplier-y) - 0.25rem);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
.kit-btn[breakpoint]kit-btn--density-comfortable {
|
|
84
|
+
height: calc(var(--btn-height) + 0.25rem);
|
|
85
|
+
min-width: calc(var(--btn-height) + 0.25rem);
|
|
86
|
+
--btn-spacing-x: 0;
|
|
87
|
+
--btn-spacing-y: calc(var(--kit-spacing) * var(--btn-multiplier-y) + 0.25rem);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/* variant */
|
|
91
|
+
.kit-btn[breakpoint]kit-btn--variant-outline {
|
|
92
|
+
--btn-color: var(--base, var(--kit-neutral));
|
|
93
|
+
background-color: transparent;
|
|
94
|
+
border: 1px solid currentColor;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.kit-btn[breakpoint]kit-btn--variant-text {
|
|
98
|
+
--btn-color: var(--base, var(--kit-neutral));
|
|
99
|
+
background-color: transparent;
|
|
100
|
+
border-color: transparent;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.kit-btn[breakpoint]kit-btn--variant-dash {
|
|
104
|
+
--btn-color: var(--base, var(--kit-neutral));
|
|
105
|
+
background-color: transparent;
|
|
106
|
+
border: 1px dashed currentColor;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
.kit-btn[breakpoint]kit-btn--variant-link {
|
|
110
|
+
--btn-color: var(--base, var(--kit-neutral));
|
|
111
|
+
background-color: transparent;
|
|
112
|
+
border-color: transparent;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/* state */
|
|
116
|
+
.kit-btn.kit-btn--info:not([class*='btn--variant-']) {
|
|
117
|
+
--on: var(--kit-on-info);
|
|
118
|
+
--base: var(--kit-info);
|
|
119
|
+
}
|
|
120
|
+
.kit-btn.kit-btn--info[class*='btn--variant-'] {
|
|
121
|
+
--base: var(--kit-info);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
.kit-btn.kit-btn--success:not([class*='btn--variant-']) {
|
|
125
|
+
--on: var(--kit-on-success);
|
|
126
|
+
--base: var(--kit-success);
|
|
127
|
+
}
|
|
128
|
+
.kit-btn.kit-btn--success[class*='btn--variant-'] {
|
|
129
|
+
--base: var(--kit-success);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
.kit-btn.kit-btn--warning:not([class*='btn--variant-']) {
|
|
133
|
+
--on: var(--kit-on-warning);
|
|
134
|
+
--base: var(--kit-warning);
|
|
135
|
+
}
|
|
136
|
+
.kit-btn.kit-btn--warning[class*='btn--variant-'] {
|
|
137
|
+
--base: var(--kit-warning);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
.kit-btn.kit-btn--error:not([class*='btn--variant-']) {
|
|
141
|
+
--on: var(--kit-on-error);
|
|
142
|
+
--base: var(--kit-error);
|
|
143
|
+
}
|
|
144
|
+
.kit-btn.kit-btn--error[class*='btn--variant-'] {
|
|
145
|
+
--base: var(--kit-error);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/* types */
|
|
149
|
+
.kit-btn:where(.kit-btn:is(input[type='checkbox'])),
|
|
150
|
+
.kit-btn:where(.kit-btn:is(input[type='radio'])) {
|
|
151
|
+
width: auto;
|
|
152
|
+
-webkit-appearance: none;
|
|
153
|
+
-moz-appearance: none;
|
|
154
|
+
appearance: none;
|
|
155
|
+
vertical-align: inherit;
|
|
156
|
+
}
|
|
157
|
+
.kit-btn:is(input[type='checkbox']):after,
|
|
158
|
+
.kit-btn:is(input[type='radio']):after {
|
|
159
|
+
--btn-content: attr(aria-label);
|
|
160
|
+
content: var(--btn-content);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
.kit-btn:is(input[type='checkbox']):focus,
|
|
164
|
+
.kit-btn:is(input[type='radio']):focus {
|
|
165
|
+
outline: none;
|
|
166
|
+
outline-offset: inherit;
|
|
167
|
+
box-shadow: none;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
.kit-btn:is(input[type='checkbox']):checked,
|
|
171
|
+
.kit-btn:is(input[type='radio']):checked {
|
|
172
|
+
background-image: initial;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/* events */
|
|
176
|
+
.kit-btn.kit-btn--active:not([class*='btn--variant-']),
|
|
177
|
+
.kit-btn:not([class*='btn--variant-']):is(input[type='radio']):checked,
|
|
178
|
+
.kit-btn:not([class*='btn--variant-']):is(input[type='checkbox']):checked {
|
|
179
|
+
background-color: color-mix(in oklab, var(--btn-background) 90%, var(--kit-scrim));
|
|
180
|
+
border-color: color-mix(in oklab, var(--btn-background) 90%, var(--kit-scrim));
|
|
181
|
+
}
|
|
182
|
+
.kit-btn.kit-btn--active[class*='btn--variant-'],
|
|
183
|
+
.kit-btn[class*='btn--variant-']:is(input[type='radio']):checked,
|
|
184
|
+
.kit-btn[class*='btn--variant-']:is(input[type='checkbox']):checked {
|
|
185
|
+
background-color: color-mix(in oklab, currentColor 15%, transparent);
|
|
186
|
+
border-color: color-mix(in oklab, currentColor 15%, transparent);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
.kit-btn:hover:not([class*='btn--variant-']),
|
|
190
|
+
.kit-btn:not([class*='btn--variant-']):is(input[type='radio']):hover,
|
|
191
|
+
.kit-btn:not([class*='btn--variant-']):is(input[type='checkbox']):hover {
|
|
192
|
+
background-color: color-mix(in oklab, var(--btn-background) 85%, var(--kit-scrim));
|
|
193
|
+
border-color: color-mix(in oklab, var(--btn-background) 85%, var(--kit-scrim));
|
|
194
|
+
}
|
|
195
|
+
.kit-btn:hover[class*='btn--variant-'],
|
|
196
|
+
.kit-btn[class*='btn--variant-']:is(input[type='radio']):hover,
|
|
197
|
+
.kit-btn[class*='btn--variant-']:is(input[type='checkbox']):hover {
|
|
198
|
+
background-color: color-mix(in oklab, currentColor 25%, transparent);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/* icon */
|
|
202
|
+
.kit-btn i:before {
|
|
203
|
+
color: var(--btn-color);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/* disabled */
|
|
207
|
+
.kit-btn.kit-btn--disabled,
|
|
208
|
+
.kit-btn[disabled],
|
|
209
|
+
input.kit-btn.kit-btn--disabled,
|
|
210
|
+
input.kit-btn[disabled] {
|
|
211
|
+
pointer-events: none;
|
|
212
|
+
user-select: none;
|
|
213
|
+
cursor: default;
|
|
214
|
+
}
|
|
215
|
+
.kit-btn:not([class*='btn--variant-']).kit-btn--disabled {
|
|
216
|
+
color: color-mix(in oklab, var(--btn-color) 40%, transparent) !important;
|
|
217
|
+
background-color: color-mix(in oklab, var(--btn-background) 70%, transparent) !important;
|
|
218
|
+
border-color: color-mix(in oklab, var(--btn-background) 70%, transparent) !important;
|
|
219
|
+
}
|
|
220
|
+
.kit-btn:not([class*='btn--variant-']).kit-btn--disabled i:before {
|
|
221
|
+
color: color-mix(in oklab, var(--btn-color) 40%, transparent) !important;
|
|
222
|
+
}
|
|
223
|
+
.kit-btn[class*='btn--variant-'].kit-btn--disabled,
|
|
224
|
+
.kit-btn[class*='btn--variant-'].kit-btn--disabled i:before {
|
|
225
|
+
color: color-mix(in oklab, var(--btn-background) 40%, transparent) !important;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/* loading */
|
|
229
|
+
.kit-btn.kit-btn--loading {
|
|
230
|
+
pointer-events: none;
|
|
231
|
+
user-select: none;
|
|
232
|
+
cursor: default;
|
|
233
|
+
}
|
|
234
|
+
.kit-btn.kit-btn--loading > .kit-btn-content {
|
|
235
|
+
color: transparent;
|
|
236
|
+
}
|
|
237
|
+
.kit-btn.kit-btn--loading > .kit-btn-loading {
|
|
238
|
+
position: absolute;
|
|
239
|
+
min-width: fit-content;
|
|
240
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { getAssets } from '../../internal/index.js';
|
|
3
|
+
import type { BtnProps } from './types.js';
|
|
4
|
+
|
|
5
|
+
let {
|
|
6
|
+
children,
|
|
7
|
+
ref = $bindable(),
|
|
8
|
+
is = 'button',
|
|
9
|
+
href,
|
|
10
|
+
dark,
|
|
11
|
+
light,
|
|
12
|
+
active,
|
|
13
|
+
variant,
|
|
14
|
+
error,
|
|
15
|
+
info,
|
|
16
|
+
success,
|
|
17
|
+
warning,
|
|
18
|
+
density = 'default',
|
|
19
|
+
disabled,
|
|
20
|
+
size = 'md',
|
|
21
|
+
type = 'button',
|
|
22
|
+
background,
|
|
23
|
+
color,
|
|
24
|
+
label,
|
|
25
|
+
loading,
|
|
26
|
+
rounded,
|
|
27
|
+
...rest
|
|
28
|
+
}: BtnProps = $props();
|
|
29
|
+
|
|
30
|
+
const assets = getAssets();
|
|
31
|
+
|
|
32
|
+
$effect(() => {
|
|
33
|
+
if (type === 'radio') is = 'input';
|
|
34
|
+
if (type === 'checkbox') is = 'input';
|
|
35
|
+
if (type === 'submit') is = 'input';
|
|
36
|
+
if (type === 'reset') is = 'input';
|
|
37
|
+
});
|
|
38
|
+
</script>
|
|
39
|
+
|
|
40
|
+
<svelte:element
|
|
41
|
+
this={href ? 'a' : is}
|
|
42
|
+
bind:this={ref}
|
|
43
|
+
{...rest}
|
|
44
|
+
href={href && !disabled ? href : undefined}
|
|
45
|
+
class={[
|
|
46
|
+
'kit-btn',
|
|
47
|
+
light && 'light',
|
|
48
|
+
dark && 'dark',
|
|
49
|
+
size && assets.className('btn', 'size', size),
|
|
50
|
+
variant && assets.className('btn', 'variant', variant),
|
|
51
|
+
density && assets.className('btn', 'density', density),
|
|
52
|
+
error && 'kit-btn--error',
|
|
53
|
+
info && 'kit-btn--info',
|
|
54
|
+
success && 'kit-btn--success',
|
|
55
|
+
warning && 'kit-btn--warning',
|
|
56
|
+
disabled && 'kit-btn--disabled',
|
|
57
|
+
active && 'kit-btn--active',
|
|
58
|
+
loading && 'kit-btn--loading',
|
|
59
|
+
rest.class
|
|
60
|
+
]}
|
|
61
|
+
tabindex={href && disabled ? -1 : 0}
|
|
62
|
+
aria-disabled={href ? disabled : undefined}
|
|
63
|
+
aria-label={type !== 'button' ? label : undefined}
|
|
64
|
+
disabled={href ? undefined : disabled}
|
|
65
|
+
type={href ? undefined : type}
|
|
66
|
+
style:--base={assets.color(background)}
|
|
67
|
+
style:--on={assets.color(color)}
|
|
68
|
+
style:--shape={assets.shape(rounded)}
|
|
69
|
+
>
|
|
70
|
+
{#if loading}
|
|
71
|
+
<div class="kit-btn-loading">
|
|
72
|
+
<div>loading ...</div>
|
|
73
|
+
</div>
|
|
74
|
+
{/if}
|
|
75
|
+
|
|
76
|
+
{#if !label}
|
|
77
|
+
<span class="kit-btn-content">
|
|
78
|
+
{@render children?.()}
|
|
79
|
+
</span>
|
|
80
|
+
{/if}
|
|
81
|
+
</svelte:element>
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Component } from '../../internal/types.js';
|
|
2
|
+
export interface BtnProps extends Component {
|
|
3
|
+
ref?: HTMLElement | null;
|
|
4
|
+
is?: 'button' | 'a' | 'input';
|
|
5
|
+
dark?: boolean;
|
|
6
|
+
light?: boolean;
|
|
7
|
+
href?: string;
|
|
8
|
+
variant?: 'outline' | 'text' | 'dash' | 'link';
|
|
9
|
+
density?: 'compact' | 'comfortable' | 'default';
|
|
10
|
+
active?: boolean;
|
|
11
|
+
loading?: boolean;
|
|
12
|
+
error?: boolean;
|
|
13
|
+
info?: boolean;
|
|
14
|
+
warning?: boolean;
|
|
15
|
+
success?: boolean;
|
|
16
|
+
disabled?: boolean;
|
|
17
|
+
color?: string;
|
|
18
|
+
background?: string;
|
|
19
|
+
size?: string | {
|
|
20
|
+
[key: string]: string;
|
|
21
|
+
};
|
|
22
|
+
type?: 'button' | 'submit' | 'reset' | 'radio' | 'checkbox';
|
|
23
|
+
label?: string;
|
|
24
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -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
|
+
}
|
package/dist/internal/index.d.ts
CHANGED
package/dist/internal/index.js
CHANGED
package/dist/internal/types.d.ts
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
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
|
+
}
|
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
|
-
|
|
25
|
-
|
|
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 += `--
|
|
70
|
-
classStyles += `--
|
|
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,
|
package/dist/utils/x11.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lapikit",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
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
|
-
|
|
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": {
|