@widgetic/design-system 0.5.29 → 0.5.31
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/chat/OptionRow.svelte +1 -1
- package/dist/components/chat/SuggestionCard.svelte +13 -1
- package/dist/components/chat/SuggestionCard.svelte.d.ts +5 -0
- package/dist/components/color-picker/ColorPicker.svelte +324 -0
- package/dist/components/color-picker/ColorPicker.svelte.d.ts +34 -0
- package/dist/components/color-picker/colorPickerLogic.d.ts +77 -0
- package/dist/components/color-picker/colorPickerLogic.js +184 -0
- package/dist/components/color-picker/index.d.ts +2 -0
- package/dist/components/color-picker/index.js +3 -0
- package/dist/components/font-picker/FontPicker.svelte +169 -0
- package/dist/components/font-picker/FontPicker.svelte.d.ts +41 -0
- package/dist/components/font-picker/fontPickerLogic.d.ts +21 -0
- package/dist/components/font-picker/fontPickerLogic.js +29 -0
- package/dist/components/font-picker/index.d.ts +2 -0
- package/dist/components/font-picker/index.js +3 -0
- package/dist/components/index.d.ts +3 -1
- package/dist/components/index.js +3 -1
- package/dist/components/modals/BaseModal.svelte +6 -6
- package/dist/components/shell/NotificationDetail.svelte +96 -0
- package/dist/components/shell/NotificationDetail.svelte.d.ts +28 -0
- package/dist/components/shell/NotificationRow.svelte +6 -4
- package/dist/components/shell/SettingsDialog.svelte +22 -8
- package/dist/components/shell/SettingsDialog.svelte.d.ts +5 -0
- package/dist/components/shell/SettingsNav.svelte +72 -23
- package/dist/components/shell/SettingsNav.svelte.d.ts +7 -0
- package/dist/components/shell/index.d.ts +1 -0
- package/dist/components/shell/index.js +1 -0
- package/dist/components/toast/ToasterModal.svelte +19 -29
- package/dist/components/ui/button/button.svelte +11 -9
- package/dist/components/ui/button/button.svelte.d.ts +2 -2
- package/dist/components/ui/command/command-item.svelte +1 -1
- package/dist/components/ui/command/command-link-item.svelte +1 -1
- package/dist/components/ui/dropdown-menu/dropdown-menu-checkbox-item.svelte +1 -1
- package/dist/components/ui/dropdown-menu/dropdown-menu-item.svelte +1 -1
- package/dist/components/ui/dropdown-menu/dropdown-menu-radio-item.svelte +1 -1
- package/dist/components/ui/icon-button/icon-button.svelte +7 -6
- package/dist/components/ui/icon-button/icon-button.svelte.d.ts +2 -2
- package/dist/components/ui/select/select-item.svelte +18 -7
- package/dist/components/ui/select/select-item.svelte.d.ts +8 -2
- package/dist/components/ui/slider/slider.svelte +31 -5
- package/dist/components/ui/tabs/tabs-trigger.svelte +1 -1
- package/dist/components/ui/toggle/toggle.svelte +1 -1
- package/dist/components/ui/toggle/toggle.svelte.d.ts +2 -2
- package/dist/styles/fonts.css +4 -33
- package/dist/styles/global.css +114 -20
- package/dist/styles/tokens.css +6 -10
- package/dist/utils/overlayMotion.d.ts +11 -1
- package/dist/utils/overlayMotion.js +16 -8
- package/dist/utils/toastMotion.d.ts +12 -0
- package/dist/utils/toastMotion.js +12 -0
- package/package.json +2 -2
- package/tailwind.config.ts +4 -11
- package/dist/fonts/Cousine/Cousine-Bold.woff2 +0 -0
- package/dist/fonts/Cousine/Cousine-Regular.woff2 +0 -0
|
@@ -10,37 +10,86 @@
|
|
|
10
10
|
groups: SettingsNavGroup[];
|
|
11
11
|
activeId: string;
|
|
12
12
|
onSelect?: (id: string) => void;
|
|
13
|
+
/**
|
|
14
|
+
* The menu is not known yet (the workspace the person is in is still loading, and with it what they may open): it is
|
|
15
|
+
* drawn as skeleton rows of the same size as the real ones, so that it does not grow row by row when it is known.
|
|
16
|
+
*/
|
|
17
|
+
pending?: boolean;
|
|
18
|
+
/** What a screen reader says for the menu while it is pending. */
|
|
19
|
+
pendingLabel?: string;
|
|
13
20
|
};
|
|
14
21
|
</script>
|
|
15
22
|
|
|
16
23
|
<script lang="ts">
|
|
17
24
|
import { cn } from '../../utils.js';
|
|
25
|
+
import Skeleton from '../ui/skeleton/skeleton.svelte';
|
|
18
26
|
import NavRow from './NavRow.svelte';
|
|
19
27
|
import NavSectionLabel from './NavSectionLabel.svelte';
|
|
20
28
|
import { settingsNavItemIsActive } from './settings-nav-types.js';
|
|
21
29
|
|
|
22
|
-
let {
|
|
30
|
+
let {
|
|
31
|
+
class: className,
|
|
32
|
+
groups,
|
|
33
|
+
activeId,
|
|
34
|
+
onSelect,
|
|
35
|
+
pending = false,
|
|
36
|
+
pendingLabel = 'Loading settings',
|
|
37
|
+
...restProps
|
|
38
|
+
}: SettingsNavProps = $props();
|
|
39
|
+
|
|
40
|
+
// The shape of the menu while it loads: a Workspace group of five rows and an Account group of two (what an owner sees
|
|
41
|
+
// at the least). Each row is a 16px icon and a label of its own width, on the 32px row of the real menu (Nav Row).
|
|
42
|
+
const pendingGroups: { id: string; labelWidth: string; labelWidths: string[] }[] = [
|
|
43
|
+
{ id: 'workspace', labelWidth: 'w-16', labelWidths: ['w-24', 'w-28', 'w-20', 'w-24', 'w-16'] },
|
|
44
|
+
{ id: 'account', labelWidth: 'w-14', labelWidths: ['w-20', 'w-28'] }
|
|
45
|
+
];
|
|
23
46
|
</script>
|
|
24
47
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
</
|
|
48
|
+
{#if pending}
|
|
49
|
+
<!-- Figma: Settings Nav, Loading (Skeleton rows on the Nav Row grid) -->
|
|
50
|
+
<nav
|
|
51
|
+
class={cn('flex w-full flex-col gap-0.5', className)}
|
|
52
|
+
aria-label="Settings"
|
|
53
|
+
aria-busy="true"
|
|
54
|
+
data-settings-nav-pending
|
|
55
|
+
{...restProps}
|
|
56
|
+
>
|
|
57
|
+
<span class="sr-only" role="status">{pendingLabel}</span>
|
|
58
|
+
{#each pendingGroups as group (group.id)}
|
|
59
|
+
<div class="flex flex-col gap-0.5" aria-hidden="true">
|
|
60
|
+
<div class="flex h-8 w-full min-w-0 items-center py-1 ps-3 pe-2 pb-1">
|
|
61
|
+
<Skeleton class={cn('h-3', group.labelWidth)} pulse="low" />
|
|
62
|
+
</div>
|
|
63
|
+
{#each group.labelWidths as labelWidth, rowIndex (rowIndex)}
|
|
64
|
+
<div class="flex h-8 w-full min-w-0 items-center gap-2 py-1.5 ps-2 pe-2">
|
|
65
|
+
<Skeleton class="size-4 shrink-0" />
|
|
66
|
+
<Skeleton class={cn('h-3', labelWidth)} />
|
|
67
|
+
</div>
|
|
68
|
+
{/each}
|
|
69
|
+
</div>
|
|
70
|
+
{/each}
|
|
71
|
+
</nav>
|
|
72
|
+
{:else}
|
|
73
|
+
<nav class={cn('flex w-full flex-col gap-0.5', className)} aria-label="Settings" {...restProps}>
|
|
74
|
+
{#each groups as group (group.id)}
|
|
75
|
+
<div class="flex flex-col gap-0.5">
|
|
76
|
+
<NavSectionLabel label={group.label} />
|
|
77
|
+
{#each group.items as item (item.id)}
|
|
78
|
+
{@const active = settingsNavItemIsActive(activeId, item.id)}
|
|
79
|
+
<NavRow
|
|
80
|
+
label={item.label}
|
|
81
|
+
{active}
|
|
82
|
+
showIcon={Boolean(item.icon)}
|
|
83
|
+
onclick={() => onSelect?.(item.id)}
|
|
84
|
+
>
|
|
85
|
+
{#snippet icon()}
|
|
86
|
+
{#if item.icon}
|
|
87
|
+
{@render item.icon()}
|
|
88
|
+
{/if}
|
|
89
|
+
{/snippet}
|
|
90
|
+
</NavRow>
|
|
91
|
+
{/each}
|
|
92
|
+
</div>
|
|
93
|
+
{/each}
|
|
94
|
+
</nav>
|
|
95
|
+
{/if}
|
|
@@ -5,6 +5,13 @@ export type SettingsNavProps = HTMLAttributes<HTMLElement> & {
|
|
|
5
5
|
groups: SettingsNavGroup[];
|
|
6
6
|
activeId: string;
|
|
7
7
|
onSelect?: (id: string) => void;
|
|
8
|
+
/**
|
|
9
|
+
* The menu is not known yet (the workspace the person is in is still loading, and with it what they may open): it is
|
|
10
|
+
* drawn as skeleton rows of the same size as the real ones, so that it does not grow row by row when it is known.
|
|
11
|
+
*/
|
|
12
|
+
pending?: boolean;
|
|
13
|
+
/** What a screen reader says for the menu while it is pending. */
|
|
14
|
+
pendingLabel?: string;
|
|
8
15
|
};
|
|
9
16
|
declare const SettingsNav: import("svelte").Component<SettingsNavProps, {}, "">;
|
|
10
17
|
type SettingsNav = ReturnType<typeof SettingsNav>;
|
|
@@ -11,6 +11,7 @@ export { default as AppShell } from './AppShell.svelte';
|
|
|
11
11
|
export { default as ErrorState } from './ErrorState.svelte';
|
|
12
12
|
export { defaultErrorStateMessages, type ErrorStateMessages } from './error-state-messages.js';
|
|
13
13
|
export { default as NotificationRow, type NotificationRowProps } from './NotificationRow.svelte';
|
|
14
|
+
export { default as NotificationDetail, type NotificationDetailProps } from './NotificationDetail.svelte';
|
|
14
15
|
export { default as SettingsNav, type SettingsNavProps } from './SettingsNav.svelte';
|
|
15
16
|
export { default as SettingsDialog, type SettingsDialogProps } from './SettingsDialog.svelte';
|
|
16
17
|
export { default as Stat, type StatProps, statVariants } from './Stat.svelte';
|
|
@@ -14,6 +14,7 @@ export { default as ErrorState } from './ErrorState.svelte';
|
|
|
14
14
|
export { defaultErrorStateMessages } from './error-state-messages.js';
|
|
15
15
|
// [S2 exports]
|
|
16
16
|
export { default as NotificationRow } from './NotificationRow.svelte';
|
|
17
|
+
export { default as NotificationDetail } from './NotificationDetail.svelte';
|
|
17
18
|
export { default as SettingsNav } from './SettingsNav.svelte';
|
|
18
19
|
export { default as SettingsDialog } from './SettingsDialog.svelte';
|
|
19
20
|
export { default as Stat, statVariants } from './Stat.svelte';
|
|
@@ -5,11 +5,10 @@
|
|
|
5
5
|
import IconExclamationCircle from '@tabler/icons-svelte/icons/exclamation-circle';
|
|
6
6
|
import IconInfoCircle from '@tabler/icons-svelte/icons/info-circle';
|
|
7
7
|
import { toastLookupRoots } from './toasterRoots';
|
|
8
|
+
import { toastEnterDurationMs, toastExitDurationMs } from '../../utils/toastMotion.js';
|
|
8
9
|
|
|
9
10
|
type ToastTypes = 'success' | 'error' | 'warning' | 'info' | 'loading';
|
|
10
11
|
|
|
11
|
-
// Icon of each tone: the same glyphs as the Tone variants of the Toast in Figma (135:87).
|
|
12
|
-
// `info` is the Default tone of Figma. `loading` keeps the spinner of the library.
|
|
13
12
|
const toneIcons: Partial<Record<ToastTypes, typeof IconInfoCircle>> = {
|
|
14
13
|
info: IconInfoCircle,
|
|
15
14
|
success: IconCircleCheck,
|
|
@@ -24,26 +23,21 @@
|
|
|
24
23
|
export let element: HTMLElement | null = null;
|
|
25
24
|
|
|
26
25
|
let toastMainClass = 'toast-modal';
|
|
27
|
-
let isToastVisible = false;
|
|
28
26
|
|
|
29
27
|
export function showToast(
|
|
30
28
|
type: string = 'success',
|
|
31
29
|
title: string,
|
|
32
30
|
options: Record<string, unknown> | null = null
|
|
33
31
|
) {
|
|
34
|
-
isToastVisible = true;
|
|
35
|
-
|
|
36
32
|
if (options === null) {
|
|
37
33
|
options = {};
|
|
38
34
|
}
|
|
39
35
|
|
|
40
36
|
const duration = (options?.duration as number | undefined) || defaultDuration;
|
|
41
37
|
|
|
42
|
-
// Every tone has its own icon, the same one as in Figma, so a caller does not swap it.
|
|
43
38
|
const toneIcon = toneIcons[type as ToastTypes];
|
|
44
39
|
if (toneIcon) options.icon = toneIcon;
|
|
45
40
|
|
|
46
|
-
// A type the library does not know is shown as info instead of throwing, and says so once.
|
|
47
41
|
let toastKey: ToastTypes = type as ToastTypes;
|
|
48
42
|
if (typeof toast[toastKey] !== 'function') {
|
|
49
43
|
console.warn(`[showToast] Unknown toast type "${type}", showing it as info.`);
|
|
@@ -53,13 +47,7 @@
|
|
|
53
47
|
return toast[toastKey](title, {
|
|
54
48
|
...options,
|
|
55
49
|
duration,
|
|
56
|
-
unstyled: true
|
|
57
|
-
onAutoClose: () => {
|
|
58
|
-
isToastVisible = false;
|
|
59
|
-
},
|
|
60
|
-
onDismiss: () => {
|
|
61
|
-
isToastVisible = false;
|
|
62
|
-
}
|
|
50
|
+
unstyled: true
|
|
63
51
|
});
|
|
64
52
|
}
|
|
65
53
|
</script>
|
|
@@ -82,33 +70,35 @@
|
|
|
82
70
|
<Toaster
|
|
83
71
|
theme="light"
|
|
84
72
|
dir={$textDirection}
|
|
85
|
-
position=
|
|
73
|
+
position="top-center"
|
|
86
74
|
{containerAriaLabel}
|
|
87
75
|
{closeButtonAriaLabel}
|
|
88
76
|
closeButton
|
|
89
77
|
toastOptions={{
|
|
78
|
+
duration: defaultDuration,
|
|
90
79
|
classes: {
|
|
91
80
|
toast:
|
|
92
81
|
toastMainClass +
|
|
93
|
-
' !
|
|
94
|
-
title: toastMainClass + '-title text-
|
|
95
|
-
description: toastMainClass + '-description text-
|
|
82
|
+
' !flex !min-w-0 !max-w-[420px] !flex-wrap !items-center !gap-2 !rounded-xl !border !px-4 !py-2.5 !pe-9 !text-sm !font-medium !shadow-none [&>[data-icon]]:!hidden',
|
|
83
|
+
title: toastMainClass + '-title !text-inherit',
|
|
84
|
+
description: toastMainClass + '-description !text-inherit/90 !text-sm',
|
|
96
85
|
actionButton:
|
|
97
|
-
'!h-8 !rounded-lg !border !border-
|
|
86
|
+
'!h-8 !rounded-lg !border !border-current/30 !bg-transparent !px-2 !text-label !text-inherit hover:!bg-current/15',
|
|
98
87
|
cancelButton: '',
|
|
99
88
|
closeButton:
|
|
100
89
|
toastMainClass +
|
|
101
|
-
'-close-button !absolute
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
warning: '[&>[data-icon]]:!
|
|
106
|
-
error:
|
|
90
|
+
'-close-button !absolute !end-1.5 !top-1/2 !-translate-y-1/2 !flex !size-7 !items-center justify-center !rounded-full !border-0 !bg-transparent !p-0 !text-inherit !transition-colors hover:!bg-current/20 focus-visible:!bg-current/20 focus-visible:!outline-hidden [&_svg]:!size-3.5 [&_svg]:!stroke-2',
|
|
91
|
+
info: '!border-border !bg-popover !text-popover-foreground',
|
|
92
|
+
success:
|
|
93
|
+
'!border-transparent !bg-toast-green !text-inverse-foreground [&>[data-icon]]:!hidden',
|
|
94
|
+
warning: '!border-transparent !bg-warning !text-primary-foreground [&>[data-icon]]:!hidden',
|
|
95
|
+
error:
|
|
96
|
+
'!border-transparent !bg-destructive !text-destructive-foreground [&>[data-icon]]:!hidden'
|
|
107
97
|
}
|
|
108
98
|
}}
|
|
109
|
-
expand={
|
|
110
|
-
visibleToasts={
|
|
99
|
+
expand={true}
|
|
100
|
+
visibleToasts={3}
|
|
111
101
|
offset="1rem"
|
|
112
|
-
class={className}
|
|
113
|
-
{style}
|
|
102
|
+
class="{className} toast-modal-host"
|
|
103
|
+
style="--toast-enter-ms: {toastEnterDurationMs}ms; --toast-exit-ms: {toastExitDurationMs}ms;{style}"
|
|
114
104
|
/>
|
|
@@ -13,21 +13,23 @@
|
|
|
13
13
|
import type { VariantProps } from "tailwind-variants";
|
|
14
14
|
|
|
15
15
|
export const buttonVariants = tv({
|
|
16
|
-
base: "inline-flex cursor-pointer items-center justify-center gap-1 whitespace-nowrap rounded-lg text-label press-feedback focus-visible:outline-hidden
|
|
16
|
+
base: "inline-flex cursor-pointer items-center justify-center gap-1 whitespace-nowrap rounded-lg text-label press-feedback focus-visible:outline-hidden disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 [&_svg]:stroke-2",
|
|
17
17
|
variants: {
|
|
18
18
|
variant: {
|
|
19
|
-
|
|
19
|
+
// A button draws no ring when it holds the focus (a ring is drawn outside the button, and the edge of a scroll box
|
|
20
|
+
// or a card cut it off): the keyboard focus takes the look of the hover, inside the button.
|
|
21
|
+
default: "bg-primary text-primary-foreground hover:bg-primary/90 focus-visible:bg-primary/90",
|
|
20
22
|
destructive:
|
|
21
|
-
"bg-destructive text-destructive-foreground hover:bg-destructive/90",
|
|
23
|
+
"bg-destructive text-destructive-foreground hover:bg-destructive/90 focus-visible:bg-destructive/90",
|
|
22
24
|
outline:
|
|
23
|
-
"border border-input bg-background text-foreground hover:bg-accent hover:text-foreground",
|
|
25
|
+
"border border-input bg-background text-foreground hover:bg-accent-hover hover:text-foreground focus-visible:bg-accent-hover focus-visible:text-foreground active:bg-accent-hover",
|
|
24
26
|
secondary:
|
|
25
|
-
"bg-secondary text-secondary-foreground hover:bg-accent hover:text-foreground",
|
|
26
|
-
ghost: "text-foreground hover:bg-accent hover:text-foreground",
|
|
27
|
-
accent: "bg-brand text-brand-foreground hover:bg-brand/90",
|
|
27
|
+
"bg-secondary text-secondary-foreground hover:bg-accent hover:text-foreground focus-visible:bg-accent focus-visible:text-foreground",
|
|
28
|
+
ghost: "text-foreground hover:bg-accent hover:text-foreground focus-visible:bg-accent focus-visible:text-foreground",
|
|
29
|
+
accent: "bg-brand text-brand-foreground hover:bg-brand/90 focus-visible:bg-brand/90",
|
|
28
30
|
stroke:
|
|
29
|
-
"border border-border-strong/30 bg-transparent text-foreground hover:bg-accent hover:text-foreground",
|
|
30
|
-
link: "text-primary underline-offset-4 hover:underline",
|
|
31
|
+
"border border-border-strong/30 bg-transparent text-foreground hover:bg-accent hover:text-foreground focus-visible:bg-accent focus-visible:text-foreground",
|
|
32
|
+
link: "text-primary underline-offset-4 hover:underline focus-visible:underline",
|
|
31
33
|
},
|
|
32
34
|
size: {
|
|
33
35
|
// The 12 of the side (small: 8) and the 4 of the label box (see the note at the top), as Figma
|
|
@@ -23,7 +23,7 @@ export declare const buttonVariants: import("tailwind-variants").TVReturnType<{
|
|
|
23
23
|
true: string;
|
|
24
24
|
false: string;
|
|
25
25
|
};
|
|
26
|
-
}, undefined, "inline-flex cursor-pointer items-center justify-center gap-1 whitespace-nowrap rounded-lg text-label press-feedback focus-visible:outline-hidden
|
|
26
|
+
}, undefined, "inline-flex cursor-pointer items-center justify-center gap-1 whitespace-nowrap rounded-lg text-label press-feedback focus-visible:outline-hidden disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 [&_svg]:stroke-2", {
|
|
27
27
|
responsiveVariants?: boolean | (string | number | symbol)[] | {
|
|
28
28
|
size?: boolean | (string | number | symbol)[] | undefined;
|
|
29
29
|
iconPadding?: boolean | (string | number | symbol)[] | undefined;
|
|
@@ -81,7 +81,7 @@ export declare const buttonVariants: import("tailwind-variants").TVReturnType<{
|
|
|
81
81
|
true: string;
|
|
82
82
|
false: string;
|
|
83
83
|
};
|
|
84
|
-
}, undefined, "inline-flex cursor-pointer items-center justify-center gap-1 whitespace-nowrap rounded-lg text-label press-feedback focus-visible:outline-hidden
|
|
84
|
+
}, undefined, "inline-flex cursor-pointer items-center justify-center gap-1 whitespace-nowrap rounded-lg text-label press-feedback focus-visible:outline-hidden disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 [&_svg]:stroke-2", import("tailwind-variants/dist/config.js").TVConfig<{
|
|
85
85
|
variant: {
|
|
86
86
|
default: string;
|
|
87
87
|
destructive: string;
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
|
|
16
16
|
<CommandPrimitive.Item
|
|
17
17
|
class={cn(
|
|
18
|
-
"text-body
|
|
18
|
+
"text-body data-[selected]:bg-brand-subtle hover:not-data-[selected]:bg-accent relative flex h-8 cursor-pointer select-none items-center gap-2 rounded-lg px-2 py-1.5 outline-hidden transition-colors duration-fast data-disabled:pointer-events-none data-disabled:cursor-not-allowed data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 [&_svg]:stroke-2",
|
|
19
19
|
className
|
|
20
20
|
)}
|
|
21
21
|
bind:ref
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
|
|
16
16
|
<CommandPrimitive.LinkItem
|
|
17
17
|
class={cn(
|
|
18
|
-
"
|
|
18
|
+
"data-[selected]:bg-brand-subtle hover:not-data-[selected]:bg-accent relative flex cursor-pointer select-none items-center rounded-sm px-2 py-1.5 text-sm outline-hidden data-disabled:pointer-events-none data-disabled:cursor-not-allowed data-disabled:opacity-50",
|
|
19
19
|
className
|
|
20
20
|
)}
|
|
21
21
|
bind:ref
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
bind:checked
|
|
23
23
|
bind:indeterminate
|
|
24
24
|
class={cn(
|
|
25
|
-
"text-body data-highlighted:bg-accent data-highlighted:text-foreground relative flex h-8 cursor-pointer select-none items-center rounded-lg py-1.5 ps-8 pe-2 outline-hidden transition-colors duration-fast data-disabled:pointer-events-none data-disabled:cursor-not-allowed data-disabled:opacity-50",
|
|
25
|
+
"text-body data-[state=checked]:bg-brand-subtle data-highlighted:data-[state=checked]:bg-brand-subtle data-highlighted:not-data-[state=checked]:bg-accent data-highlighted:text-foreground relative flex h-8 cursor-pointer select-none items-center rounded-lg py-1.5 ps-8 pe-2 outline-hidden transition-colors duration-fast data-disabled:pointer-events-none data-disabled:cursor-not-allowed data-disabled:opacity-50",
|
|
26
26
|
className
|
|
27
27
|
)}
|
|
28
28
|
{...restProps}
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
<DropdownMenuPrimitive.Item
|
|
23
23
|
bind:ref
|
|
24
24
|
class={cn(
|
|
25
|
-
"text-body data-highlighted:bg-accent data-highlighted:text-foreground relative flex cursor-pointer select-none items-center gap-2 rounded-lg px-2 py-1.5 outline-hidden transition-colors duration-fast data-disabled:pointer-events-none data-disabled:cursor-not-allowed data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 [&_svg]:stroke-2 data-[variant=destructive]:text-destructive data-highlighted:data-[variant=destructive]:text-destructive",
|
|
25
|
+
"text-body aria-current:bg-brand-subtle data-highlighted:aria-current:bg-brand-subtle data-highlighted:not-aria-current:bg-accent data-highlighted:text-foreground relative flex cursor-pointer select-none items-center gap-2 rounded-lg px-2 py-1.5 outline-hidden transition-colors duration-fast data-disabled:pointer-events-none data-disabled:cursor-not-allowed data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 [&_svg]:stroke-2 data-[variant=destructive]:text-destructive data-highlighted:data-[variant=destructive]:text-destructive",
|
|
26
26
|
description ? "min-h-12" : "min-h-8",
|
|
27
27
|
inset && "ps-8",
|
|
28
28
|
className
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
<DropdownMenuPrimitive.RadioItem
|
|
19
19
|
bind:ref
|
|
20
20
|
class={cn(
|
|
21
|
-
"text-body data-highlighted:bg-accent data-highlighted:text-foreground relative flex h-8 cursor-pointer select-none items-center rounded-lg py-1.5 ps-8 pe-2 outline-hidden transition-colors duration-fast data-disabled:pointer-events-none data-disabled:cursor-not-allowed data-disabled:opacity-50",
|
|
21
|
+
"text-body data-[state=checked]:bg-brand-subtle data-highlighted:data-[state=checked]:bg-brand-subtle data-highlighted:not-data-[state=checked]:bg-accent data-highlighted:text-foreground relative flex h-8 cursor-pointer select-none items-center rounded-lg py-1.5 ps-8 pe-2 outline-hidden transition-colors duration-fast data-disabled:pointer-events-none data-disabled:cursor-not-allowed data-disabled:opacity-50",
|
|
22
22
|
className
|
|
23
23
|
)}
|
|
24
24
|
{...restProps}
|
|
@@ -8,19 +8,20 @@
|
|
|
8
8
|
import type { VariantProps } from "tailwind-variants";
|
|
9
9
|
|
|
10
10
|
export const iconButtonVariants = tv({
|
|
11
|
-
base: "inline-flex shrink-0 cursor-pointer items-center justify-center press-feedback focus-visible:outline-hidden
|
|
11
|
+
base: "inline-flex shrink-0 cursor-pointer items-center justify-center press-feedback focus-visible:outline-hidden disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 [&_svg]:stroke-2",
|
|
12
12
|
variants: {
|
|
13
13
|
variant: {
|
|
14
|
+
// No ring when it holds the focus (see Button): the keyboard focus takes the look of the hover.
|
|
14
15
|
ghost:
|
|
15
|
-
"rounded-lg text-foreground hover:bg-accent hover:text-foreground",
|
|
16
|
+
"rounded-lg text-foreground hover:bg-accent hover:text-foreground focus-visible:bg-accent focus-visible:text-foreground",
|
|
16
17
|
secondary:
|
|
17
|
-
"rounded-lg bg-secondary text-secondary-foreground hover:bg-accent hover:text-foreground",
|
|
18
|
+
"rounded-lg bg-secondary text-secondary-foreground hover:bg-accent hover:text-foreground focus-visible:bg-accent focus-visible:text-foreground",
|
|
18
19
|
outline:
|
|
19
|
-
"rounded-lg border border-input bg-background text-foreground hover:bg-accent hover:text-foreground",
|
|
20
|
+
"rounded-lg border border-input bg-background text-foreground hover:bg-accent hover:text-foreground focus-visible:bg-accent focus-visible:text-foreground",
|
|
20
21
|
primary:
|
|
21
|
-
"rounded-full bg-primary text-primary-foreground hover:bg-primary/90",
|
|
22
|
+
"rounded-full bg-primary text-primary-foreground hover:bg-primary/90 focus-visible:bg-primary/90",
|
|
22
23
|
accent:
|
|
23
|
-
"rounded-full bg-brand text-brand-foreground hover:bg-brand/90",
|
|
24
|
+
"rounded-full bg-brand text-brand-foreground hover:bg-brand/90 focus-visible:bg-brand/90",
|
|
24
25
|
},
|
|
25
26
|
size: {
|
|
26
27
|
default: "size-8",
|
|
@@ -13,7 +13,7 @@ export declare const iconButtonVariants: import("tailwind-variants").TVReturnTyp
|
|
|
13
13
|
default: string;
|
|
14
14
|
sm: string;
|
|
15
15
|
};
|
|
16
|
-
}, undefined, "inline-flex shrink-0 cursor-pointer items-center justify-center press-feedback focus-visible:outline-hidden
|
|
16
|
+
}, undefined, "inline-flex shrink-0 cursor-pointer items-center justify-center press-feedback focus-visible:outline-hidden disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 [&_svg]:stroke-2", {
|
|
17
17
|
responsiveVariants?: boolean | (string | number | symbol)[] | {
|
|
18
18
|
size?: boolean | (string | number | symbol)[] | undefined;
|
|
19
19
|
variant?: boolean | (string | number | symbol)[] | undefined;
|
|
@@ -50,7 +50,7 @@ export declare const iconButtonVariants: import("tailwind-variants").TVReturnTyp
|
|
|
50
50
|
default: string;
|
|
51
51
|
sm: string;
|
|
52
52
|
};
|
|
53
|
-
}, undefined, "inline-flex shrink-0 cursor-pointer items-center justify-center press-feedback focus-visible:outline-hidden
|
|
53
|
+
}, undefined, "inline-flex shrink-0 cursor-pointer items-center justify-center press-feedback focus-visible:outline-hidden disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 [&_svg]:stroke-2", import("tailwind-variants/dist/config.js").TVConfig<{
|
|
54
54
|
variant: {
|
|
55
55
|
ghost: string;
|
|
56
56
|
secondary: string;
|
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
<!-- Figma: Select Option (component set 170:135, node 170:135). -->
|
|
2
2
|
<script lang="ts" module>
|
|
3
3
|
import { Select as SelectPrimitive, type WithoutChild } from "bits-ui";
|
|
4
|
-
export type SelectItemProps = WithoutChild<SelectPrimitive.ItemProps
|
|
4
|
+
export type SelectItemProps = WithoutChild<SelectPrimitive.ItemProps> & {
|
|
5
|
+
/**
|
|
6
|
+
* The check at the start of the chosen row (default: shown). Turn it off when the row draws its own leading mark and says
|
|
7
|
+
* "Selected" in words (Figma: Billing, "Paid with": a card icon on every row, "Selected" at the end of the chosen one).
|
|
8
|
+
*/
|
|
9
|
+
showIndicator?: boolean;
|
|
10
|
+
};
|
|
5
11
|
</script>
|
|
6
12
|
|
|
7
13
|
<script lang="ts">
|
|
@@ -13,6 +19,7 @@
|
|
|
13
19
|
class: className,
|
|
14
20
|
value,
|
|
15
21
|
label,
|
|
22
|
+
showIndicator = true,
|
|
16
23
|
children: childrenProp,
|
|
17
24
|
...restProps
|
|
18
25
|
}: SelectItemProps = $props();
|
|
@@ -29,17 +36,21 @@
|
|
|
29
36
|
bind:ref
|
|
30
37
|
{value}
|
|
31
38
|
class={cn(
|
|
32
|
-
"relative flex h-8 w-full cursor-pointer select-none items-center gap-2 rounded-lg px-2 py-1.5
|
|
39
|
+
"relative flex h-8 w-full cursor-pointer select-none items-center gap-2 rounded-lg px-2 py-1.5 text-body outline-hidden data-[selected]:bg-brand-subtle hover:not-data-[selected]:bg-accent [[data-input-modality=keyboard]_&]:not-data-[selected]:data-[highlighted]:bg-accent [[data-input-modality=keyboard]_&]:not-data-[selected]:not-data-[highlighted]:hover:bg-transparent data-[disabled]:pointer-events-none data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50",
|
|
40
|
+
// The start padding leaves room for the check; a row without one keeps the plain padding for its own leading mark.
|
|
41
|
+
showIndicator && "ps-8",
|
|
33
42
|
className
|
|
34
43
|
)}
|
|
35
44
|
{...restProps}
|
|
36
45
|
>
|
|
37
46
|
{#snippet children({ selected, highlighted })}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
47
|
+
{#if showIndicator}
|
|
48
|
+
<span class="absolute start-2 flex size-3.5 items-center justify-center">
|
|
49
|
+
{#if selected}
|
|
50
|
+
<IconCheck class="size-4 stroke-2" aria-hidden="true" />
|
|
51
|
+
{/if}
|
|
52
|
+
</span>
|
|
53
|
+
{/if}
|
|
43
54
|
{#if childrenProp}
|
|
44
55
|
{@render childrenProp({ selected, highlighted })}
|
|
45
56
|
{:else}
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import { Select as SelectPrimitive, type WithoutChild } from "bits-ui";
|
|
2
|
-
export type SelectItemProps = WithoutChild<SelectPrimitive.ItemProps
|
|
3
|
-
|
|
2
|
+
export type SelectItemProps = WithoutChild<SelectPrimitive.ItemProps> & {
|
|
3
|
+
/**
|
|
4
|
+
* The check at the start of the chosen row (default: shown). Turn it off when the row draws its own leading mark and says
|
|
5
|
+
* "Selected" in words (Figma: Billing, "Paid with": a card icon on every row, "Selected" at the end of the chosen one).
|
|
6
|
+
*/
|
|
7
|
+
showIndicator?: boolean;
|
|
8
|
+
};
|
|
9
|
+
declare const SelectItem: import("svelte").Component<SelectItemProps, {}, "ref">;
|
|
4
10
|
type SelectItem = ReturnType<typeof SelectItem>;
|
|
5
11
|
export default SelectItem;
|
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
<!--
|
|
1
|
+
<!--
|
|
2
|
+
Figma: IC Slider (Editor); track input, range primary, 4px track / 16px thumb.
|
|
3
|
+
|
|
4
|
+
The root is as tall (or as wide, when vertical) as the thumb so a press anywhere in that band jumps the scrub, not only on the
|
|
5
|
+
thin track line. `aria-label` and `aria-labelledby` name the thumb, which is the element a screen reader lands on (the root is a
|
|
6
|
+
plain span with no role, so a name on it is never spoken). With two thumbs (a range) each one gets the name and its place:
|
|
7
|
+
"Price 1", "Price 2".
|
|
8
|
+
-->
|
|
2
9
|
<script lang="ts" module>
|
|
3
10
|
import { Slider as SliderPrimitive, type WithoutChildrenOrChild } from "bits-ui";
|
|
4
11
|
export type SliderProps = WithoutChildrenOrChild<SliderPrimitive.RootProps>;
|
|
@@ -14,25 +21,44 @@
|
|
|
14
21
|
ref = $bindable(null),
|
|
15
22
|
value = $bindable(),
|
|
16
23
|
class: className,
|
|
24
|
+
"aria-label": ariaLabel,
|
|
25
|
+
"aria-labelledby": ariaLabelledby,
|
|
17
26
|
...restProps
|
|
18
27
|
}: SliderProps = $props();
|
|
28
|
+
|
|
29
|
+
/** The name of one thumb: the label as given for a single thumb, numbered for a range. */
|
|
30
|
+
function thumbLabel(thumb: number, thumbCount: number): string | undefined {
|
|
31
|
+
if (!ariaLabel) return undefined;
|
|
32
|
+
return thumbCount > 1 ? `${ariaLabel} ${thumb + 1}` : ariaLabel;
|
|
33
|
+
}
|
|
19
34
|
</script>
|
|
20
35
|
|
|
21
36
|
<SliderPrimitive.Root
|
|
22
37
|
bind:value={value as never}
|
|
23
38
|
bind:ref
|
|
24
|
-
class={cn(
|
|
39
|
+
class={cn(
|
|
40
|
+
"group relative flex w-full min-h-4 touch-none select-none items-center cursor-pointer data-[disabled]:cursor-not-allowed data-[orientation=vertical]:h-full data-[orientation=vertical]:min-h-0 data-[orientation=vertical]:w-auto data-[orientation=vertical]:min-w-4 data-[orientation=vertical]:flex-col data-[orientation=vertical]:justify-center",
|
|
41
|
+
className
|
|
42
|
+
)}
|
|
25
43
|
dir={$textDirection}
|
|
26
44
|
{...restProps}
|
|
27
45
|
>
|
|
28
46
|
{#snippet children({ thumbs })}
|
|
29
|
-
<span
|
|
30
|
-
|
|
47
|
+
<span
|
|
48
|
+
class="relative flex h-4 w-full grow items-center group-data-[orientation=vertical]:h-full group-data-[orientation=vertical]:w-4 group-data-[orientation=vertical]:flex-col group-data-[orientation=vertical]:justify-center"
|
|
49
|
+
>
|
|
50
|
+
<span
|
|
51
|
+
class="relative h-1 w-full overflow-hidden rounded-full bg-input group-data-[orientation=vertical]:h-full group-data-[orientation=vertical]:w-1"
|
|
52
|
+
>
|
|
53
|
+
<SliderPrimitive.Range class="absolute z-10 h-full w-full rounded-full bg-primary" />
|
|
54
|
+
</span>
|
|
31
55
|
</span>
|
|
32
56
|
{#each thumbs as thumb}
|
|
33
57
|
<SliderPrimitive.Thumb
|
|
34
58
|
index={thumb}
|
|
35
|
-
|
|
59
|
+
aria-label={thumbLabel(thumb, thumbs.length)}
|
|
60
|
+
aria-labelledby={ariaLabelledby}
|
|
61
|
+
class="relative z-20 block size-4 cursor-grab rounded-full border-2 border-primary bg-background data-active:cursor-grabbing focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:pointer-events-none disabled:opacity-50"
|
|
36
62
|
/>
|
|
37
63
|
{/each}
|
|
38
64
|
{/snippet}
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
<TabsPrimitive.Trigger
|
|
17
17
|
bind:ref
|
|
18
18
|
class={cn(
|
|
19
|
-
"text-label focus-visible:ring-ring data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=inactive]:text-muted-foreground inline-flex h-7 items-center justify-center whitespace-nowrap rounded-lg px-3 transition-colors duration-fast focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:pointer-events-none disabled:opacity-50 data-[state=inactive]:hover:bg-accent data-[state=inactive]:hover:text-foreground",
|
|
19
|
+
"text-label focus-visible:ring-ring data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=inactive]:text-muted-foreground inline-flex h-7 cursor-pointer items-center justify-center whitespace-nowrap rounded-lg px-3 transition-colors duration-fast focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 data-[state=inactive]:hover:bg-accent data-[state=inactive]:hover:text-foreground",
|
|
20
20
|
className
|
|
21
21
|
)}
|
|
22
22
|
{...restProps}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import type { VariantProps } from "tailwind-variants";
|
|
4
4
|
|
|
5
5
|
export const toggleVariants = tv({
|
|
6
|
-
base: "inline-flex items-center justify-center gap-2 rounded-lg text-label transition-colors duration-fast focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-brand-subtle data-[state=on]:text-foreground [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 [&_svg]:stroke-2 hover:bg-accent",
|
|
6
|
+
base: "inline-flex cursor-pointer items-center justify-center gap-2 rounded-lg text-label transition-colors duration-fast focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 data-[state=on]:bg-brand-subtle data-[state=on]:text-foreground [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 [&_svg]:stroke-2 hover:bg-accent",
|
|
7
7
|
variants: {
|
|
8
8
|
variant: {
|
|
9
9
|
default: "bg-transparent text-foreground",
|
|
@@ -9,7 +9,7 @@ export declare const toggleVariants: import("tailwind-variants").TVReturnType<{
|
|
|
9
9
|
sm: string;
|
|
10
10
|
lg: string;
|
|
11
11
|
};
|
|
12
|
-
}, undefined, "inline-flex items-center justify-center gap-2 rounded-lg text-label transition-colors duration-fast focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-brand-subtle data-[state=on]:text-foreground [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 [&_svg]:stroke-2 hover:bg-accent", {
|
|
12
|
+
}, undefined, "inline-flex cursor-pointer items-center justify-center gap-2 rounded-lg text-label transition-colors duration-fast focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 data-[state=on]:bg-brand-subtle data-[state=on]:text-foreground [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 [&_svg]:stroke-2 hover:bg-accent", {
|
|
13
13
|
responsiveVariants?: boolean | (string | number | symbol)[] | {
|
|
14
14
|
size?: boolean | (string | number | symbol)[] | undefined;
|
|
15
15
|
variant?: boolean | (string | number | symbol)[] | undefined;
|
|
@@ -42,7 +42,7 @@ export declare const toggleVariants: import("tailwind-variants").TVReturnType<{
|
|
|
42
42
|
sm: string;
|
|
43
43
|
lg: string;
|
|
44
44
|
};
|
|
45
|
-
}, undefined, "inline-flex items-center justify-center gap-2 rounded-lg text-label transition-colors duration-fast focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-brand-subtle data-[state=on]:text-foreground [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 [&_svg]:stroke-2 hover:bg-accent", import("tailwind-variants/dist/config.js").TVConfig<{
|
|
45
|
+
}, undefined, "inline-flex cursor-pointer items-center justify-center gap-2 rounded-lg text-label transition-colors duration-fast focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 data-[state=on]:bg-brand-subtle data-[state=on]:text-foreground [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 [&_svg]:stroke-2 hover:bg-accent", import("tailwind-variants/dist/config.js").TVConfig<{
|
|
46
46
|
variant: {
|
|
47
47
|
default: string;
|
|
48
48
|
outline: string;
|