@valerius_petrini/corekit-ui 0.1.47 → 0.1.48
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/Button.svelte +45 -15
- package/dist/components/Card.svelte +1 -1
- package/dist/components/Checkbox.svelte +35 -0
- package/dist/components/Checkbox.svelte.d.ts +4 -0
- package/dist/components/FloatingSelect.svelte +2 -2
- package/dist/components/NavbarElement.svelte +2 -2
- package/dist/components/Text.svelte +2 -2
- package/dist/styles/color.d.ts +4 -11
- package/dist/styles/color.js +61 -9
- package/dist/styles/size.d.ts +3 -0
- package/dist/styles/size.js +57 -0
- package/dist/types/Button.d.ts +7 -2
- package/dist/types/Checkbox.d.ts +9 -0
- package/package.json +1 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import {
|
|
2
|
+
import { generateColorStyle } from "../styles/color.js";
|
|
3
|
+
import { sizeStyleParts, type SizeStyle } from "../styles/size.js";
|
|
3
4
|
import type { ButtonProps } from "../types/Button.js";
|
|
4
5
|
import { twMerge } from "tailwind-merge";
|
|
5
6
|
|
|
@@ -9,26 +10,55 @@
|
|
|
9
10
|
pill = false,
|
|
10
11
|
icon = false,
|
|
11
12
|
href = undefined,
|
|
12
|
-
color =
|
|
13
|
-
|
|
13
|
+
color = "none",
|
|
14
|
+
variant = "full",
|
|
15
|
+
disabled = false,
|
|
16
|
+
external = false,
|
|
17
|
+
size = "md",
|
|
18
|
+
radius = "md",
|
|
14
19
|
...restProps
|
|
15
20
|
}: ButtonProps = $props();
|
|
16
21
|
|
|
17
|
-
|
|
18
|
-
if (typeof size === "
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
+
const sizeClasses = $derived.by(() => {
|
|
23
|
+
if (typeof size === "string") {
|
|
24
|
+
const parts = sizeStyleParts[size as SizeStyle];
|
|
25
|
+
return icon ? parts.buttonIcon : parts.button;
|
|
26
|
+
}
|
|
27
|
+
return icon ? "p-0 flex-none" : "h-fit";
|
|
28
|
+
});
|
|
22
29
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
30
|
+
const customStyle = $derived(
|
|
31
|
+
typeof size === "number"
|
|
32
|
+
? `width: ${size}px; height: ${size}px; flex: none;`
|
|
33
|
+
: ""
|
|
34
|
+
);
|
|
28
35
|
|
|
29
|
-
|
|
36
|
+
const defaultClass = "inline-flex items-center justify-center gap-2 transition-colors duration-300 text-white whitespace-nowrap";
|
|
37
|
+
const radiusClass = $derived(pill || icon ? "rounded-full" : sizeStyleParts[radius as SizeStyle].radius);
|
|
38
|
+
const disabledClass = $derived(disabled ? "opacity-50 pointer-events-none" : "cursor-pointer");
|
|
39
|
+
|
|
40
|
+
const mergedClass = $derived(twMerge(
|
|
41
|
+
defaultClass,
|
|
42
|
+
generateColorStyle(color, variant),
|
|
43
|
+
disabledClass,
|
|
44
|
+
sizeClasses,
|
|
45
|
+
radiusClass,
|
|
46
|
+
className
|
|
47
|
+
));
|
|
48
|
+
|
|
49
|
+
const mergedStyle = $derived([customStyle, restProps.style].filter(Boolean).join("; "));
|
|
30
50
|
</script>
|
|
31
51
|
|
|
32
|
-
<svelte:element
|
|
52
|
+
<svelte:element
|
|
53
|
+
this={href ? "a" : "button"}
|
|
54
|
+
class={mergedClass}
|
|
55
|
+
{disabled}
|
|
56
|
+
aria-disabled={disabled}
|
|
57
|
+
type={href ? undefined : (restProps.type || "button")}
|
|
58
|
+
style={mergedStyle}
|
|
59
|
+
target={external ? "_blank" : undefined}
|
|
60
|
+
rel={external ? "noopener noreferrer" : undefined}
|
|
61
|
+
{...(href ? { href } : {})}
|
|
62
|
+
{...restProps}>
|
|
33
63
|
{@render children?.()}
|
|
34
64
|
</svelte:element>
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
...restProps
|
|
11
11
|
}: CardProps = $props();
|
|
12
12
|
|
|
13
|
-
let defaultClass = "text-main-text shadow-xl
|
|
13
|
+
let defaultClass = "text-main-text shadow-xl radius-lg transition-colors bg-sub-background hover:bg-sub-background-hover p-4";
|
|
14
14
|
let combinedClass = $derived(twMerge(defaultClass, className));
|
|
15
15
|
</script>
|
|
16
16
|
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { twMerge } from "tailwind-merge";
|
|
3
|
+
import Text from "./Text.svelte";
|
|
4
|
+
import type { CheckboxProps } from "../types/Checkbox.js";
|
|
5
|
+
|
|
6
|
+
let {
|
|
7
|
+
children = undefined,
|
|
8
|
+
class: className = "",
|
|
9
|
+
labelClass = "",
|
|
10
|
+
divClass = "",
|
|
11
|
+
checked = $bindable(),
|
|
12
|
+
id = crypto.randomUUID(),
|
|
13
|
+
...restProps
|
|
14
|
+
}: CheckboxProps = $props();
|
|
15
|
+
|
|
16
|
+
let defaultClass = "z-20 bg-form-input-background text-main-text rounded-lg outline-none focus:ring-2 focus:ring-blue-500 transition-all";
|
|
17
|
+
let defaultLabelClass = "block text-sub-text font-medium";
|
|
18
|
+
let defaultDivClass = "relative flex items-center gap-2";
|
|
19
|
+
|
|
20
|
+
let combinedLabelClass = $derived(twMerge(defaultLabelClass, labelClass));
|
|
21
|
+
let combinedClass = $derived(twMerge(defaultClass, className));
|
|
22
|
+
let combinedDivClass = $derived(twMerge(defaultDivClass, divClass));
|
|
23
|
+
</script>
|
|
24
|
+
|
|
25
|
+
<div class={combinedDivClass}>
|
|
26
|
+
<input
|
|
27
|
+
type="checkbox"
|
|
28
|
+
id={id}
|
|
29
|
+
bind:checked={checked}
|
|
30
|
+
class={combinedClass}
|
|
31
|
+
{...restProps}/>
|
|
32
|
+
<Text tag="label" for={id} class={combinedLabelClass}>
|
|
33
|
+
{@render children?.()}
|
|
34
|
+
</Text>
|
|
35
|
+
</div>
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
let {
|
|
7
7
|
children = undefined,
|
|
8
8
|
class: className = "",
|
|
9
|
-
|
|
9
|
+
divClass = "",
|
|
10
10
|
optionClass = "",
|
|
11
11
|
value = $bindable(),
|
|
12
12
|
options = [],
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
|
|
23
23
|
let combinedLabelClass = $derived(twMerge(defaultLabelClass, selectedLabelClass, className));
|
|
24
24
|
let combinedSelectClass = $derived(twMerge(defaultSelectClass, className));
|
|
25
|
-
let combinedDivClass = $derived(twMerge(defaultDivClass,
|
|
25
|
+
let combinedDivClass = $derived(twMerge(defaultDivClass, divClass));
|
|
26
26
|
</script>
|
|
27
27
|
|
|
28
28
|
<div class={combinedDivClass}>
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
...restProps
|
|
13
13
|
}: NavbarElementProps = $props();
|
|
14
14
|
|
|
15
|
-
let defaultClass = "navbar-element w-fit h-full
|
|
15
|
+
let defaultClass = "navbar-element w-fit h-full px-5 py-0 text-main-text hover:bg-navbar-element-hover-background";
|
|
16
16
|
|
|
17
17
|
let scrollY = $state(0);
|
|
18
18
|
|
|
@@ -34,6 +34,6 @@
|
|
|
34
34
|
});
|
|
35
35
|
</script>
|
|
36
36
|
|
|
37
|
-
<Button {href} class={combinedClass} {...restProps}>
|
|
37
|
+
<Button radius={0} {href} class={combinedClass} {...restProps}>
|
|
38
38
|
{@render children?.()}
|
|
39
39
|
</Button>
|
|
@@ -18,8 +18,8 @@
|
|
|
18
18
|
"em": "text-base italic",
|
|
19
19
|
"small": "text-sm",
|
|
20
20
|
"blockquote": "border-l-4 border-gray-500 pl-2 opacity-70",
|
|
21
|
-
"pre": "font-mono bg-sub-background px-3 py-2
|
|
22
|
-
"code": "font-mono bg-sub-background px-3 py-2
|
|
21
|
+
"pre": "font-mono bg-sub-background px-3 py-2 radius overflow-x-auto whitespace-pre",
|
|
22
|
+
"code": "font-mono bg-sub-background px-3 py-2 radius inline-block",
|
|
23
23
|
"a": "text-blue-400 hover:text-blue-500 hover:underline",
|
|
24
24
|
"li": "text-base list-disc list-inside",
|
|
25
25
|
"h1": "text-6xl font-extrabold",
|
package/dist/styles/color.d.ts
CHANGED
|
@@ -1,11 +1,4 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
blue: string;
|
|
6
|
-
pink: string;
|
|
7
|
-
purple: string;
|
|
8
|
-
gray: string;
|
|
9
|
-
sub: string;
|
|
10
|
-
};
|
|
11
|
-
export type ColorStyle = keyof typeof colorStyles;
|
|
1
|
+
export type ColorStyle = "red" | "yellow" | "lightgreen" | "blue" | "pink" | "purple" | "gray" | "sub" | "none";
|
|
2
|
+
export type ColorStyleType = "full" | "light" | "outline" | "ghost";
|
|
3
|
+
export declare const colorStyleParts: Record<ColorStyle, Record<ColorStyleType, string>>;
|
|
4
|
+
export declare function generateColorStyle(color: ColorStyle, variant: ColorStyleType): string;
|
package/dist/styles/color.js
CHANGED
|
@@ -1,10 +1,62 @@
|
|
|
1
|
-
export const
|
|
2
|
-
red:
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
export const colorStyleParts = {
|
|
2
|
+
red: {
|
|
3
|
+
full: "bg-red-500 hover:bg-red-600",
|
|
4
|
+
light: "bg-red-500/35 hover:bg-red-600/35 text-white/60",
|
|
5
|
+
outline: "border border-red-500 hover:border-red-600 text-red-500 hover:text-red-600 hover:bg-red-500/10",
|
|
6
|
+
ghost: "hover:bg-red-500"
|
|
7
|
+
},
|
|
8
|
+
yellow: {
|
|
9
|
+
full: "bg-yellow-500 hover:bg-yellow-600",
|
|
10
|
+
light: "bg-yellow-500/35 hover:bg-yellow-600/35 text-white/60",
|
|
11
|
+
outline: "border border-yellow-500 hover:border-yellow-600 text-yellow-500 hover:text-yellow-600 hover:bg-yellow-500/10",
|
|
12
|
+
ghost: "hover:bg-yellow-500"
|
|
13
|
+
},
|
|
14
|
+
lightgreen: {
|
|
15
|
+
full: "bg-green-500 hover:bg-green-600",
|
|
16
|
+
light: "bg-green-500/35 hover:bg-green-600/35 text-white/60",
|
|
17
|
+
outline: "border border-green-500 hover:border-green-600 text-green-500 hover:text-green-600 hover:bg-green-500/10",
|
|
18
|
+
ghost: "hover:bg-green-500"
|
|
19
|
+
},
|
|
20
|
+
blue: {
|
|
21
|
+
full: "bg-blue-500 hover:bg-blue-600",
|
|
22
|
+
light: "bg-blue-500/35 hover:bg-blue-600/35 text-white/60",
|
|
23
|
+
outline: "border border-blue-500 hover:border-blue-600 text-blue-500 hover:text-blue-600 hover:bg-blue-500/10",
|
|
24
|
+
ghost: "hover:bg-blue-500"
|
|
25
|
+
},
|
|
26
|
+
pink: {
|
|
27
|
+
full: "bg-pink-500 hover:bg-pink-600",
|
|
28
|
+
light: "bg-pink-500/35 hover:bg-pink-600/35 text-white/60",
|
|
29
|
+
outline: "border border-pink-500 hover:border-pink-600 text-pink-500 hover:text-pink-600 hover:bg-pink-500/10",
|
|
30
|
+
ghost: "hover:bg-pink-500"
|
|
31
|
+
},
|
|
32
|
+
purple: {
|
|
33
|
+
full: "bg-purple-500 hover:bg-purple-600",
|
|
34
|
+
light: "bg-purple-500/35 hover:bg-purple-600/35 text-white/60",
|
|
35
|
+
outline: "border border-purple-500 hover:border-purple-600 text-purple-500 hover:text-purple-600 hover:bg-purple-500/10",
|
|
36
|
+
ghost: "hover:bg-purple-500"
|
|
37
|
+
},
|
|
38
|
+
gray: {
|
|
39
|
+
full: "bg-gray-500 hover:bg-gray-600",
|
|
40
|
+
light: "bg-gray-500/35 hover:bg-gray-600/35 text-white/60",
|
|
41
|
+
outline: "border border-gray-500 hover:border-gray-600 text-gray-500 hover:text-gray-600 hover:bg-gray-500/10",
|
|
42
|
+
ghost: "hover:bg-gray-500"
|
|
43
|
+
},
|
|
44
|
+
sub: {
|
|
45
|
+
full: "bg-sub-background hover:bg-sub-background-hover",
|
|
46
|
+
light: "bg-sub-background hover:bg-sub-background-hover text-white/60",
|
|
47
|
+
outline: "border border-sub-background hover:border-sub-background-hover text-sub-background hover:text-sub-background-hover hover:bg-sub-background/10",
|
|
48
|
+
ghost: "hover:bg-sub-background"
|
|
49
|
+
},
|
|
50
|
+
none: {
|
|
51
|
+
full: "",
|
|
52
|
+
light: "",
|
|
53
|
+
outline: "",
|
|
54
|
+
ghost: ""
|
|
55
|
+
}
|
|
10
56
|
};
|
|
57
|
+
export function generateColorStyle(color, variant) {
|
|
58
|
+
const styles = colorStyleParts[color];
|
|
59
|
+
if (!styles)
|
|
60
|
+
return "";
|
|
61
|
+
return styles[variant] || "";
|
|
62
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
export const sizeStyleParts = {
|
|
2
|
+
xs: {
|
|
3
|
+
button: "text-xs h-4 px-1 py-0.5",
|
|
4
|
+
buttonIcon: "text-xs h-4 w-4 p-0.5",
|
|
5
|
+
radius: "rounded-xs"
|
|
6
|
+
},
|
|
7
|
+
sm: {
|
|
8
|
+
button: "text-sm h-6 px-2 py-1",
|
|
9
|
+
buttonIcon: "text-sm h-6 w-6 p-1",
|
|
10
|
+
radius: "rounded-sm"
|
|
11
|
+
},
|
|
12
|
+
md: {
|
|
13
|
+
button: "text-base h-8 px-3 py-1.5",
|
|
14
|
+
buttonIcon: "text-base h-8 w-8 p-1.5",
|
|
15
|
+
radius: "rounded-md"
|
|
16
|
+
},
|
|
17
|
+
lg: {
|
|
18
|
+
button: "text-lg h-10 px-4 py-2",
|
|
19
|
+
buttonIcon: "text-lg h-10 w-10 p-2",
|
|
20
|
+
radius: "rounded-lg"
|
|
21
|
+
},
|
|
22
|
+
xl: {
|
|
23
|
+
button: "text-xl h-12 px-5 py-2.5",
|
|
24
|
+
buttonIcon: "text-xl h-12 w-12 p-2.5",
|
|
25
|
+
radius: "rounded-xl"
|
|
26
|
+
},
|
|
27
|
+
"2xl": {
|
|
28
|
+
button: "text-2xl h-14 px-6 py-3",
|
|
29
|
+
buttonIcon: "text-2xl h-14 w-14 p-3",
|
|
30
|
+
radius: "rounded-2xl"
|
|
31
|
+
},
|
|
32
|
+
"3xl": {
|
|
33
|
+
button: "text-3xl h-16 px-7 py-3.5",
|
|
34
|
+
buttonIcon: "text-3xl h-16 w-16 p-3.5",
|
|
35
|
+
radius: "rounded-3xl"
|
|
36
|
+
},
|
|
37
|
+
"4xl": {
|
|
38
|
+
button: "text-4xl h-18 px-8 py-4",
|
|
39
|
+
buttonIcon: "text-4xl h-18 w-18 p-4",
|
|
40
|
+
radius: "rounded-4xl"
|
|
41
|
+
},
|
|
42
|
+
full: {
|
|
43
|
+
button: "w-full text-base h-8 px-3 py-1",
|
|
44
|
+
buttonIcon: "w-full aspect-square text-base p-1",
|
|
45
|
+
radius: "rounded-full"
|
|
46
|
+
},
|
|
47
|
+
none: {
|
|
48
|
+
button: "",
|
|
49
|
+
buttonIcon: "",
|
|
50
|
+
radius: "rounded-none"
|
|
51
|
+
},
|
|
52
|
+
0: {
|
|
53
|
+
button: "",
|
|
54
|
+
buttonIcon: "",
|
|
55
|
+
radius: "rounded-none"
|
|
56
|
+
}
|
|
57
|
+
};
|
package/dist/types/Button.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { ColorStyle } from "../styles/color.ts";
|
|
1
|
+
import type { ColorStyle, ColorStyleType } from "../styles/color.ts";
|
|
2
|
+
import type { SizeStyle } from "../styles/size.ts";
|
|
2
3
|
|
|
3
4
|
export interface ButtonProps {
|
|
4
5
|
children?: any;
|
|
@@ -7,6 +8,10 @@ export interface ButtonProps {
|
|
|
7
8
|
icon?: boolean;
|
|
8
9
|
href?: string;
|
|
9
10
|
color?: ColorStyle;
|
|
10
|
-
|
|
11
|
+
variant?: ColorStyleType;
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
external?: boolean;
|
|
14
|
+
size?: SizeStyle;
|
|
15
|
+
radius?: SizeStyle;
|
|
11
16
|
[key: string]: any;
|
|
12
17
|
}
|