@x33025/sveltely 0.0.58 → 0.1.0
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/actions/tooltip.d.ts +10 -0
- package/dist/actions/tooltip.js +255 -0
- package/dist/components/{AnimatedNumber.demo.svelte → Library/AnimatedNumber/AnimatedNumber.demo.svelte} +6 -10
- package/dist/components/{AnimatedNumber.demo.svelte.d.ts → Library/AnimatedNumber/AnimatedNumber.demo.svelte.d.ts} +0 -1
- package/dist/components/Library/AnimatedNumber/AnimatedNumber.svelte +29 -0
- package/dist/components/Library/AnimatedNumber/AnimatedNumber.svelte.d.ts +9 -0
- package/dist/components/Library/AnimatedNumber/index.d.ts +1 -0
- package/dist/components/Library/AnimatedNumber/index.js +1 -0
- package/dist/components/{AsyncButton.demo.svelte → Library/AsyncButton/AsyncButton.demo.svelte} +0 -1
- package/dist/components/Library/AsyncButton/AsyncButton.svelte +178 -0
- package/dist/components/{AsyncButton.svelte.d.ts → Library/AsyncButton/AsyncButton.svelte.d.ts} +7 -2
- package/dist/components/Library/AsyncButton/index.d.ts +1 -0
- package/dist/components/Library/AsyncButton/index.js +1 -0
- package/dist/components/Library/Button/Button.demo.svelte +17 -0
- package/dist/components/Library/Button/Button.demo.svelte.d.ts +23 -0
- package/dist/components/Library/Button/Button.svelte +134 -0
- package/dist/components/Library/Button/Button.svelte.d.ts +17 -0
- package/dist/components/Library/Button/index.d.ts +1 -0
- package/dist/components/Library/Button/index.js +1 -0
- package/dist/components/Library/Calendar/Calendar.demo.svelte +30 -0
- package/dist/components/Library/Calendar/Calendar.demo.svelte.d.ts +10 -0
- package/dist/components/Library/Calendar/Calendar.svelte +310 -0
- package/dist/components/Library/Calendar/Calendar.svelte.d.ts +10 -0
- package/dist/components/Library/Calendar/index.d.ts +1 -0
- package/dist/components/Library/Calendar/index.js +1 -0
- package/dist/components/Library/Checkbox/Checkbox.demo.svelte +20 -0
- package/dist/components/Library/Checkbox/Checkbox.demo.svelte.d.ts +8 -0
- package/dist/components/Library/Checkbox/Checkbox.svelte +134 -0
- package/dist/components/Library/Checkbox/Checkbox.svelte.d.ts +11 -0
- package/dist/components/Library/Checkbox/index.d.ts +1 -0
- package/dist/components/Library/Checkbox/index.js +1 -0
- package/dist/components/{ChipInput.demo.svelte → Library/ChipInput/ChipInput.demo.svelte} +1 -2
- package/dist/components/{ChipInput.demo.svelte.d.ts → Library/ChipInput/ChipInput.demo.svelte.d.ts} +0 -1
- package/dist/components/{ChipInput.svelte → Library/ChipInput/ChipInput.svelte} +77 -3
- package/dist/components/{ChipInput.svelte.d.ts → Library/ChipInput/ChipInput.svelte.d.ts} +2 -1
- package/dist/components/Library/ChipInput/index.d.ts +1 -0
- package/dist/components/Library/ChipInput/index.js +1 -0
- package/dist/components/Library/Dropdown/Dropdown.demo.svelte +54 -0
- package/dist/components/Library/Dropdown/Dropdown.demo.svelte.d.ts +8 -0
- package/dist/components/Library/Dropdown/Dropdown.svelte +346 -0
- package/dist/components/Library/Dropdown/Dropdown.svelte.d.ts +40 -0
- package/dist/components/Library/Dropdown/index.d.ts +2 -0
- package/dist/components/Library/Dropdown/index.js +1 -0
- package/dist/components/Library/Dropdown/types.d.ts +27 -0
- package/dist/components/Library/Dropdown/types.js +1 -0
- package/dist/components/{Popover/Popover.svelte → Library/Floating/Floating.svelte} +155 -101
- package/dist/components/Library/Floating/Floating.svelte.d.ts +30 -0
- package/dist/components/Library/Floating/registry.svelte.d.ts +6 -0
- package/dist/components/{Popover → Library/Floating}/registry.svelte.js +2 -23
- package/dist/components/{GlowEffect.svelte → Library/GlowEffect/GlowEffect.svelte} +15 -6
- package/dist/components/{GlowEffect.svelte.d.ts → Library/GlowEffect/GlowEffect.svelte.d.ts} +3 -2
- package/dist/components/Library/GlowEffect/index.d.ts +1 -0
- package/dist/components/Library/GlowEffect/index.js +1 -0
- package/dist/components/Library/NavigationStack/NavigationStack.svelte +242 -0
- package/dist/components/Library/NavigationStack/NavigationStack.svelte.d.ts +15 -0
- package/dist/components/Library/NavigationStack/SidebarToggle.svelte +52 -0
- package/dist/components/Library/NavigationStack/SidebarToggle.svelte.d.ts +10 -0
- package/dist/components/Library/NavigationStack/Toolbar.svelte +59 -0
- package/dist/components/Library/NavigationStack/Toolbar.svelte.d.ts +11 -0
- package/dist/components/{Pagination.demo.svelte → Library/Pagination/Pagination.demo.svelte} +0 -1
- package/dist/components/{Pagination.demo.svelte.d.ts → Library/Pagination/Pagination.demo.svelte.d.ts} +0 -1
- package/dist/components/Library/Pagination/Pagination.svelte +227 -0
- package/dist/components/{Pagination.svelte.d.ts → Library/Pagination/Pagination.svelte.d.ts} +3 -3
- package/dist/components/Library/Pagination/index.d.ts +1 -0
- package/dist/components/Library/Pagination/index.js +1 -0
- package/dist/components/Library/Popover/Popover.demo.svelte +21 -0
- package/dist/components/Library/Popover/Popover.svelte +92 -0
- package/dist/components/Library/Popover/Popover.svelte.d.ts +14 -0
- package/dist/components/{Popover → Library/Popover}/PopoverDebugOverlay.svelte +1 -1
- package/dist/components/Library/Popover/index.d.ts +1 -0
- package/dist/components/Library/Popover/index.js +1 -0
- package/dist/components/Library/ScrollView/ScrollView.svelte +89 -0
- package/dist/components/Library/ScrollView/ScrollView.svelte.d.ts +12 -0
- package/dist/components/Library/ScrollView/index.d.ts +1 -0
- package/dist/components/Library/ScrollView/index.js +1 -0
- package/dist/components/{SearchInput.demo.svelte → Library/SearchInput/SearchInput.demo.svelte} +2 -3
- package/dist/components/{SearchInput.demo.svelte.d.ts → Library/SearchInput/SearchInput.demo.svelte.d.ts} +0 -1
- package/dist/components/Library/SearchInput/SearchInput.svelte +88 -0
- package/dist/components/{SearchInput.svelte.d.ts → Library/SearchInput/SearchInput.svelte.d.ts} +3 -3
- package/dist/components/Library/SearchInput/index.d.ts +1 -0
- package/dist/components/Library/SearchInput/index.js +1 -0
- package/dist/components/{SegmentedPicker.demo.svelte → Library/SegmentedPicker/SegmentedPicker.demo.svelte} +1 -2
- package/dist/components/{SegmentedPicker.demo.svelte.d.ts → Library/SegmentedPicker/SegmentedPicker.demo.svelte.d.ts} +0 -1
- package/dist/components/Library/SegmentedPicker/SegmentedPicker.svelte +106 -0
- package/dist/components/{SegmentedPicker.svelte.d.ts → Library/SegmentedPicker/SegmentedPicker.svelte.d.ts} +2 -2
- package/dist/components/Library/SegmentedPicker/index.d.ts +1 -0
- package/dist/components/Library/SegmentedPicker/index.js +1 -0
- package/dist/components/{Sheet → Library/Sheet}/Sheet.demo.svelte +4 -17
- package/dist/components/Library/Sheet/Sheet.demo.svelte.d.ts +23 -0
- package/dist/components/Library/Sheet/Sheet.svelte +113 -0
- package/dist/components/{Sheet → Library/Sheet}/Sheet.svelte.d.ts +4 -2
- package/dist/components/{Slider.demo.svelte → Library/Slider/Slider.demo.svelte} +2 -3
- package/dist/components/{Slider.demo.svelte.d.ts → Library/Slider/Slider.demo.svelte.d.ts} +0 -1
- package/dist/components/Library/Slider/Slider.svelte +122 -0
- package/dist/components/{Slider.svelte.d.ts → Library/Slider/Slider.svelte.d.ts} +2 -3
- package/dist/components/Library/Slider/index.d.ts +1 -0
- package/dist/components/Library/Slider/index.js +1 -0
- package/dist/components/{Spinner.demo.svelte → Library/Spinner/Spinner.demo.svelte} +3 -1
- package/dist/components/Library/Spinner/Spinner.svelte +32 -0
- package/dist/components/{Spinner.svelte.d.ts → Library/Spinner/Spinner.svelte.d.ts} +3 -2
- package/dist/components/Library/Spinner/index.d.ts +1 -0
- package/dist/components/Library/Spinner/index.js +1 -0
- package/dist/components/Library/Switch/Switch.demo.svelte +20 -0
- package/dist/components/Library/Switch/Switch.demo.svelte.d.ts +8 -0
- package/dist/components/Library/Switch/Switch.svelte +168 -0
- package/dist/components/Library/Switch/Switch.svelte.d.ts +11 -0
- package/dist/components/Library/Switch/index.d.ts +1 -0
- package/dist/components/Library/Switch/index.js +1 -0
- package/dist/components/Library/TextShimmer/TextShimmer.demo.svelte +14 -0
- package/dist/components/Library/TextShimmer/TextShimmer.demo.svelte.d.ts +23 -0
- package/dist/components/Library/TextShimmer/TextShimmer.svelte +88 -0
- package/dist/components/Library/TextShimmer/TextShimmer.svelte.d.ts +11 -0
- package/dist/components/Library/TextShimmer/index.d.ts +1 -0
- package/dist/components/Library/TextShimmer/index.js +1 -0
- package/dist/components/Library/TimePicker/TimePicker.demo.svelte +18 -0
- package/dist/components/Library/TimePicker/TimePicker.demo.svelte.d.ts +10 -0
- package/dist/components/Library/TimePicker/TimePicker.svelte +143 -0
- package/dist/components/Library/TimePicker/TimePicker.svelte.d.ts +13 -0
- package/dist/components/Library/TimePicker/index.d.ts +2 -0
- package/dist/components/Library/TimePicker/index.js +1 -0
- package/dist/components/{TokenSearchInput.demo.svelte → Library/TokenSearchInput/TokenSearchInput.demo.svelte} +1 -2
- package/dist/components/{TokenSearchInput.demo.svelte.d.ts → Library/TokenSearchInput/TokenSearchInput.demo.svelte.d.ts} +0 -1
- package/dist/components/Library/TokenSearchInput/TokenSearchInput.svelte +230 -0
- package/dist/components/{TokenSearchInput.svelte.d.ts → Library/TokenSearchInput/TokenSearchInput.svelte.d.ts} +2 -3
- package/dist/components/Library/TokenSearchInput/index.d.ts +1 -0
- package/dist/components/Library/TokenSearchInput/index.js +1 -0
- package/dist/components/Library/Tooltip/Tooltip.demo.svelte +14 -0
- package/dist/components/{Tooltip.demo.svelte.d.ts → Library/Tooltip/Tooltip.demo.svelte.d.ts} +0 -1
- package/dist/components/Library/Tooltip/index.d.ts +2 -0
- package/dist/components/Library/Tooltip/index.js +1 -0
- package/dist/components/Library/WheelPicker/WheelColumn.svelte +302 -0
- package/dist/components/Library/WheelPicker/WheelColumn.svelte.d.ts +29 -0
- package/dist/components/Library/WheelPicker/WheelPicker.svelte +114 -0
- package/dist/components/Library/WheelPicker/WheelPicker.svelte.d.ts +9 -0
- package/dist/components/Library/WheelPicker/index.d.ts +2 -0
- package/dist/components/Library/WheelPicker/index.js +1 -0
- package/dist/components/Library/WheelPicker/types.d.ts +10 -0
- package/dist/components/Library/WheelPicker/types.js +1 -0
- package/dist/components/Local/ComponentGrid.svelte +7 -6
- package/dist/components/Local/ComponentGrid.svelte.d.ts +1 -1
- package/dist/components/Local/HeroCard.svelte +18 -8
- package/dist/components/Local/HeroCard.svelte.d.ts +1 -1
- package/dist/components/Local/StyleControls.svelte +119 -0
- package/dist/components/Local/StyleControls.svelte.d.ts +15 -0
- package/dist/index.d.ts +24 -15
- package/dist/index.js +23 -15
- package/dist/style/index.css +61 -325
- package/dist/style/surface.d.ts +17 -0
- package/dist/style/surface.js +54 -0
- package/dist/style.css +86 -601
- package/dist/utils/positioning.d.ts +3 -2
- package/dist/utils/positioning.js +9 -5
- package/package.json +1 -1
- package/dist/components/AnimatedNumber.svelte +0 -18
- package/dist/components/AnimatedNumber.svelte.d.ts +0 -8
- package/dist/components/AsyncButton.svelte +0 -93
- package/dist/components/NavigationStack/NavigationStack.svelte +0 -76
- package/dist/components/NavigationStack/NavigationStack.svelte.d.ts +0 -10
- package/dist/components/NavigationStack/SidebarToggle.svelte +0 -36
- package/dist/components/NavigationStack/SidebarToggle.svelte.d.ts +0 -9
- package/dist/components/NavigationStack/Toolbar.svelte +0 -25
- package/dist/components/NavigationStack/Toolbar.svelte.d.ts +0 -9
- package/dist/components/Pagination.svelte +0 -144
- package/dist/components/Popover/Popover.demo.svelte +0 -35
- package/dist/components/Popover/Popover.svelte.d.ts +0 -13
- package/dist/components/Popover/index.d.ts +0 -2
- package/dist/components/Popover/index.js +0 -2
- package/dist/components/Popover/registry.svelte.d.ts +0 -18
- package/dist/components/SearchInput.svelte +0 -39
- package/dist/components/SegmentedPicker.svelte +0 -51
- package/dist/components/Sheet/Sheet.demo.svelte.d.ts +0 -8
- package/dist/components/Sheet/Sheet.svelte +0 -60
- package/dist/components/Slider.svelte +0 -47
- package/dist/components/Spinner.svelte +0 -7
- package/dist/components/TextShimmer.svelte +0 -60
- package/dist/components/TextShimmer.svelte.d.ts +0 -10
- package/dist/components/TokenSearchInput.svelte +0 -124
- package/dist/components/Tooltip.demo.svelte +0 -16
- package/dist/components/Tooltip.svelte +0 -79
- package/dist/components/Tooltip.svelte.d.ts +0 -12
- /package/dist/components/{AsyncButton.demo.svelte.d.ts → Library/AsyncButton/AsyncButton.demo.svelte.d.ts} +0 -0
- /package/dist/components/{NavigationStack → Library/NavigationStack}/index.d.ts +0 -0
- /package/dist/components/{NavigationStack → Library/NavigationStack}/index.js +0 -0
- /package/dist/components/{Popover → Library/Popover}/Popover.demo.svelte.d.ts +0 -0
- /package/dist/components/{Popover → Library/Popover}/PopoverDebugOverlay.svelte.d.ts +0 -0
- /package/dist/components/{Sheet → Library/Sheet}/index.d.ts +0 -0
- /package/dist/components/{Sheet → Library/Sheet}/index.js +0 -0
- /package/dist/components/{Spinner.demo.svelte.d.ts → Library/Spinner/Spinner.demo.svelte.d.ts} +0 -0
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Component, Snippet } from 'svelte';
|
|
3
|
+
import type { HTMLButtonAttributes } from 'svelte/elements';
|
|
4
|
+
import { extractStyleProps, surfaceStyle, type StyleProps } from '../../../style/surface';
|
|
5
|
+
|
|
6
|
+
type Props = {
|
|
7
|
+
children?: Snippet;
|
|
8
|
+
label?: string;
|
|
9
|
+
icon?: Component<{ class?: string; size?: number | string }>;
|
|
10
|
+
iconSize?: number | string;
|
|
11
|
+
iconColor?: string;
|
|
12
|
+
variant?: 'default' | 'solid' | 'ghost';
|
|
13
|
+
} & StyleProps & Omit<HTMLButtonAttributes, 'children' | 'class' | 'style'>;
|
|
14
|
+
|
|
15
|
+
let {
|
|
16
|
+
children,
|
|
17
|
+
label,
|
|
18
|
+
icon,
|
|
19
|
+
iconSize,
|
|
20
|
+
iconColor,
|
|
21
|
+
variant = 'default',
|
|
22
|
+
disabled = false,
|
|
23
|
+
type = 'button',
|
|
24
|
+
...restProps
|
|
25
|
+
}: Props = $props();
|
|
26
|
+
|
|
27
|
+
const extractedStyleProps = $derived.by(() => extractStyleProps(restProps));
|
|
28
|
+
const styleProps = $derived(extractedStyleProps.styleProps);
|
|
29
|
+
const props = $derived(extractedStyleProps.restProps);
|
|
30
|
+
|
|
31
|
+
const toRem = (value: number | string | undefined) =>
|
|
32
|
+
value === undefined ? undefined : typeof value === 'number' ? `${value}rem` : value;
|
|
33
|
+
|
|
34
|
+
const rootStyle = $derived.by(() => surfaceStyle(styleProps, 'button'));
|
|
35
|
+
const iconStyle = $derived.by(() => {
|
|
36
|
+
const declarations: string[] = [];
|
|
37
|
+
if (iconColor !== undefined) {
|
|
38
|
+
declarations.push(`color: ${iconColor};`);
|
|
39
|
+
}
|
|
40
|
+
if (iconSize !== undefined) {
|
|
41
|
+
const size = toRem(iconSize);
|
|
42
|
+
declarations.push(`width: ${size};`, `height: ${size};`);
|
|
43
|
+
}
|
|
44
|
+
return declarations.join(' ');
|
|
45
|
+
});
|
|
46
|
+
const iconOnly = $derived(!children && !label);
|
|
47
|
+
</script>
|
|
48
|
+
|
|
49
|
+
<button
|
|
50
|
+
{type}
|
|
51
|
+
class="button inline-flex items-center justify-center disabled:cursor-not-allowed disabled:opacity-50 {iconOnly
|
|
52
|
+
? 'button-icon-only'
|
|
53
|
+
: ''}"
|
|
54
|
+
data-variant={variant}
|
|
55
|
+
style={rootStyle}
|
|
56
|
+
{disabled}
|
|
57
|
+
{...props}
|
|
58
|
+
>
|
|
59
|
+
{#if icon}
|
|
60
|
+
{@const Icon = icon}
|
|
61
|
+
<span class="button-icon-frame inline-grid shrink-0 place-items-center" style={iconStyle}>
|
|
62
|
+
<Icon class="button-icon" />
|
|
63
|
+
</span>
|
|
64
|
+
{/if}
|
|
65
|
+
|
|
66
|
+
{#if children}
|
|
67
|
+
{@render children()}
|
|
68
|
+
{:else if label}
|
|
69
|
+
<span>{label}</span>
|
|
70
|
+
{/if}
|
|
71
|
+
</button>
|
|
72
|
+
|
|
73
|
+
<style>
|
|
74
|
+
.button {
|
|
75
|
+
--button-font-size: var(--sveltely-font-size);
|
|
76
|
+
--button-scale: calc(var(--button-font-size) / 1rem);
|
|
77
|
+
--button-icon-size: calc(var(--button-font-size) * 1.143);
|
|
78
|
+
border: 1px solid var(--button-border-color, var(--sveltely-border-color));
|
|
79
|
+
border-radius: var(--button-border-radius, var(--sveltely-border-radius));
|
|
80
|
+
background: var(--button-background, white);
|
|
81
|
+
color: var(--button-color, var(--color-zinc-800));
|
|
82
|
+
gap: var(--button-gap, var(--sveltely-gap));
|
|
83
|
+
font-size: var(--button-font-size);
|
|
84
|
+
line-height: 1.25;
|
|
85
|
+
padding:
|
|
86
|
+
var(--button-padding-y, calc(var(--sveltely-padding-y) * 0.67 * var(--button-scale)))
|
|
87
|
+
var(--button-padding-x, calc(var(--sveltely-padding-x) * var(--button-scale)));
|
|
88
|
+
transition: color 150ms, border-color 150ms, background-color 150ms;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
.button[data-variant='default']:hover {
|
|
92
|
+
background: var(--button-hover-background, var(--sveltely-hover-color));
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.button[data-variant='solid'] {
|
|
96
|
+
border-color: var(--button-solid-border-color, var(--sveltely-primary-color));
|
|
97
|
+
background: var(--button-solid-background, var(--sveltely-primary-color));
|
|
98
|
+
color: var(--button-solid-color, white);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
.button[data-variant='solid']:hover {
|
|
102
|
+
background: var(--button-solid-hover-background, var(--sveltely-active-hover-color));
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
.button[data-variant='ghost'] {
|
|
106
|
+
border-color: transparent;
|
|
107
|
+
background: transparent;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
.button[data-variant='ghost']:hover {
|
|
111
|
+
background: var(--button-ghost-hover-background, var(--sveltely-hover-color));
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
.button-icon-only {
|
|
115
|
+
padding:
|
|
116
|
+
var(--button-padding-y, calc(var(--sveltely-padding-y) * 0.67 * var(--button-scale)))
|
|
117
|
+
var(--button-padding-x, calc(var(--sveltely-padding-x) * 0.67 * var(--button-scale)));
|
|
118
|
+
min-width: calc((var(--button-padding-x, calc(var(--sveltely-padding-x) * 0.67 * var(--button-scale))) * 2) + 1rem);
|
|
119
|
+
min-height: calc((var(--button-padding-y, calc(var(--sveltely-padding-y) * 0.67 * var(--button-scale))) * 2) + 1rem);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
.button-icon-frame {
|
|
123
|
+
display: inline-flex;
|
|
124
|
+
align-items: center;
|
|
125
|
+
justify-content: center;
|
|
126
|
+
width: var(--button-icon-size);
|
|
127
|
+
height: var(--button-icon-size);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
.button-icon {
|
|
131
|
+
width: 100%;
|
|
132
|
+
height: 100%;
|
|
133
|
+
}
|
|
134
|
+
</style>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Component, Snippet } from 'svelte';
|
|
2
|
+
import type { HTMLButtonAttributes } from 'svelte/elements';
|
|
3
|
+
import { type StyleProps } from '../../../style/surface';
|
|
4
|
+
type Props = {
|
|
5
|
+
children?: Snippet;
|
|
6
|
+
label?: string;
|
|
7
|
+
icon?: Component<{
|
|
8
|
+
class?: string;
|
|
9
|
+
size?: number | string;
|
|
10
|
+
}>;
|
|
11
|
+
iconSize?: number | string;
|
|
12
|
+
iconColor?: string;
|
|
13
|
+
variant?: 'default' | 'solid' | 'ghost';
|
|
14
|
+
} & StyleProps & Omit<HTMLButtonAttributes, 'children' | 'class' | 'style'>;
|
|
15
|
+
declare const Button: Component<Props, {}, "">;
|
|
16
|
+
type Button = ReturnType<typeof Button>;
|
|
17
|
+
export default Button;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './Button.svelte';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './Button.svelte';
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
export const demo = {
|
|
3
|
+
name: 'Calendar',
|
|
4
|
+
description: 'Compact month calendar with token-driven spacing and radius.',
|
|
5
|
+
columnSpan: 2,
|
|
6
|
+
rowSpan: 2
|
|
7
|
+
};
|
|
8
|
+
</script>
|
|
9
|
+
|
|
10
|
+
<script lang="ts">
|
|
11
|
+
import Calendar from './Calendar.svelte';
|
|
12
|
+
|
|
13
|
+
let value = $state<Date | null>(new Date());
|
|
14
|
+
let month = $state(new Date());
|
|
15
|
+
let weekStart = $state<'monday' | 'sunday'>('monday');
|
|
16
|
+
</script>
|
|
17
|
+
|
|
18
|
+
<div class="vstack gap-2">
|
|
19
|
+
<div class="hstack gap-2">
|
|
20
|
+
<button type="button" onclick={() => (weekStart = 'monday')}>Monday start</button>
|
|
21
|
+
<button type="button" onclick={() => (weekStart = 'sunday')}>Sunday start</button>
|
|
22
|
+
</div>
|
|
23
|
+
<Calendar bind:value bind:month {weekStart} />
|
|
24
|
+
<p class="text-xs text-zinc-500">
|
|
25
|
+
Selected: {value ? value.toLocaleDateString() : 'none'} | Month: {month.toLocaleDateString(undefined, {
|
|
26
|
+
month: 'long',
|
|
27
|
+
year: 'numeric'
|
|
28
|
+
})} | Week starts: {weekStart}
|
|
29
|
+
</p>
|
|
30
|
+
</div>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare const demo: {
|
|
2
|
+
name: string;
|
|
3
|
+
description: string;
|
|
4
|
+
columnSpan: number;
|
|
5
|
+
rowSpan: number;
|
|
6
|
+
};
|
|
7
|
+
import Calendar from './Calendar.svelte';
|
|
8
|
+
declare const Calendar: import("svelte").Component<Record<string, never>, {}, "">;
|
|
9
|
+
type Calendar = ReturnType<typeof Calendar>;
|
|
10
|
+
export default Calendar;
|
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { ChevronLeftIcon, ChevronRightIcon } from '@lucide/svelte';
|
|
3
|
+
import { extractStyleProps, surfaceStyle, type StyleProps } from '../../../style/surface';
|
|
4
|
+
|
|
5
|
+
const startOfDay = (value: Date) =>
|
|
6
|
+
new Date(value.getFullYear(), value.getMonth(), value.getDate());
|
|
7
|
+
|
|
8
|
+
const startOfMonth = (value: Date) =>
|
|
9
|
+
new Date(value.getFullYear(), value.getMonth(), 1);
|
|
10
|
+
|
|
11
|
+
type CalendarCell = {
|
|
12
|
+
key: string;
|
|
13
|
+
label: string;
|
|
14
|
+
isCurrentMonth: boolean;
|
|
15
|
+
isToday: boolean;
|
|
16
|
+
isWeekend: boolean;
|
|
17
|
+
value?: Date;
|
|
18
|
+
isSelected: boolean;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
type Props = {
|
|
22
|
+
value?: Date | null;
|
|
23
|
+
month?: Date;
|
|
24
|
+
weekdayLabels?: string[];
|
|
25
|
+
weekStart?: 'monday' | 'sunday';
|
|
26
|
+
} & StyleProps & Record<string, unknown>;
|
|
27
|
+
|
|
28
|
+
const defaultWeekdayLabels = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'];
|
|
29
|
+
const today = new Date();
|
|
30
|
+
|
|
31
|
+
let {
|
|
32
|
+
value = $bindable<Date | null>(startOfDay(today)),
|
|
33
|
+
month = $bindable<Date>(startOfMonth(today)),
|
|
34
|
+
weekdayLabels = defaultWeekdayLabels,
|
|
35
|
+
weekStart = 'monday',
|
|
36
|
+
...restProps
|
|
37
|
+
}: Props = $props();
|
|
38
|
+
|
|
39
|
+
const extractedStyleProps = $derived.by(() => extractStyleProps(restProps));
|
|
40
|
+
const styleProps = $derived(extractedStyleProps.styleProps);
|
|
41
|
+
const props = $derived(extractedStyleProps.restProps);
|
|
42
|
+
const rootStyle = $derived.by(() => surfaceStyle(styleProps, 'calendar'));
|
|
43
|
+
|
|
44
|
+
const orderedWeekdayLabels = $derived(
|
|
45
|
+
weekStart === 'sunday'
|
|
46
|
+
? [weekdayLabels[6], ...weekdayLabels.slice(0, 6)]
|
|
47
|
+
: weekdayLabels
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
const weekendColumnIndexes = $derived(
|
|
51
|
+
weekStart === 'sunday' ? [0, 6] : [5, 6]
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
function shiftMonth(offset: number) {
|
|
55
|
+
month = new Date(month.getFullYear(), month.getMonth() + offset, 1);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function selectDate(nextValue: Date) {
|
|
59
|
+
value = startOfDay(nextValue);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const displayYear = $derived(month.getFullYear());
|
|
63
|
+
const displayMonth = $derived(month.getMonth());
|
|
64
|
+
const todayYear = today.getFullYear();
|
|
65
|
+
const todayMonth = today.getMonth();
|
|
66
|
+
const todayDate = today.getDate();
|
|
67
|
+
|
|
68
|
+
const monthLabel = $derived(
|
|
69
|
+
month.toLocaleDateString(undefined, {
|
|
70
|
+
month: 'long',
|
|
71
|
+
year: 'numeric'
|
|
72
|
+
})
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
const cells = $derived.by(() => {
|
|
76
|
+
const firstDay = new Date(displayYear, displayMonth, 1);
|
|
77
|
+
const daysInMonth = new Date(displayYear, displayMonth + 1, 0).getDate();
|
|
78
|
+
const leadingEmptyDays =
|
|
79
|
+
weekStart === 'sunday' ? firstDay.getDay() : (firstDay.getDay() + 6) % 7;
|
|
80
|
+
|
|
81
|
+
return Array.from({ length: leadingEmptyDays + daysInMonth }, (_, index): CalendarCell => {
|
|
82
|
+
const dayNumber = index - leadingEmptyDays + 1;
|
|
83
|
+
if (dayNumber < 1) {
|
|
84
|
+
return {
|
|
85
|
+
key: `empty-${index}`,
|
|
86
|
+
label: '',
|
|
87
|
+
isCurrentMonth: false,
|
|
88
|
+
isToday: false,
|
|
89
|
+
isWeekend: false,
|
|
90
|
+
isSelected: false
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const cellDate = new Date(displayYear, displayMonth, dayNumber);
|
|
95
|
+
const dayOfWeek = cellDate.getDay();
|
|
96
|
+
|
|
97
|
+
return {
|
|
98
|
+
key: `day-${dayNumber}`,
|
|
99
|
+
label: String(dayNumber),
|
|
100
|
+
isCurrentMonth: true,
|
|
101
|
+
value: cellDate,
|
|
102
|
+
isToday:
|
|
103
|
+
displayYear === todayYear &&
|
|
104
|
+
displayMonth === todayMonth &&
|
|
105
|
+
dayNumber === todayDate,
|
|
106
|
+
isWeekend: dayOfWeek === 0 || dayOfWeek === 6,
|
|
107
|
+
isSelected:
|
|
108
|
+
value !== null &&
|
|
109
|
+
cellDate.getFullYear() === value.getFullYear() &&
|
|
110
|
+
cellDate.getMonth() === value.getMonth() &&
|
|
111
|
+
cellDate.getDate() === value.getDate()
|
|
112
|
+
};
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
</script>
|
|
116
|
+
|
|
117
|
+
<div class="calendar vstack" style={rootStyle} {...props}>
|
|
118
|
+
<div class="calendar-grid">
|
|
119
|
+
<button class="calendar-nav-button" type="button" aria-label="Previous month" onclick={() => shiftMonth(-1)}>
|
|
120
|
+
<ChevronLeftIcon class="calendar-nav-icon" strokeWidth={2} />
|
|
121
|
+
</button>
|
|
122
|
+
<div class="calendar-title-cell">
|
|
123
|
+
<h2 class="calendar-title">{monthLabel}</h2>
|
|
124
|
+
</div>
|
|
125
|
+
<button class="calendar-nav-button" type="button" aria-label="Next month" onclick={() => shiftMonth(1)}>
|
|
126
|
+
<ChevronRightIcon class="calendar-nav-icon" strokeWidth={2} />
|
|
127
|
+
</button>
|
|
128
|
+
{#each orderedWeekdayLabels as weekday, index}
|
|
129
|
+
<div
|
|
130
|
+
class="calendar-weekday"
|
|
131
|
+
class:calendar-weekday-weekend={weekendColumnIndexes.includes(index)}
|
|
132
|
+
>
|
|
133
|
+
{weekday}
|
|
134
|
+
</div>
|
|
135
|
+
{/each}
|
|
136
|
+
|
|
137
|
+
{#each cells as cell (cell.key)}
|
|
138
|
+
{#if cell.isCurrentMonth && cell.value}
|
|
139
|
+
<button
|
|
140
|
+
type="button"
|
|
141
|
+
class="calendar-day"
|
|
142
|
+
class:calendar-day-today={cell.isToday}
|
|
143
|
+
class:calendar-day-selected={cell.isSelected}
|
|
144
|
+
class:calendar-day-weekend={cell.isWeekend}
|
|
145
|
+
aria-pressed={cell.isSelected}
|
|
146
|
+
onclick={() => selectDate(cell.value!)}
|
|
147
|
+
>
|
|
148
|
+
{cell.label}
|
|
149
|
+
</button>
|
|
150
|
+
{:else}
|
|
151
|
+
<div class="calendar-day calendar-day-empty">
|
|
152
|
+
{cell.label}
|
|
153
|
+
</div>
|
|
154
|
+
{/if}
|
|
155
|
+
{/each}
|
|
156
|
+
</div>
|
|
157
|
+
</div>
|
|
158
|
+
|
|
159
|
+
<style>
|
|
160
|
+
.calendar {
|
|
161
|
+
--calendar-font-size: calc(var(--sveltely-font-size) * 0.971);
|
|
162
|
+
--calendar-scale: calc(var(--calendar-font-size) / 1rem);
|
|
163
|
+
--calendar-cell-core-size: max(2ch, calc(2ch * var(--calendar-scale)));
|
|
164
|
+
--calendar-weekend-color: var(--color-zinc-500);
|
|
165
|
+
--calendar-weekend-header-color: var(--color-zinc-400);
|
|
166
|
+
--calendar-weekend-selected-color: white;
|
|
167
|
+
--calendar-cell-width: calc(var(--calendar-cell-core-size) + (var(--sveltely-padding-x) * 2.2));
|
|
168
|
+
--calendar-cell-height: calc(var(--calendar-cell-core-size) + (var(--sveltely-padding-y) * 2.2));
|
|
169
|
+
--calendar-title-size: calc(var(--calendar-font-size) * 1.03);
|
|
170
|
+
--calendar-weekday-size: calc(var(--calendar-font-size) * 0.75);
|
|
171
|
+
font-size: var(--calendar-font-size);
|
|
172
|
+
gap: calc(var(--sveltely-gap) * 1.25);
|
|
173
|
+
width: fit-content;
|
|
174
|
+
max-width: 100%;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
.calendar-title-cell {
|
|
178
|
+
grid-column: span 5;
|
|
179
|
+
display: flex;
|
|
180
|
+
align-items: center;
|
|
181
|
+
justify-content: center;
|
|
182
|
+
height: 100%;
|
|
183
|
+
text-align: center;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
.calendar-title {
|
|
187
|
+
margin: 0;
|
|
188
|
+
font-size: var(--calendar-title-size);
|
|
189
|
+
line-height: 1.4;
|
|
190
|
+
font-weight: 600;
|
|
191
|
+
color: var(--color-zinc-900);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
.calendar-nav-button {
|
|
195
|
+
box-sizing: border-box;
|
|
196
|
+
display: inline-flex;
|
|
197
|
+
flex: 0 0 var(--calendar-cell-width);
|
|
198
|
+
align-items: center;
|
|
199
|
+
justify-content: center;
|
|
200
|
+
width: var(--calendar-cell-width);
|
|
201
|
+
min-width: var(--calendar-cell-width);
|
|
202
|
+
max-width: var(--calendar-cell-width);
|
|
203
|
+
height: var(--calendar-cell-height);
|
|
204
|
+
min-height: var(--calendar-cell-height);
|
|
205
|
+
max-height: var(--calendar-cell-height);
|
|
206
|
+
border: 1px solid color-mix(in oklab, var(--sveltely-border-color) 75%, white);
|
|
207
|
+
border-radius: var(--sveltely-border-radius);
|
|
208
|
+
background: color-mix(in oklab, white 92%, var(--color-zinc-100));
|
|
209
|
+
padding: 0;
|
|
210
|
+
color: var(--color-zinc-600);
|
|
211
|
+
cursor: pointer;
|
|
212
|
+
appearance: none;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
.calendar-nav-button:focus-visible {
|
|
216
|
+
outline: 2px solid color-mix(in oklab, var(--sveltely-primary-color) 24%, white);
|
|
217
|
+
outline-offset: 2px;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
.calendar-nav-button:hover {
|
|
221
|
+
background: var(--sveltely-hover-color);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
.calendar-nav-icon {
|
|
225
|
+
width: calc(var(--calendar-font-size) * 1.143);
|
|
226
|
+
height: calc(var(--calendar-font-size) * 1.143);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
.calendar-grid {
|
|
230
|
+
display: grid;
|
|
231
|
+
grid-template-columns: repeat(7, var(--calendar-cell-width));
|
|
232
|
+
grid-auto-rows: var(--calendar-cell-height);
|
|
233
|
+
gap: calc(var(--sveltely-gap) * 0.5);
|
|
234
|
+
align-items: stretch;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
.calendar-weekday {
|
|
238
|
+
box-sizing: border-box;
|
|
239
|
+
display: flex;
|
|
240
|
+
align-items: center;
|
|
241
|
+
justify-content: center;
|
|
242
|
+
width: 100%;
|
|
243
|
+
height: 100%;
|
|
244
|
+
padding: 0;
|
|
245
|
+
font-size: var(--calendar-weekday-size);
|
|
246
|
+
line-height: 1;
|
|
247
|
+
text-align: center;
|
|
248
|
+
color: var(--color-zinc-500);
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
.calendar-weekday-weekend {
|
|
252
|
+
color: var(--calendar-weekend-header-color);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
.calendar-day {
|
|
256
|
+
box-sizing: border-box;
|
|
257
|
+
display: flex;
|
|
258
|
+
align-items: center;
|
|
259
|
+
justify-content: center;
|
|
260
|
+
width: 100%;
|
|
261
|
+
height: 100%;
|
|
262
|
+
border: 1px solid color-mix(in oklab, var(--sveltely-border-color) 75%, white);
|
|
263
|
+
border-radius: var(--sveltely-border-radius);
|
|
264
|
+
background: color-mix(in oklab, white 92%, var(--color-zinc-100));
|
|
265
|
+
padding: 0;
|
|
266
|
+
font-size: calc(var(--calendar-font-size) * 0.85);
|
|
267
|
+
line-height: 1;
|
|
268
|
+
color: var(--color-zinc-700);
|
|
269
|
+
cursor: pointer;
|
|
270
|
+
appearance: none;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
.calendar-day-weekend {
|
|
274
|
+
color: var(--calendar-weekend-color);
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
.calendar-day:focus-visible {
|
|
278
|
+
outline: 2px solid color-mix(in oklab, var(--sveltely-primary-color) 24%, white);
|
|
279
|
+
outline-offset: 2px;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
.calendar-day:hover {
|
|
283
|
+
background: var(--sveltely-hover-color);
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
.calendar-day-empty {
|
|
287
|
+
border-color: transparent;
|
|
288
|
+
background: transparent;
|
|
289
|
+
color: transparent;
|
|
290
|
+
cursor: default;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
.calendar-day-today {
|
|
294
|
+
border-color: color-mix(in oklab, var(--sveltely-primary-color) 18%, white);
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
.calendar-day-selected {
|
|
298
|
+
border-color: var(--sveltely-primary-color);
|
|
299
|
+
background: var(--sveltely-primary-color);
|
|
300
|
+
color: white;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
.calendar-day-selected:hover {
|
|
304
|
+
background: var(--sveltely-active-hover-color);
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
.calendar-day-selected.calendar-day-weekend {
|
|
308
|
+
color: var(--calendar-weekend-selected-color);
|
|
309
|
+
}
|
|
310
|
+
</style>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type StyleProps } from '../../../style/surface';
|
|
2
|
+
type Props = {
|
|
3
|
+
value?: Date | null;
|
|
4
|
+
month?: Date;
|
|
5
|
+
weekdayLabels?: string[];
|
|
6
|
+
weekStart?: 'monday' | 'sunday';
|
|
7
|
+
} & StyleProps & Record<string, unknown>;
|
|
8
|
+
declare const Calendar: import("svelte").Component<Props, {}, "value" | "month">;
|
|
9
|
+
type Calendar = ReturnType<typeof Calendar>;
|
|
10
|
+
export default Calendar;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './Calendar.svelte';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './Calendar.svelte';
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
export const demo = {
|
|
3
|
+
name: 'Checkbox',
|
|
4
|
+
description: 'Token-driven checkbox with bindable checked state.'
|
|
5
|
+
};
|
|
6
|
+
</script>
|
|
7
|
+
|
|
8
|
+
<script lang="ts">
|
|
9
|
+
import Checkbox from './Checkbox.svelte';
|
|
10
|
+
|
|
11
|
+
let notificationsEnabled = $state(true);
|
|
12
|
+
let weeklySummaryEnabled = $state(false);
|
|
13
|
+
</script>
|
|
14
|
+
|
|
15
|
+
<div class="vstack gap-3">
|
|
16
|
+
<Checkbox bind:checked={notificationsEnabled} label="Enable notifications" />
|
|
17
|
+
<Checkbox bind:checked={weeklySummaryEnabled}>
|
|
18
|
+
<span>Send weekly summary email</span>
|
|
19
|
+
</Checkbox>
|
|
20
|
+
</div>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const demo: {
|
|
2
|
+
name: string;
|
|
3
|
+
description: string;
|
|
4
|
+
};
|
|
5
|
+
import Checkbox from './Checkbox.svelte';
|
|
6
|
+
declare const Checkbox: import("svelte").Component<Record<string, never>, {}, "">;
|
|
7
|
+
type Checkbox = ReturnType<typeof Checkbox>;
|
|
8
|
+
export default Checkbox;
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { CheckIcon } from '@lucide/svelte';
|
|
3
|
+
import type { Snippet } from 'svelte';
|
|
4
|
+
import type { HTMLInputAttributes } from 'svelte/elements';
|
|
5
|
+
import { extractStyleProps, surfaceStyle, type StyleProps } from '../../../style/surface';
|
|
6
|
+
|
|
7
|
+
type Props = {
|
|
8
|
+
checked?: boolean;
|
|
9
|
+
label?: string;
|
|
10
|
+
children?: Snippet;
|
|
11
|
+
} & StyleProps & Omit<HTMLInputAttributes, 'type' | 'children' | 'class' | 'style' | 'checked'>;
|
|
12
|
+
|
|
13
|
+
let {
|
|
14
|
+
checked = $bindable(false),
|
|
15
|
+
label,
|
|
16
|
+
children,
|
|
17
|
+
disabled = false,
|
|
18
|
+
...restProps
|
|
19
|
+
}: Props = $props();
|
|
20
|
+
|
|
21
|
+
const extractedStyleProps = $derived.by(() => extractStyleProps(restProps));
|
|
22
|
+
const styleProps = $derived(extractedStyleProps.styleProps);
|
|
23
|
+
const props = $derived(extractedStyleProps.restProps);
|
|
24
|
+
const rootStyle = $derived.by(() => surfaceStyle(styleProps, 'checkbox'));
|
|
25
|
+
</script>
|
|
26
|
+
|
|
27
|
+
<label
|
|
28
|
+
class="checkbox inline-flex items-center"
|
|
29
|
+
style={rootStyle}
|
|
30
|
+
data-disabled={disabled ? 'true' : 'false'}
|
|
31
|
+
>
|
|
32
|
+
<span class="checkbox-control">
|
|
33
|
+
<input bind:checked type="checkbox" {disabled} {...props} />
|
|
34
|
+
<span class="checkbox-mark" aria-hidden="true">
|
|
35
|
+
<CheckIcon class="checkbox-icon" />
|
|
36
|
+
</span>
|
|
37
|
+
</span>
|
|
38
|
+
|
|
39
|
+
{#if children || label}
|
|
40
|
+
<span class="checkbox-label">
|
|
41
|
+
{#if children}
|
|
42
|
+
{@render children()}
|
|
43
|
+
{:else if label}
|
|
44
|
+
{label}
|
|
45
|
+
{/if}
|
|
46
|
+
</span>
|
|
47
|
+
{/if}
|
|
48
|
+
</label>
|
|
49
|
+
|
|
50
|
+
<style>
|
|
51
|
+
.checkbox {
|
|
52
|
+
--checkbox-font-size: var(--sveltely-font-size);
|
|
53
|
+
--checkbox-scale: calc(var(--checkbox-font-size) / 1rem);
|
|
54
|
+
--checkbox-box-size: calc(
|
|
55
|
+
(var(--checkbox-font-size) * 0.92) + (var(--sveltely-padding-y) * 0.28 * var(--checkbox-scale))
|
|
56
|
+
);
|
|
57
|
+
--checkbox-icon-size: calc(var(--checkbox-box-size) * 0.64);
|
|
58
|
+
gap: var(--checkbox-gap, var(--sveltely-gap));
|
|
59
|
+
font-size: var(--checkbox-font-size);
|
|
60
|
+
line-height: 1.25;
|
|
61
|
+
color: var(--checkbox-color, var(--color-zinc-800));
|
|
62
|
+
cursor: pointer;
|
|
63
|
+
user-select: none;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.checkbox[data-disabled='true'] {
|
|
67
|
+
cursor: not-allowed;
|
|
68
|
+
opacity: 0.5;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.checkbox-control {
|
|
72
|
+
position: relative;
|
|
73
|
+
flex: 0 0 auto;
|
|
74
|
+
inline-size: var(--checkbox-box-size);
|
|
75
|
+
block-size: var(--checkbox-box-size);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.checkbox-control input {
|
|
79
|
+
position: absolute;
|
|
80
|
+
inset: 0;
|
|
81
|
+
margin: 0;
|
|
82
|
+
opacity: 0;
|
|
83
|
+
cursor: inherit;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.checkbox-mark {
|
|
87
|
+
inline-size: 100%;
|
|
88
|
+
block-size: 100%;
|
|
89
|
+
border: 1px solid var(--checkbox-border-color, var(--sveltely-border-color));
|
|
90
|
+
border-radius: var(--checkbox-border-radius, calc(var(--sveltely-border-radius) * 0.5));
|
|
91
|
+
background: var(--checkbox-background, var(--sveltely-inactive-color));
|
|
92
|
+
color: transparent;
|
|
93
|
+
display: inline-flex;
|
|
94
|
+
align-items: center;
|
|
95
|
+
justify-content: center;
|
|
96
|
+
transition: color 150ms, border-color 150ms, background-color 150ms;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
.checkbox:hover .checkbox-mark {
|
|
100
|
+
background: var(--checkbox-hover-background, var(--sveltely-inactive-hover-color));
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.checkbox-control input:checked + .checkbox-mark {
|
|
104
|
+
border-color: var(--checkbox-checked-border-color, var(--sveltely-active-color));
|
|
105
|
+
background: var(--checkbox-checked-background, var(--sveltely-active-color));
|
|
106
|
+
color: var(--checkbox-checked-color, white);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
.checkbox:hover .checkbox-control input:checked + .checkbox-mark {
|
|
110
|
+
background: var(
|
|
111
|
+
--checkbox-checked-hover-background,
|
|
112
|
+
var(--sveltely-active-hover-color)
|
|
113
|
+
);
|
|
114
|
+
border-color: var(
|
|
115
|
+
--checkbox-checked-hover-border-color,
|
|
116
|
+
var(--sveltely-active-hover-color)
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
.checkbox-control input:focus-visible + .checkbox-mark {
|
|
121
|
+
outline: 2px solid color-mix(in oklab, var(--sveltely-primary-color) 24%, white);
|
|
122
|
+
outline-offset: 2px;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
.checkbox-icon {
|
|
126
|
+
display: block;
|
|
127
|
+
width: var(--checkbox-icon-size);
|
|
128
|
+
height: var(--checkbox-icon-size);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
.checkbox-label {
|
|
132
|
+
min-width: 0;
|
|
133
|
+
}
|
|
134
|
+
</style>
|