lapikit 0.0.0-insiders.dcdfb82 → 0.0.0-insiders.de81aed
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 +21 -0
- package/bin/helper.js +41 -32
- package/bin/lapikit.js +9 -9
- package/bin/modules/adapter.js +3 -3
- package/dist/assets/icons/loading-fill.svelte +29 -0
- package/dist/assets/icons/loading-fill.svelte.d.ts +26 -0
- 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 +276 -0
- package/dist/components/button/button.svelte +94 -0
- package/dist/components/button/button.svelte.d.ts +4 -0
- package/dist/components/button/types.d.ts +27 -0
- package/dist/components/button/types.js +1 -0
- package/dist/components/dialog/dialog.css +143 -0
- package/dist/components/dialog/dialog.svelte +67 -0
- package/dist/components/dialog/dialog.svelte.d.ts +4 -0
- package/dist/components/dialog/types.d.ts +21 -0
- package/dist/components/dialog/types.js +1 -0
- package/dist/components/dropdown/dropdown.css +22 -0
- package/dist/components/dropdown/dropdown.svelte +116 -0
- package/dist/components/dropdown/dropdown.svelte.d.ts +4 -0
- package/dist/components/dropdown/dropdown.svelte.js +148 -0
- package/dist/components/dropdown/types.d.ts +26 -0
- package/dist/components/dropdown/types.js +1 -0
- package/dist/components/icon/icon.css +76 -0
- package/dist/components/icon/icon.svelte +49 -0
- package/dist/components/icon/icon.svelte.d.ts +4 -0
- package/dist/components/icon/types.d.ts +16 -0
- package/dist/components/icon/types.js +1 -0
- package/dist/components/index.d.ts +9 -0
- package/dist/components/index.js +10 -0
- package/dist/components/modal/modal.css +19 -0
- package/dist/components/modal/modal.svelte +59 -0
- package/dist/components/modal/modal.svelte.d.ts +4 -0
- package/dist/components/modal/types.d.ts +21 -0
- package/dist/components/modal/types.js +1 -0
- package/dist/components/popover/popover.css +22 -0
- package/dist/components/popover/popover.svelte +73 -0
- package/dist/components/popover/popover.svelte.d.ts +4 -0
- package/dist/components/popover/popover.svelte.js +134 -0
- package/dist/components/popover/types.d.ts +20 -0
- package/dist/components/popover/types.js +1 -0
- package/dist/components/separator/separator.css +46 -0
- package/dist/components/separator/separator.svelte +37 -0
- package/dist/components/separator/separator.svelte.d.ts +4 -0
- package/dist/components/separator/types.d.ts +11 -0
- package/dist/components/separator/types.js +1 -0
- package/dist/components/tooltip/tooltip.css +124 -0
- package/dist/components/tooltip/tooltip.svelte +113 -0
- package/dist/components/tooltip/tooltip.svelte.d.ts +4 -0
- package/dist/components/tooltip/tooltip.svelte.js +131 -0
- package/dist/components/tooltip/types.d.ts +23 -0
- package/dist/components/tooltip/types.js +1 -0
- package/dist/internal/assets.svelte.d.ts +8 -0
- package/dist/internal/assets.svelte.js +52 -0
- package/dist/internal/clickOutside.d.ts +9 -0
- package/dist/internal/clickOutside.js +34 -0
- package/dist/internal/index.d.ts +2 -0
- package/dist/internal/index.js +2 -0
- package/dist/internal/scroll.d.ts +1 -0
- package/dist/internal/scroll.js +6 -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 +20 -0
- package/dist/style/css.js +6 -3
- package/dist/style/parser/color.js +13 -2
- package/dist/style/variable.css +7 -0
- package/dist/utils/x11.d.ts +1 -1
- package/package.json +12 -3
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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 {
|
|
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('
|
|
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
|
|
53
|
+
terminal('error', `Command not recognized. Try 'npx lapikit -h'`);
|
|
54
54
|
}
|
package/bin/modules/adapter.js
CHANGED
|
@@ -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)
|
|
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
|
|
49
|
+
`lapikit/css encountered a problem while editing ${cssPath}:\n ${error.message}.\n\n`
|
|
50
50
|
);
|
|
51
51
|
}
|
|
52
52
|
}
|
|
@@ -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 @@
|
|
|
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,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 {};
|