lapikit 0.0.4 → 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/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 ADDED
@@ -0,0 +1,74 @@
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
+ };
9
+
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
+ };
15
+
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
+ };
24
+
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
+ };
33
+
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
49
+ };
50
+
51
+ export const terminal = (type = 'info', msg) => {
52
+ const name = ansi.color.cyan('lapikit');
53
+
54
+ if (type === 'error') console.error(name, ansi.bold.red('[error]'), msg);
55
+ else if (type === 'warn') console.warn(name, ansi.bold.yellow('[warn]'), msg);
56
+ else if (type === 'success') console.warn(name, ansi.bold.green('[success]'), msg);
57
+ else if (type === 'none') console.log(msg);
58
+ else console.log(name, ansi.bold.blue('[info]'), msg);
59
+ };
60
+
61
+ export function getCssPathFromArgs() {
62
+ const args = process.argv.slice(2);
63
+ return args[1] || 'src/app.css';
64
+ }
65
+
66
+ export async function envTypescript() {
67
+ const directory = process.cwd();
68
+ try {
69
+ await fs.readFile(path.resolve(directory, 'tsconfig.json'), 'utf-8');
70
+ return true;
71
+ } catch {
72
+ return false;
73
+ }
74
+ }
package/bin/lapikit.js ADDED
@@ -0,0 +1,54 @@
1
+ #!/usr/bin/env node
2
+ import { promises as fs } from 'fs';
3
+ import path from 'path';
4
+ import { ansi, terminal, envTypescript } from './helper.js';
5
+ import { preset } from './modules/preset.js';
6
+ import { adapterCSSConfig, adapterViteConfig } from './modules/adapter.js';
7
+
8
+ const [, , command] = process.argv;
9
+ const typescriptEnabled = envTypescript();
10
+
11
+ if (process.argv.includes('--help') || process.argv.includes('-h')) {
12
+ terminal(
13
+ 'info',
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
+ );
17
+ process.exit(0);
18
+ } else if (command === 'init') {
19
+ console.log(' _ _ _ _ _ ');
20
+ console.log(' | | (_) | (_) | ');
21
+ console.log(' | | __ _ _ __ _| | ___| |_ ');
22
+ console.log(" | | / _` | '_ \\| | |/ / | __|");
23
+ console.log(' | |___| (_| | |_) | | <| | |_ ');
24
+ console.log(' |______\\__,_| .__/|_|_|\\_\\_|\\__|');
25
+ console.log(' | | ');
26
+ console.log(' |_| \n');
27
+
28
+ terminal('none', `${ansi.bold.blue('LAPIKIT')} - Component Library for Svelte\n\n`);
29
+
30
+ const configPath = path.resolve(process.cwd(), 'lapikit.config.js');
31
+ try {
32
+ await fs.writeFile(configPath, preset.trim() + '\n', 'utf8');
33
+ terminal('success', `has create lapikit.config.js on your project.`);
34
+ } catch (error) {
35
+ terminal('error', `failed to create configuration file:\n\n ${error}`);
36
+ terminal(
37
+ 'warn',
38
+ `you can create lapikit.config.js manually, please visite https://localhost:3000/docs for more information`
39
+ );
40
+ }
41
+
42
+ await adapterViteConfig(typescriptEnabled);
43
+ await adapterCSSConfig();
44
+
45
+ terminal(
46
+ 'info',
47
+ `${ansi.bold.blue('Thank to use lapikit, discover all posibility with lapikit on https://localhost:3000/docs')}\n\n`
48
+ );
49
+
50
+ console.log('Github: https://github.com/nycolaide/lapikit');
51
+ console.log('Support the developement: https://buymeacoffee.com/nycolaide');
52
+ } else {
53
+ terminal('error', `Command not recognized. Try 'npx lapikit -h'`);
54
+ }
@@ -0,0 +1,52 @@
1
+ import { promises as fs } from 'fs';
2
+ import path from 'path';
3
+ import { getCssPathFromArgs, terminal } from '../helper.js';
4
+
5
+ const importLapikitVite = `import { lapikit } from 'lapikit/vite';`;
6
+ const importLapikitCss = `@import 'lapikit/css';`;
7
+
8
+ export async function adapterViteConfig(typescript) {
9
+ const viteConfigPath = path.resolve(process.cwd(), `vite.config.${typescript ? 'ts' : 'js'}`);
10
+ try {
11
+ let viteConfig = await fs.readFile(viteConfigPath, 'utf8');
12
+
13
+ if (!viteConfig.includes(`${importLapikitVite}`))
14
+ viteConfig = `${importLapikitVite}\n` + viteConfig;
15
+
16
+ const pluginsRegex = /plugins:\s*\[([^\]]*)\]/;
17
+ const match = viteConfig.match(pluginsRegex);
18
+
19
+ if (match && !match[1].includes('lapikit()')) {
20
+ const updatedPlugins = match[1].trim() ? `${match[1].trim()}, lapikit()` : `lapikit()`;
21
+
22
+ viteConfig = viteConfig.replace(pluginsRegex, `plugins: [${updatedPlugins}]`);
23
+ }
24
+
25
+ await fs.writeFile(viteConfigPath, viteConfig, 'utf8');
26
+
27
+ terminal('success', 'lapikit() has added on vite.config.(js|ts) successfully');
28
+ } catch (error) {
29
+ terminal(
30
+ 'error',
31
+ `lapikit() encountered a problem while editing vite.config.(js|ts):\n ${error}.\n\n`
32
+ );
33
+ }
34
+ }
35
+
36
+ export async function adapterCSSConfig() {
37
+ const cssPath = getCssPathFromArgs();
38
+ const resolvedPath = path.resolve(process.cwd(), cssPath);
39
+ try {
40
+ await fs.access(resolvedPath);
41
+ let appCssContent = await fs.readFile(resolvedPath, 'utf8');
42
+ appCssContent = `${importLapikitCss}\n\n` + appCssContent;
43
+ await fs.writeFile(resolvedPath, appCssContent, 'utf8');
44
+
45
+ terminal('success', `lapikit/css has added on ${cssPath}.`);
46
+ } catch (error) {
47
+ terminal(
48
+ 'error',
49
+ `lapikit/css encountered a problem while editing ${cssPath}:\n ${error.message}.\n\n`
50
+ );
51
+ }
52
+ }
@@ -0,0 +1,11 @@
1
+ export const preset = `
2
+ /** @type {import('lapikit').Config} */
3
+ export default {
4
+ theme: {
5
+ colorScheme: 'light',
6
+ colors: {
7
+ svelte: '#ff3e00'
8
+ }
9
+ }
10
+ };
11
+ `;
@@ -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.4",
3
+ "version": "0.1.1",
4
+ "license": "MIT",
4
5
  "publishConfig": {
5
6
  "access": "public"
6
7
  },
@@ -23,24 +24,36 @@
23
24
  "test": "npm run test:unit -- --run"
24
25
  },
25
26
  "files": [
27
+ "bin",
26
28
  "dist",
29
+ "README.md",
30
+ "LICENSE",
27
31
  "!dist/**/*.test.*",
28
32
  "!dist/**/*.spec.*"
29
33
  ],
30
34
  "sideEffects": [
31
35
  "**/*.css"
32
36
  ],
37
+ "bin": {
38
+ "lapikit": "bin/lapikit.js"
39
+ },
33
40
  "svelte": "./dist/index.js",
34
41
  "types": "./dist/index.d.ts",
35
42
  "type": "module",
36
43
  "exports": {
37
44
  ".": {
38
- "types": "./dist/index.d.ts",
39
- "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"
40
50
  },
41
51
  "./vite": {
42
52
  "default": "./dist/plugin/vitejs.js"
43
53
  },
54
+ "./stores": {
55
+ "default": "./dist/stores/index.js"
56
+ },
44
57
  "./css": "./dist/styles.css"
45
58
  },
46
59
  "peerDependencies": {