@valerius_petrini/corekit-ui 0.1.78 → 0.1.80
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/display/KBD/index.svelte +2 -2
- package/dist/components/display/Skeleton/index.svelte +1 -1
- package/dist/components/feedback/Loader/index.svelte +1 -0
- package/dist/components/feedback/Modal/index.svelte +29 -17
- package/dist/components/feedback/Toast/index.svelte +1 -1
- package/dist/components/inputs/Button/index.svelte +26 -53
- package/dist/components/inputs/Input/index.svelte +4 -4
- package/dist/components/inputs/helper/BaseInput.svelte +1 -3
- package/dist/components/navigation/Navbar/NavbarDropdown.svelte +27 -25
- package/dist/components/navigation/Navbar/NavbarElement.svelte +3 -2
- package/dist/components/navigation/Navbar/index.stories.svelte +3 -0
- package/dist/components/navigation/Navbar/index.svelte +1 -1
- package/dist/components/navigation/Navbar/types.d.ts +2 -0
- package/dist/components/typography/Text/index.svelte +3 -3
- package/package.json +1 -1
|
@@ -14,11 +14,11 @@
|
|
|
14
14
|
const combinedClass = $derived(twMerge(defaultClass, className));
|
|
15
15
|
</script>
|
|
16
16
|
|
|
17
|
-
<
|
|
17
|
+
<kbd class={combinedClass} {...restProps} bind:this={element}>
|
|
18
18
|
{@render children?.()}
|
|
19
19
|
{#if subtext}
|
|
20
20
|
<span class="text-sub-text text-[10px] mt-0.5">
|
|
21
21
|
{@render subtext?.()}
|
|
22
22
|
</span>
|
|
23
23
|
{/if}
|
|
24
|
-
</
|
|
24
|
+
</kbd>
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
</div>
|
|
40
40
|
{/snippet}
|
|
41
41
|
|
|
42
|
-
<div class={combinedContainerClass} bind:this={element}>
|
|
42
|
+
<div class={combinedContainerClass} bind:this={element} aria-hidden="true">
|
|
43
43
|
{#if variant === "default"}
|
|
44
44
|
<div class="h-4 bg-sub-background rounded w-3/4"></div>
|
|
45
45
|
<div class="h-4 bg-sub-background rounded w-full"></div>
|
|
@@ -9,13 +9,26 @@
|
|
|
9
9
|
let {
|
|
10
10
|
children = undefined,
|
|
11
11
|
class: className = "",
|
|
12
|
-
element = $bindable(),
|
|
13
|
-
open = $bindable(),
|
|
12
|
+
element = $bindable<HTMLDialogElement>(),
|
|
13
|
+
open = $bindable(false),
|
|
14
14
|
position = "center",
|
|
15
15
|
size = "md",
|
|
16
16
|
...restProps
|
|
17
17
|
}: ModalProps = $props();
|
|
18
18
|
|
|
19
|
+
$effect(() => {
|
|
20
|
+
if (!element) return;
|
|
21
|
+
if (open) {
|
|
22
|
+
(element as HTMLDialogElement).showModal();
|
|
23
|
+
} else {
|
|
24
|
+
(element as HTMLDialogElement).close();
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
function onclose() {
|
|
29
|
+
open = false;
|
|
30
|
+
}
|
|
31
|
+
|
|
19
32
|
const outerClass = $derived(twMerge(
|
|
20
33
|
"inset-0 flex flex-col w-[calc(100%-1rem)] h-[calc(100%-1rem)] p-4",
|
|
21
34
|
modalPositionParts[position]
|
|
@@ -28,20 +41,19 @@
|
|
|
28
41
|
));
|
|
29
42
|
</script>
|
|
30
43
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
{@render children()}
|
|
44
|
+
<dialog
|
|
45
|
+
bind:this={element}
|
|
46
|
+
class="w-full h-screen bg-black/50 z-300 fixed top-0 left-0 p-0 m-0 max-w-none max-h-none"
|
|
47
|
+
transition:fade={{ duration: 200 }}
|
|
48
|
+
onclick={() => open = false}
|
|
49
|
+
onclose={onclose}
|
|
50
|
+
{...restProps}
|
|
51
|
+
>
|
|
52
|
+
{#if open}
|
|
53
|
+
<div class={outerClass} transition:fly={{ y: -20, duration: 200 }}>
|
|
54
|
+
<Card class={cardClass} onclick={(e: MouseEvent) => e.stopPropagation()}>
|
|
55
|
+
{@render children?.()}
|
|
44
56
|
</Card>
|
|
45
57
|
</div>
|
|
46
|
-
|
|
47
|
-
|
|
58
|
+
{/if}
|
|
59
|
+
</dialog>
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
});
|
|
60
60
|
</script>
|
|
61
61
|
|
|
62
|
-
<div transition:fly={flyParams} class={combinedToastClass} {...restProps} bind:this={element}>
|
|
62
|
+
<div transition:fly={flyParams} class={combinedToastClass} {...restProps} bind:this={element} role="status" aria-live={type === "error" ? "assertive" : "polite"}>
|
|
63
63
|
<div class="w-8 h-8 flex-center">
|
|
64
64
|
<Icon class={defualtIconClass}/>
|
|
65
65
|
</div>
|
|
@@ -29,72 +29,45 @@
|
|
|
29
29
|
...restProps
|
|
30
30
|
}: ButtonProps = $props();
|
|
31
31
|
|
|
32
|
-
const
|
|
33
|
-
"inline-flex items-center justify-center gap-2 transition-colors duration-300 ease-in-out text-white whitespace-nowrap";
|
|
34
|
-
const disabledClass = $derived(
|
|
35
|
-
disabled || loading
|
|
36
|
-
? "opacity-50 pointer-events-none"
|
|
37
|
-
: "cursor-pointer",
|
|
38
|
-
);
|
|
39
|
-
const iconClass = $derived(icon ? "p-0 flex-none" : "h-fit");
|
|
40
|
-
const pillClass = $derived((pill || icon) && "rounded-full");
|
|
41
|
-
const squareClass = $derived(square && "aspect-square rounded-none");
|
|
32
|
+
const isDisabled = $derived(disabled || loading);
|
|
42
33
|
|
|
43
|
-
const mergedClass = $derived(
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
pillClass,
|
|
55
|
-
squareClass,
|
|
56
|
-
className,
|
|
57
|
-
),
|
|
58
|
-
);
|
|
34
|
+
const mergedClass = $derived(twMerge(
|
|
35
|
+
"inline-flex items-center justify-center gap-2 transition-colors duration-300 ease-in-out text-white whitespace-nowrap",
|
|
36
|
+
generateColorStyle(color, variant),
|
|
37
|
+
isDisabled ? "opacity-50 pointer-events-none" : "cursor-pointer",
|
|
38
|
+
getSizeStyleClassRecord(size, icon ? buttonIconSizeStyles : buttonSizeStyles),
|
|
39
|
+
getSizeStyleClass(radius, "radius"),
|
|
40
|
+
icon ? "p-0 flex-none" : "h-fit",
|
|
41
|
+
(pill || icon) && "rounded-full",
|
|
42
|
+
square && "aspect-square rounded-none",
|
|
43
|
+
className,
|
|
44
|
+
));
|
|
59
45
|
|
|
60
|
-
const mergedStyle = $derived(
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
?
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
]
|
|
70
|
-
.filter(Boolean)
|
|
71
|
-
.join("; "),
|
|
72
|
-
);
|
|
73
|
-
|
|
74
|
-
const anchorProps = $derived(
|
|
75
|
-
getLinkProps(href, external, disabled || loading),
|
|
76
|
-
);
|
|
46
|
+
const mergedStyle = $derived([
|
|
47
|
+
typeof size === "number"
|
|
48
|
+
? icon
|
|
49
|
+
? `height: ${size}px; width: ${size}px; padding: ${size / 4}px`
|
|
50
|
+
: `height: ${size}px; padding: ${size / 4}px ${size / 8}px`
|
|
51
|
+
: "",
|
|
52
|
+
getSizeStyle(radius, "radius"),
|
|
53
|
+
restProps.style,
|
|
54
|
+
].filter(Boolean).join("; "));
|
|
77
55
|
</script>
|
|
78
56
|
|
|
79
57
|
<svelte:element
|
|
80
58
|
this={href ? "a" : "button"}
|
|
81
59
|
class={mergedClass}
|
|
82
|
-
disabled={
|
|
83
|
-
aria-disabled={
|
|
60
|
+
disabled={isDisabled}
|
|
61
|
+
aria-disabled={isDisabled}
|
|
62
|
+
aria-busy={loading}
|
|
84
63
|
type={href ? undefined : restProps.type || "button"}
|
|
85
64
|
style={mergedStyle}
|
|
86
|
-
{...
|
|
65
|
+
{...getLinkProps(href, external, isDisabled)}
|
|
87
66
|
{...restProps}
|
|
88
67
|
bind:this={element}
|
|
89
68
|
>
|
|
90
69
|
{#if loading}
|
|
91
|
-
<Loader
|
|
92
|
-
color="white"
|
|
93
|
-
class="border-2 border-loader-btn-color {getSizeStyleClass(
|
|
94
|
-
size,
|
|
95
|
-
'buttonLoader',
|
|
96
|
-
)}"
|
|
97
|
-
/>
|
|
70
|
+
<Loader color="white" class="border-2 border-loader-btn-color {getSizeStyleClass(size, 'buttonLoader')}" />
|
|
98
71
|
{/if}
|
|
99
72
|
{@render children?.()}
|
|
100
73
|
</svelte:element>
|
|
@@ -134,19 +134,19 @@
|
|
|
134
134
|
{...restProps}>
|
|
135
135
|
{#snippet outerDivElementAfter()}
|
|
136
136
|
{#if touched && requirements}
|
|
137
|
-
<
|
|
137
|
+
<ul role="list" class="mt-1 text-xs" transition:slide={{ duration: 300 }}>
|
|
138
138
|
{#each requirements as req}
|
|
139
139
|
{@const isReqMet = testRequirement(req.requirements)}
|
|
140
140
|
{@const reqClass = isReqMet ? "text-green-500" : "text-red-500"}
|
|
141
|
-
<
|
|
141
|
+
<li class="flex w-full items-center gap-1 transition-colors {reqClass}">
|
|
142
142
|
<div class="relative w-4 h-4">
|
|
143
143
|
<Check class="w-4 h-4 absolute transition-all duration-150 {isReqMet ? 'opacity-100 scale-100' : 'opacity-0 scale-0'}"/>
|
|
144
144
|
<X class="w-4 h-4 absolute transition-all duration-150 {isReqMet ? 'opacity-0 scale-0' : 'opacity-100 scale-100'}"/>
|
|
145
145
|
</div>
|
|
146
146
|
<Text tag="span" class="text-xs text-inherit">{req.label}</Text>
|
|
147
|
-
</
|
|
147
|
+
</li>
|
|
148
148
|
{/each}
|
|
149
|
-
</
|
|
149
|
+
</ul>
|
|
150
150
|
{/if}
|
|
151
151
|
{/snippet}
|
|
152
152
|
|
|
@@ -85,9 +85,7 @@
|
|
|
85
85
|
{/if}
|
|
86
86
|
{#if icon}
|
|
87
87
|
{@const Icon = icon}
|
|
88
|
-
<
|
|
89
|
-
<Icon class="h-full aspect-square text-sub-text"></Icon>
|
|
90
|
-
</div>
|
|
88
|
+
<Icon class="h-5 aspect-square mx-1 py-0! text-sub-text shrink-0"></Icon>
|
|
91
89
|
{/if}
|
|
92
90
|
{@render innerDivElement?.()}
|
|
93
91
|
</div>
|
|
@@ -12,6 +12,9 @@
|
|
|
12
12
|
} from "@floating-ui/dom";
|
|
13
13
|
import { tick } from "svelte";
|
|
14
14
|
|
|
15
|
+
import ChevronUp from "@lucide/svelte/icons/chevron-up";
|
|
16
|
+
import ChevronDown from "@lucide/svelte/icons/chevron-down";
|
|
17
|
+
|
|
15
18
|
let {
|
|
16
19
|
children = undefined,
|
|
17
20
|
class: className = "",
|
|
@@ -62,13 +65,8 @@
|
|
|
62
65
|
};
|
|
63
66
|
}
|
|
64
67
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
open = false;
|
|
68
|
-
} else {
|
|
69
|
-
ready = false;
|
|
70
|
-
open = true;
|
|
71
|
-
}
|
|
68
|
+
function toggle() {
|
|
69
|
+
open = !open;
|
|
72
70
|
}
|
|
73
71
|
|
|
74
72
|
function handleClickOutside(event: MouseEvent) {
|
|
@@ -80,35 +78,39 @@
|
|
|
80
78
|
|
|
81
79
|
<svelte:window onclick={handleClickOutside} />
|
|
82
80
|
|
|
83
|
-
<
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
</
|
|
96
|
-
|
|
81
|
+
<NavbarElement
|
|
82
|
+
onclick={toggle}
|
|
83
|
+
class="{className} relative {wrapperClass}"
|
|
84
|
+
bind:element
|
|
85
|
+
{...restProps}
|
|
86
|
+
aria-haspopup="true"
|
|
87
|
+
aria-expanded={open}
|
|
88
|
+
>
|
|
89
|
+
{label}
|
|
90
|
+
{#if navelement}
|
|
91
|
+
{@render navelement()}
|
|
92
|
+
{/if}
|
|
93
|
+
<span class="sr-only">{open ? 'Close' : 'Open'} dropdown</span>
|
|
94
|
+
<ChevronDown
|
|
95
|
+
class="mt-0.5 transition-transform ease-out duration-150 {open ? 'rotate-180' : 'rotate-0'}"
|
|
96
|
+
size="16"/>
|
|
97
|
+
</NavbarElement>
|
|
97
98
|
|
|
98
99
|
{#if open}
|
|
99
100
|
<div
|
|
100
101
|
use:initDropdown
|
|
102
|
+
role="menu"
|
|
101
103
|
style="position: fixed; top: {y}px; left: {x}px;"
|
|
102
104
|
class="z-100 shadow-lg"
|
|
103
105
|
style:visibility={ready ? "visible" : "hidden"}
|
|
104
106
|
>
|
|
105
|
-
<
|
|
107
|
+
<menu
|
|
106
108
|
transition:fly={flyParams}
|
|
107
|
-
class="bg-sub-background p-2 min-w-max flex flex-col
|
|
109
|
+
class="bg-sub-background p-2 min-w-max flex flex-col rounded border border-white/10 shadow-xl shadow-black/40"
|
|
108
110
|
>
|
|
109
|
-
<button onclick={() => (open = false)} class="contents">
|
|
111
|
+
<button onclick={() => (open = false)} class="contents *:w-full [&_button]:justify-start [&_a]:justify-start *:mx-0 [&_a]:pr-5">
|
|
110
112
|
{@render children?.()}
|
|
111
113
|
</button>
|
|
112
|
-
</
|
|
114
|
+
</menu>
|
|
113
115
|
</div>
|
|
114
116
|
{/if}
|
|
@@ -12,10 +12,11 @@
|
|
|
12
12
|
active = false,
|
|
13
13
|
href = undefined,
|
|
14
14
|
threshold = 10,
|
|
15
|
+
color = "sub",
|
|
15
16
|
...restProps
|
|
16
17
|
}: NavbarElementProps = $props();
|
|
17
18
|
|
|
18
|
-
let defaultClass = "navbar-element w-fit h-
|
|
19
|
+
let defaultClass = "navbar-element w-fit h-fit mx-2 px-2.5 py-1.5 rounded text-main-text";
|
|
19
20
|
|
|
20
21
|
let scrollY = $state(0);
|
|
21
22
|
let isAtTop = $derived(scrollY <= threshold);
|
|
@@ -30,6 +31,6 @@
|
|
|
30
31
|
|
|
31
32
|
<svelte:window bind:scrollY={scrollY}/>
|
|
32
33
|
|
|
33
|
-
<Button bind:element radius="none" {href} color
|
|
34
|
+
<Button bind:element radius="none" {href} {color} class={combinedClass} {...restProps} aria-current={active ? 'page' : undefined}>
|
|
34
35
|
{@render children?.()}
|
|
35
36
|
</Button>
|
|
@@ -25,5 +25,8 @@
|
|
|
25
25
|
<NavbarElement href="/about">About</NavbarElement>
|
|
26
26
|
<NavbarSeparator variant="horizontal"/>
|
|
27
27
|
<NavbarElement href="/contact">Contact</NavbarElement>
|
|
28
|
+
<NavbarElement>No Link</NavbarElement>
|
|
28
29
|
</NavbarDropdown>
|
|
30
|
+
|
|
31
|
+
<NavbarElement color="primary">Action</NavbarElement>
|
|
29
32
|
</Story>
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
...restProps
|
|
12
12
|
}: NavbarProps = $props();
|
|
13
13
|
|
|
14
|
-
let defaultClass = "transition-colors duration-300 fixed top-0 left-0 w-full h-14 z-[100] flex items-center bg-sub-background/99 border-b border-box border-b-sub-background-hover";
|
|
14
|
+
let defaultClass = "transition-colors duration-300 fixed top-0 left-0 w-full h-14 z-[100] flex items-center bg-sub-background/99 border-b border-box border-b-sub-background-hover px-4 md:px-6 lg:px-8";
|
|
15
15
|
|
|
16
16
|
let scrollY = $state(0);
|
|
17
17
|
let isAtTop = $derived(scrollY <= threshold);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Snippet } from "svelte";
|
|
2
2
|
import type { BaseComponentProps } from "../../../types/BaseComponent.ts";
|
|
3
|
+
import type { ColorStyle } from "../../../styles/color.ts";
|
|
3
4
|
export interface NavbarProps extends BaseComponentProps {
|
|
4
5
|
classTop?: string;
|
|
5
6
|
threshold?: number;
|
|
@@ -10,6 +11,7 @@ export interface NavbarElementProps extends BaseComponentProps {
|
|
|
10
11
|
active?: boolean;
|
|
11
12
|
href?: string;
|
|
12
13
|
threshold?: number;
|
|
14
|
+
color?: ColorStyle;
|
|
13
15
|
}
|
|
14
16
|
export type NavbarSeparatorVariant = "vertical" | "horizontal" | "dynamic";
|
|
15
17
|
export declare const NavbarSeparatorClasses: Record<NavbarSeparatorVariant, string>;
|
|
@@ -25,9 +25,9 @@
|
|
|
25
25
|
"u": { class: "underline", size: "text-base" },
|
|
26
26
|
"small": { class: "", size: "text-sm" },
|
|
27
27
|
"blockquote": { class: "border-l-4 border-gray-500 pl-2 opacity-70", size: "text-base" },
|
|
28
|
-
"pre": { class: "font-mono bg-sub-background px-3 py-2
|
|
29
|
-
"code": { class: "font-mono bg-sub-background px-1
|
|
30
|
-
"a": { class: "text-blue-400
|
|
28
|
+
"pre": { class: "font-mono bg-sub-background px-3 py-2 rounded overflow-x-auto whitespace-pre", size: "text-base" },
|
|
29
|
+
"code": { class: "font-mono bg-sub-background px-1 rounded inline-block", size: "text-base" },
|
|
30
|
+
"a": { class: "text-blue-400 decoration-blue-400/0 underline underline-offset-2 transition-all cursor-pointer duration-150 hover:decoration-blue-400 ", size: "text-base" },
|
|
31
31
|
"li": { class: "text-base list-disc list-inside", size: "text-base" },
|
|
32
32
|
"h1": { class: "font-bold", size: "text-4xl" },
|
|
33
33
|
"h2": { class: "font-bold", size: "text-3xl" },
|