lapikit 0.0.0-insiders.dcdfb82 → 0.0.0-insiders.e330f8d

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) Nycolaide <https://github.com/Nycolaide>.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/bin/helper.js CHANGED
@@ -1,43 +1,51 @@
1
- export const color = {
2
- red: `\x1b[31m${text}\x1b[0m`,
3
- green: `\x1b[32m${text}\x1b[0m`,
4
- yellow: `\x1b[33m${text}\x1b[0m`,
5
- blue: `\x1b[34m${text}\x1b[0m`,
6
- purple: `\x1b[35m${text}\x1b[0m`,
7
- cyan: `\x1b[36m${text}\x1b[0m`
1
+ const color = {
2
+ red: (text) => `\x1b[31m${text}\x1b[0m`,
3
+ green: (text) => `\x1b[32m${text}\x1b[0m`,
4
+ yellow: (text) => `\x1b[33m${text}\x1b[0m`,
5
+ blue: (text) => `\x1b[34m${text}\x1b[0m`,
6
+ purple: (text) => `\x1b[35m${text}\x1b[0m`,
7
+ cyan: (text) => `\x1b[36m${text}\x1b[0m`
8
8
  };
9
9
 
10
- export const variant = {
11
- bold: `\x1b[1m${text}\x1b[0m`,
12
- underline: `\x1b[4m${text}\x1b[0m`,
13
- inverse: `\x1b[7m${text}\x1b[0m`
10
+ const variant = {
11
+ bold: (text) => `\x1b[1m${text}\x1b[0m`,
12
+ underline: (text) => `\x1b[4m${text}\x1b[0m`,
13
+ inverse: (text) => `\x1b[7m${text}\x1b[0m`
14
14
  };
15
15
 
16
- export const bold = {
17
- red: `\x1b[1m\x1b[31m${text}\x1b[0m`,
18
- green: `\x1b[1m\x1b[32m${text}\x1b[0m`,
19
- yellow: `\x1b[1m\x1b[33m${text}\x1b[0m`,
20
- blue: `\x1b[1m\x1b[34m${text}\x1b[0m`,
21
- purple: `\x1b[1m\x1b[35m${text}\x1b[0m`,
22
- cyan: `\x1b[1m\x1b[36m${text}\x1b[0m`
16
+ const bold = {
17
+ red: (text) => `\x1b[1m\x1b[31m${text}\x1b[0m`,
18
+ green: (text) => `\x1b[1m\x1b[32m${text}\x1b[0m`,
19
+ yellow: (text) => `\x1b[1m\x1b[33m${text}\x1b[0m`,
20
+ blue: (text) => `\x1b[1m\x1b[34m${text}\x1b[0m`,
21
+ purple: (text) => `\x1b[1m\x1b[35m${text}\x1b[0m`,
22
+ cyan: (text) => `\x1b[1m\x1b[36m${text}\x1b[0m`
23
23
  };
24
24
 
25
- export const inverse = {
26
- red: `\x1b[7m\x1b[31m${text}\x1b[0m`,
27
- green: `\x1b[7m\x1b[32m${text}\x1b[0m`,
28
- yellow: `\x1b[7m\x1b[33m${text}\x1b[0m`,
29
- blue: `\x1b[7m\x1b[34m${text}\x1b[0m`,
30
- purple: `\x1b[7m\x1b[35m${text}\x1b[0m`,
31
- cyan: `\x1b[7m\x1b[36m${text}\x1b[0m`
25
+ const inverse = {
26
+ red: (text) => `\x1b[7m\x1b[31m${text}\x1b[0m`,
27
+ green: (text) => `\x1b[7m\x1b[32m${text}\x1b[0m`,
28
+ yellow: (text) => `\x1b[7m\x1b[33m${text}\x1b[0m`,
29
+ blue: (text) => `\x1b[7m\x1b[34m${text}\x1b[0m`,
30
+ purple: (text) => `\x1b[7m\x1b[35m${text}\x1b[0m`,
31
+ cyan: (text) => `\x1b[7m\x1b[36m${text}\x1b[0m`
32
32
  };
33
33
 
34
- export const underline = {
35
- red: `\x1b[4m\x1b[31m${text}\x1b[0m`,
36
- green: `\x1b[4m\x1b[32m${text}\x1b[0m`,
37
- yellow: `\x1b[4m\x1b[33m${text}\x1b[0m`,
38
- blue: `\x1b[4m\x1b[34m${text}\x1b[0m`,
39
- purple: `\x1b[4m\x1b[35m${text}\x1b[0m`,
40
- cyan: `\x1b[4m\x1b[36m${text}\x1b[0m`
34
+ const underline = {
35
+ red: (text) => `\x1b[4m\x1b[31m${text}\x1b[0m`,
36
+ green: (text) => `\x1b[4m\x1b[32m${text}\x1b[0m`,
37
+ yellow: (text) => `\x1b[4m\x1b[33m${text}\x1b[0m`,
38
+ blue: (text) => `\x1b[4m\x1b[34m${text}\x1b[0m`,
39
+ purple: (text) => `\x1b[4m\x1b[35m${text}\x1b[0m`,
40
+ cyan: (text) => `\x1b[4m\x1b[36m${text}\x1b[0m`
41
+ };
42
+
43
+ export const ansi = {
44
+ color,
45
+ variant,
46
+ bold,
47
+ inverse,
48
+ underline
41
49
  };
42
50
 
43
51
  export const terminal = (type = 'info', msg) => {
@@ -46,6 +54,7 @@ export const terminal = (type = 'info', msg) => {
46
54
  if (type === 'error') console.error(name, ansi.bold.red('[error]'), msg);
47
55
  else if (type === 'warn') console.warn(name, ansi.bold.yellow('[warn]'), msg);
48
56
  else if (type === 'success') console.warn(name, ansi.bold.green('[success]'), msg);
57
+ else if (type === 'none') console.log(msg);
49
58
  else console.log(name, ansi.bold.blue('[info]'), msg);
50
59
  };
51
60
 
package/bin/lapikit.js CHANGED
@@ -1,9 +1,9 @@
1
1
  #!/usr/bin/env node
2
2
  import { promises as fs } from 'fs';
3
3
  import path from 'path';
4
- import { color, bold, variant, terminal, envTypescript } from './helper';
5
- import { preset } from './modules/preset';
6
- import { adapterCSSConfig, adapterViteConfig } from './modules/adapter';
4
+ import { ansi, terminal, envTypescript } from './helper.js';
5
+ import { preset } from './modules/preset.js';
6
+ import { adapterCSSConfig, adapterViteConfig } from './modules/adapter.js';
7
7
 
8
8
  const [, , command] = process.argv;
9
9
  const typescriptEnabled = envTypescript();
@@ -11,8 +11,8 @@ const typescriptEnabled = envTypescript();
11
11
  if (process.argv.includes('--help') || process.argv.includes('-h')) {
12
12
  terminal(
13
13
  'info',
14
- `usage: ${color.yellow('npx lapikit init {cssPath}')}\n\n ${variant.bold('options:')}\n
15
- - {cssPath}: (${color.cyan('src/app.css')}) customize path on your origin css file.\n\n`
14
+ `usage: ${ansi.color.yellow('npx lapikit init {cssPath}')}\n\n ${ansi.variant.bold('options:')}\n
15
+ - {cssPath}: (${ansi.color.cyan('src/app.css')}) customize path on your origin css file.\n\n`
16
16
  );
17
17
  process.exit(0);
18
18
  } else if (command === 'init') {
@@ -23,9 +23,9 @@ if (process.argv.includes('--help') || process.argv.includes('-h')) {
23
23
  console.log(' | |___| (_| | |_) | | <| | |_ ');
24
24
  console.log(' |______\\__,_| .__/|_|_|\\_\\_|\\__|');
25
25
  console.log(' | | ');
26
- console.log(' |_| ');
26
+ console.log(' |_| \n');
27
27
 
28
- terminal('info', `${bold.blue('LAPIKIT')} - Component Library for Svelte\n\n`);
28
+ terminal('none', `${ansi.bold.blue('LAPIKIT')} - Component Library for Svelte\n\n`);
29
29
 
30
30
  const configPath = path.resolve(process.cwd(), 'lapikit.config.js');
31
31
  try {
@@ -44,11 +44,11 @@ if (process.argv.includes('--help') || process.argv.includes('-h')) {
44
44
 
45
45
  terminal(
46
46
  'info',
47
- `${bold.blue('Thank to use lapikit, discover all posibility with lapikit on https://localhost:3000/docs')}\n\n`
47
+ `${ansi.bold.blue('Thank to use lapikit, discover all posibility with lapikit on https://localhost:3000/docs')}\n\n`
48
48
  );
49
49
 
50
50
  console.log('Github: https://github.com/nycolaide/lapikit');
51
51
  console.log('Support the developement: https://buymeacoffee.com/nycolaide');
52
52
  } else {
53
- terminal('error', `Command not recognized. Try 'npx lapikit init'`);
53
+ terminal('error', `Command not recognized. Try 'npx lapikit -h'`);
54
54
  }
@@ -1,6 +1,6 @@
1
1
  import { promises as fs } from 'fs';
2
2
  import path from 'path';
3
- import { getCssPathFromArgs, terminal } from '../helper';
3
+ import { getCssPathFromArgs, terminal } from '../helper.js';
4
4
 
5
5
  const importLapikitVite = `import { lapikit } from 'lapikit/vite';`;
6
6
  const importLapikitCss = `@import 'lapikit/css';`;
@@ -28,7 +28,7 @@ export async function adapterViteConfig(typescript) {
28
28
  } catch (error) {
29
29
  terminal(
30
30
  'error',
31
- `lapikit encountered a problem while editing vite.config.(js|ts): \n\n ${error}`
31
+ `lapikit() encountered a problem while editing vite.config.(js|ts):\n ${error}.\n\n`
32
32
  );
33
33
  }
34
34
  }
@@ -46,7 +46,7 @@ export async function adapterCSSConfig() {
46
46
  } catch (error) {
47
47
  terminal(
48
48
  'error',
49
- `lapikit encountered a problem while editing ${cssPath}:\n\n ${error.message}.`
49
+ `lapikit/css encountered a problem while editing ${cssPath}:\n ${error.message}.\n\n`
50
50
  );
51
51
  }
52
52
  }
@@ -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,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,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,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,2 @@
1
+ export { default as App } from './app/app.svelte';
2
+ export { default as Btn } from './button/button.svelte';
@@ -0,0 +1,3 @@
1
+ // components
2
+ export { default as App } from './app/app.svelte';
3
+ export { default as Btn } from './button/button.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,11 @@
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
+ }
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,7 @@
1
1
  {
2
2
  "name": "lapikit",
3
- "version": "0.0.0-insiders.dcdfb82",
3
+ "version": "0.0.0-insiders.e330f8d",
4
+ "license": "MIT",
4
5
  "publishConfig": {
5
6
  "access": "public"
6
7
  },
@@ -25,6 +26,8 @@
25
26
  "files": [
26
27
  "bin",
27
28
  "dist",
29
+ "README.md",
30
+ "LICENSE",
28
31
  "!dist/**/*.test.*",
29
32
  "!dist/**/*.spec.*"
30
33
  ],
@@ -39,12 +42,18 @@
39
42
  "type": "module",
40
43
  "exports": {
41
44
  ".": {
42
- "types": "./dist/index.d.ts",
43
- "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"
44
50
  },
45
51
  "./vite": {
46
52
  "default": "./dist/plugin/vitejs.js"
47
53
  },
54
+ "./stores": {
55
+ "default": "./dist/stores/index.js"
56
+ },
48
57
  "./css": "./dist/styles.css"
49
58
  },
50
59
  "peerDependencies": {