@widgetic/design-system 0.5.22 → 0.5.23
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/README.md +2 -0
- package/dist/components/CopyableHeader.svelte +260 -448
- package/dist/components/CopyableHeader.svelte.d.ts +8 -5
- package/dist/components/EmptyState.svelte +100 -128
- package/dist/components/EmptyState.svelte.d.ts +16 -19
- package/dist/components/GenerateLoader.svelte +17 -10
- package/dist/components/PasswordInput.svelte +41 -44
- package/dist/components/PasswordInput.svelte.d.ts +2 -0
- package/dist/components/ThumbHashImage.svelte +117 -119
- package/dist/components/WScrollArea.svelte +47 -41
- package/dist/components/chat/ActivityRow.svelte +115 -0
- package/dist/components/chat/ActivityRow.svelte.d.ts +18 -0
- package/dist/components/chat/ChatHeader.svelte +114 -0
- package/dist/components/chat/ChatHeader.svelte.d.ts +26 -0
- package/dist/components/chat/Composer.svelte +172 -0
- package/dist/components/chat/Composer.svelte.d.ts +27 -0
- package/dist/components/chat/Message.svelte +158 -0
- package/dist/components/chat/Message.svelte.d.ts +28 -0
- package/dist/components/chat/OptionRow.svelte +59 -0
- package/dist/components/chat/OptionRow.svelte.d.ts +14 -0
- package/dist/components/chat/PlanCard.svelte +220 -0
- package/dist/components/chat/PlanCard.svelte.d.ts +34 -0
- package/dist/components/chat/QuestionCard.svelte +265 -0
- package/dist/components/chat/QuestionCard.svelte.d.ts +38 -0
- package/dist/components/chat/ScrollToBottom.svelte +51 -0
- package/dist/components/chat/ScrollToBottom.svelte.d.ts +11 -0
- package/dist/components/chat/SuggestionCard.svelte +79 -0
- package/dist/components/chat/SuggestionCard.svelte.d.ts +20 -0
- package/dist/components/chat/TaskRow.svelte +59 -0
- package/dist/components/chat/TaskRow.svelte.d.ts +11 -0
- package/dist/components/chat/composerLogic.d.ts +16 -0
- package/dist/components/chat/composerLogic.js +29 -0
- package/dist/components/chat/index.d.ts +16 -0
- package/dist/components/chat/index.js +16 -0
- package/dist/components/chat/questionCardLogic.d.ts +11 -0
- package/dist/components/chat/questionCardLogic.js +39 -0
- package/dist/components/index.d.ts +10 -1
- package/dist/components/index.js +10 -0
- package/dist/components/modals/ActionModal.svelte +186 -180
- package/dist/components/modals/BaseModal.svelte +402 -399
- package/dist/components/modals/BaseModal.svelte.d.ts +1 -0
- package/dist/components/modals/NewItemDialog.svelte +200 -243
- package/dist/components/modals/Portal.svelte +107 -105
- package/dist/components/modals/README.md +16 -2
- package/dist/components/modals/RenameDialog.svelte +234 -292
- package/dist/components/navigation/Breadcrumbs.svelte +415 -377
- package/dist/components/navigation/Breadcrumbs.svelte.d.ts +3 -2
- package/dist/components/navigation/types.d.ts +2 -0
- package/dist/components/pdf/PDFViewer.svelte +1 -1
- package/dist/components/search-input/SearchInput.svelte +51 -104
- package/dist/components/search-input/SearchInput.svelte.d.ts +9 -27
- package/dist/components/shad-editor/editor.css +1 -1
- package/dist/components/shad-editor/i18n/messages.d.ts +1 -1
- package/dist/components/shad-editor/i18n/messages.js +1 -1
- package/dist/components/shell/AppShell.svelte +52 -0
- package/dist/components/shell/AppShell.svelte.d.ts +13 -0
- package/dist/components/shell/Banner.svelte +90 -0
- package/dist/components/shell/Banner.svelte.d.ts +61 -0
- package/dist/components/shell/ErrorState.svelte +60 -0
- package/dist/components/shell/ErrorState.svelte.d.ts +13 -0
- package/dist/components/shell/Link.svelte +63 -0
- package/dist/components/shell/Link.svelte.d.ts +53 -0
- package/dist/components/shell/NavDrawer.svelte +117 -0
- package/dist/components/shell/NavDrawer.svelte.d.ts +10 -0
- package/dist/components/shell/NavRow.svelte +128 -0
- package/dist/components/shell/NavRow.svelte.d.ts +65 -0
- package/dist/components/shell/NavSectionLabel.svelte +27 -0
- package/dist/components/shell/NavSectionLabel.svelte.d.ts +9 -0
- package/dist/components/shell/NotificationRow.svelte +76 -0
- package/dist/components/shell/NotificationRow.svelte.d.ts +16 -0
- package/dist/components/shell/PageHeader.svelte +42 -0
- package/dist/components/shell/PageHeader.svelte.d.ts +12 -0
- package/dist/components/shell/ProfileRow.svelte +95 -0
- package/dist/components/shell/ProfileRow.svelte.d.ts +54 -0
- package/dist/components/shell/SettingsDialog.svelte +118 -0
- package/dist/components/shell/SettingsDialog.svelte.d.ts +19 -0
- package/dist/components/shell/SettingsNav.svelte +46 -0
- package/dist/components/shell/SettingsNav.svelte.d.ts +11 -0
- package/dist/components/shell/Sidebar.svelte +82 -0
- package/dist/components/shell/Sidebar.svelte.d.ts +25 -0
- package/dist/components/shell/Stat.svelte +63 -0
- package/dist/components/shell/Stat.svelte.d.ts +58 -0
- package/dist/components/shell/TopBar.svelte +37 -0
- package/dist/components/shell/TopBar.svelte.d.ts +11 -0
- package/dist/components/shell/WidgetRow.svelte +126 -0
- package/dist/components/shell/WidgetRow.svelte.d.ts +78 -0
- package/dist/components/shell/error-state-messages.d.ts +7 -0
- package/dist/components/shell/error-state-messages.js +9 -0
- package/dist/components/shell/index.d.ts +22 -0
- package/dist/components/shell/index.js +25 -0
- package/dist/components/shell/link-external.d.ts +2 -0
- package/dist/components/shell/link-external.js +7 -0
- package/dist/components/shell/messages.d.ts +7 -0
- package/dist/components/shell/messages.js +5 -0
- package/dist/components/shell/settings-nav-types.d.ts +12 -0
- package/dist/components/shell/settings-nav-types.js +3 -0
- package/dist/components/shell/shell-utils.d.ts +7 -0
- package/dist/components/shell/shell-utils.js +27 -0
- package/dist/components/shell/stat-tone.d.ts +3 -0
- package/dist/components/shell/stat-tone.js +11 -0
- package/dist/components/toast/ToasterModal.svelte +102 -168
- package/dist/components/toast/ToasterModal.svelte.d.ts +2 -12
- package/dist/components/ui/accordion/accordion-content.svelte +3 -2
- package/dist/components/ui/accordion/accordion-item.svelte +10 -1
- package/dist/components/ui/accordion/accordion-trigger.svelte +4 -3
- package/dist/components/ui/alert/alert-description.svelte +5 -1
- package/dist/components/ui/alert/alert-title.svelte +2 -1
- package/dist/components/ui/alert/index.d.ts +13 -11
- package/dist/components/ui/alert/index.js +4 -4
- package/dist/components/ui/avatar/avatar-utils.d.ts +2 -0
- package/dist/components/ui/avatar/avatar-utils.js +9 -0
- package/dist/components/ui/avatar/avatar.svelte +63 -0
- package/dist/components/ui/avatar/avatar.svelte.d.ts +80 -0
- package/dist/components/ui/avatar/index.d.ts +4 -0
- package/dist/components/ui/avatar/index.js +4 -0
- package/dist/components/ui/badge/badge.svelte +22 -10
- package/dist/components/ui/badge/badge.svelte.d.ts +14 -15
- package/dist/components/ui/breadcrumb/breadcrumb-ellipsis.svelte +2 -2
- package/dist/components/ui/breadcrumb/breadcrumb-link.svelte +1 -1
- package/dist/components/ui/breadcrumb/breadcrumb-page.svelte +1 -1
- package/dist/components/ui/breadcrumb/breadcrumb-separator.svelte +2 -2
- package/dist/components/ui/button/button-padding.d.ts +9 -0
- package/dist/components/ui/button/button-padding.js +15 -0
- package/dist/components/ui/button/button.svelte +81 -31
- package/dist/components/ui/button/button.svelte.d.ts +48 -29
- package/dist/components/ui/calendar/calendar-cell.svelte +1 -1
- package/dist/components/ui/calendar/calendar-head-cell.svelte +1 -1
- package/dist/components/ui/calendar/calendar-next-button.svelte +2 -2
- package/dist/components/ui/calendar/calendar-prev-button.svelte +2 -2
- package/dist/components/ui/card/card-description.svelte +1 -1
- package/dist/components/ui/card/card-title.svelte +1 -1
- package/dist/components/ui/card/card.svelte +1 -1
- package/dist/components/ui/checkbox/checkbox.svelte +9 -5
- package/dist/components/ui/chip/chip.svelte +48 -0
- package/dist/components/ui/chip/chip.svelte.d.ts +13 -0
- package/dist/components/ui/chip/index.d.ts +2 -0
- package/dist/components/ui/chip/index.js +2 -0
- package/dist/components/ui/command/command-dialog.svelte +1 -1
- package/dist/components/ui/command/command-input.svelte +4 -4
- package/dist/components/ui/command/command-item.svelte +1 -1
- package/dist/components/ui/command/command.svelte +1 -1
- package/dist/components/ui/dialog/dialog-content.svelte +4 -4
- package/dist/components/ui/dialog/dialog-description.svelte +1 -1
- package/dist/components/ui/dialog/dialog-overlay.svelte +1 -1
- package/dist/components/ui/dialog/dialog-title.svelte +1 -1
- package/dist/components/ui/drawer/drawer-content.svelte +1 -1
- package/dist/components/ui/drawer/drawer-overlay.svelte +1 -1
- package/dist/components/ui/dropdown-menu/dropdown-menu-checkbox-item.svelte +5 -5
- package/dist/components/ui/dropdown-menu/dropdown-menu-content.svelte +1 -1
- package/dist/components/ui/dropdown-menu/dropdown-menu-group-heading.svelte +1 -1
- package/dist/components/ui/dropdown-menu/dropdown-menu-item.svelte +20 -2
- package/dist/components/ui/dropdown-menu/dropdown-menu-item.svelte.d.ts +4 -0
- package/dist/components/ui/dropdown-menu/dropdown-menu-label.svelte +5 -1
- package/dist/components/ui/dropdown-menu/dropdown-menu-radio-item.svelte +3 -3
- package/dist/components/ui/dropdown-menu/dropdown-menu-separator.svelte +2 -1
- package/dist/components/ui/dropdown-menu/dropdown-menu-sub-content.svelte +1 -1
- package/dist/components/ui/dropdown-menu/dropdown-menu-sub-trigger.svelte +3 -3
- package/dist/components/ui/field/field-ids.d.ts +7 -0
- package/dist/components/ui/field/field-ids.js +15 -0
- package/dist/components/ui/field/field.svelte +62 -0
- package/dist/components/ui/field/field.svelte.d.ts +21 -0
- package/dist/components/ui/field/index.d.ts +3 -0
- package/dist/components/ui/field/index.js +3 -0
- package/dist/components/ui/hover-card/hover-card-content.svelte +1 -1
- package/dist/components/ui/icon-button/icon-button.svelte +72 -0
- package/dist/components/ui/icon-button/icon-button.svelte.d.ts +90 -0
- package/dist/components/ui/icon-button/index.d.ts +2 -0
- package/dist/components/ui/icon-button/index.js +4 -0
- package/dist/components/ui/input/index.d.ts +1 -0
- package/dist/components/ui/input/input.svelte +11 -4
- package/dist/components/ui/input/input.svelte.d.ts +4 -1
- package/dist/components/ui/input-otp/input-otp-separator.svelte +2 -2
- package/dist/components/ui/input-otp/input-otp-slot.svelte +5 -4
- package/dist/components/ui/input-otp/input-otp-slot.svelte.d.ts +1 -1
- package/dist/components/ui/input-otp/input-otp.svelte +1 -1
- package/dist/components/ui/label/label.svelte +3 -2
- package/dist/components/ui/popover/popover-content.svelte +1 -1
- package/dist/components/ui/progress/progress.svelte +19 -5
- package/dist/components/ui/progress/progress.svelte.d.ts +4 -2
- package/dist/components/ui/radio-group/radio-group-item.svelte +4 -4
- package/dist/components/ui/range-calendar/range-calendar-head-cell.svelte +1 -1
- package/dist/components/ui/range-calendar/range-calendar-next-button.svelte +2 -2
- package/dist/components/ui/range-calendar/range-calendar-prev-button.svelte +2 -2
- package/dist/components/ui/scroll-area/scroll-area-scrollbar.svelte +4 -1
- package/dist/components/ui/scroll-area/scroll-area.svelte +1 -1
- package/dist/components/ui/select/select-content.svelte +1 -3
- package/dist/components/ui/select/select-item.svelte +5 -4
- package/dist/components/ui/select/select-scroll-down-button.svelte +2 -2
- package/dist/components/ui/select/select-scroll-up-button.svelte +2 -2
- package/dist/components/ui/select/select-trigger.svelte +4 -3
- package/dist/components/ui/skeleton/index.d.ts +2 -0
- package/dist/components/ui/skeleton/index.js +2 -0
- package/dist/components/ui/skeleton/skeleton.svelte +24 -0
- package/dist/components/ui/skeleton/skeleton.svelte.d.ts +8 -0
- package/dist/components/ui/slider/slider.svelte +5 -10
- package/dist/components/ui/sonner/sonner.svelte +19 -13
- package/dist/components/ui/stepper-button/index.d.ts +3 -0
- package/dist/components/ui/stepper-button/index.js +2 -0
- package/dist/components/ui/stepper-button/stepper-button.svelte +37 -0
- package/dist/components/ui/stepper-button/stepper-button.svelte.d.ts +9 -0
- package/dist/components/ui/switch/switch.svelte +8 -3
- package/dist/components/ui/table/table-cell.svelte +1 -1
- package/dist/components/ui/table/table-head.svelte +1 -1
- package/dist/components/ui/table/table-row.svelte +1 -1
- package/dist/components/ui/tabs/tabs-list.svelte +1 -1
- package/dist/components/ui/tabs/tabs-trigger.svelte +1 -1
- package/dist/components/ui/tag/index.d.ts +2 -0
- package/dist/components/ui/tag/index.js +2 -0
- package/dist/components/ui/tag/tag.svelte +42 -0
- package/dist/components/ui/tag/tag.svelte.d.ts +11 -0
- package/dist/components/ui/textarea/textarea.svelte +4 -3
- package/dist/components/ui/textarea/textarea.svelte.d.ts +2 -2
- package/dist/components/ui/toggle/toggle.svelte +9 -9
- package/dist/components/ui/toggle/toggle.svelte.d.ts +14 -21
- package/dist/components/ui/tooltip/tooltip-content.svelte +1 -1
- package/dist/fonts/Inter/Inter-Black.woff2 +0 -0
- package/dist/fonts/Inter/Inter-BlackItalic.woff2 +0 -0
- package/dist/fonts/Inter/Inter-Bold.woff2 +0 -0
- package/dist/fonts/Inter/Inter-BoldItalic.woff2 +0 -0
- package/dist/fonts/Inter/Inter-ExtraBold.woff2 +0 -0
- package/dist/fonts/Inter/Inter-ExtraBoldItalic.woff2 +0 -0
- package/dist/fonts/Inter/Inter-ExtraLight-BETA.woff2 +0 -0
- package/dist/fonts/Inter/Inter-ExtraLightItalic-BETA.woff2 +0 -0
- package/dist/fonts/Inter/Inter-Italic.woff2 +0 -0
- package/dist/fonts/Inter/Inter-Light-BETA.woff2 +0 -0
- package/dist/fonts/Inter/Inter-LightItalic-BETA.woff2 +0 -0
- package/dist/fonts/Inter/Inter-Medium.woff2 +0 -0
- package/dist/fonts/Inter/Inter-MediumItalic.woff2 +0 -0
- package/dist/fonts/Inter/Inter-Regular.woff2 +0 -0
- package/dist/fonts/Inter/Inter-SemiBold.woff2 +0 -0
- package/dist/fonts/Inter/Inter-SemiBoldItalic.woff2 +0 -0
- package/dist/fonts/Inter/Inter-Thin-BETA.woff2 +0 -0
- package/dist/fonts/Inter/Inter-ThinItalic-BETA.woff2 +0 -0
- package/dist/fonts/Inter/Inter-italic.var.woff2 +0 -0
- package/dist/fonts/Inter/Inter-upright.var.woff2 +0 -0
- package/dist/fonts/Inter/Inter.var.woff2 +0 -0
- package/dist/fonts/JetBrainsMono/JetBrainsMono-Regular.woff2 +0 -0
- package/dist/i18n/audit/designSystemWords.d.ts +1 -1
- package/dist/i18n/audit/designSystemWords.js +1 -1
- package/dist/styles/fonts.css +18 -14
- package/dist/styles/global.css +7 -19
- package/dist/styles/tokens.css +332 -0
- package/dist/utils.d.ts +27 -0
- package/dist/utils.js +33 -2
- package/package.json +2 -1
- package/tailwind.config.ts +7 -47
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { VariantProps } from "tailwind-variants";
|
|
2
2
|
import Root from "./alert.svelte";
|
|
3
3
|
import Description from "./alert-description.svelte";
|
|
4
4
|
import Title from "./alert-title.svelte";
|
|
@@ -7,27 +7,29 @@ export declare const alertVariants: import("tailwind-variants").TVReturnType<{
|
|
|
7
7
|
default: string;
|
|
8
8
|
destructive: string;
|
|
9
9
|
};
|
|
10
|
-
}, undefined, "
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
}, undefined, "relative grid w-full grid-cols-[auto_1fr] gap-x-3 gap-y-0.5 rounded-xl border border-border bg-background p-3 pe-4 ps-4 text-foreground [&>svg]:col-start-1 [&>svg]:row-start-1 [&>svg]:mt-0.5 [&>svg]:size-4 [&>svg]:shrink-0 [&>svg]:stroke-[1.333] [&_[data-slot=alert-title]]:col-start-2 [&_[data-slot=alert-title]]:row-start-1 [&_[data-slot=alert-description]]:col-start-2 [&_[data-slot=alert-description]]:row-start-2", {
|
|
11
|
+
responsiveVariants?: boolean | (string | number | symbol)[] | {
|
|
12
|
+
variant?: boolean | (string | number | symbol)[] | undefined;
|
|
13
|
+
} | undefined;
|
|
14
|
+
} & import("tailwind-variants/dist/config.js").TWMConfig & {
|
|
15
|
+
twMergeConfig: {
|
|
16
|
+
classGroups: {
|
|
17
|
+
"font-size": {
|
|
18
|
+
text: ("display-hero" | "heading-page" | "heading-section" | "body" | "body-medium" | "body-large" | "caption" | "caption-medium" | "label" | "label-small" | "code")[];
|
|
19
|
+
}[];
|
|
20
|
+
};
|
|
14
21
|
};
|
|
15
22
|
}, {
|
|
16
23
|
variant: {
|
|
17
24
|
default: string;
|
|
18
25
|
destructive: string;
|
|
19
26
|
};
|
|
20
|
-
}>, {
|
|
21
|
-
variant: {
|
|
22
|
-
default: string;
|
|
23
|
-
destructive: string;
|
|
24
|
-
};
|
|
25
27
|
}, undefined, import("tailwind-variants").TVReturnType<{
|
|
26
28
|
variant: {
|
|
27
29
|
default: string;
|
|
28
30
|
destructive: string;
|
|
29
31
|
};
|
|
30
|
-
}, undefined, "
|
|
32
|
+
}, undefined, "relative grid w-full grid-cols-[auto_1fr] gap-x-3 gap-y-0.5 rounded-xl border border-border bg-background p-3 pe-4 ps-4 text-foreground [&>svg]:col-start-1 [&>svg]:row-start-1 [&>svg]:mt-0.5 [&>svg]:size-4 [&>svg]:shrink-0 [&>svg]:stroke-[1.333] [&_[data-slot=alert-title]]:col-start-2 [&_[data-slot=alert-title]]:row-start-1 [&_[data-slot=alert-description]]:col-start-2 [&_[data-slot=alert-description]]:row-start-2", import("tailwind-variants/dist/config.js").TVConfig<{
|
|
31
33
|
variant: {
|
|
32
34
|
default: string;
|
|
33
35
|
destructive: string;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { tv } from "
|
|
1
|
+
import { tv } from "../../../utils.js";
|
|
2
2
|
import Root from "./alert.svelte";
|
|
3
3
|
import Description from "./alert-description.svelte";
|
|
4
4
|
import Title from "./alert-title.svelte";
|
|
5
5
|
export const alertVariants = tv({
|
|
6
|
-
base: "
|
|
6
|
+
base: "relative grid w-full grid-cols-[auto_1fr] gap-x-3 gap-y-0.5 rounded-xl border border-border bg-background p-3 pe-4 ps-4 text-foreground [&>svg]:col-start-1 [&>svg]:row-start-1 [&>svg]:mt-0.5 [&>svg]:size-4 [&>svg]:shrink-0 [&>svg]:stroke-[1.333] [&_[data-slot=alert-title]]:col-start-2 [&_[data-slot=alert-title]]:row-start-1 [&_[data-slot=alert-description]]:col-start-2 [&_[data-slot=alert-description]]:row-start-2",
|
|
7
7
|
variants: {
|
|
8
8
|
variant: {
|
|
9
|
-
default: "
|
|
10
|
-
destructive: "
|
|
9
|
+
default: "text-foreground [&>svg]:text-foreground",
|
|
10
|
+
destructive: "[&>svg]:text-destructive [&_[data-slot=alert-title]]:text-destructive [&_[data-slot=alert-description]]:text-destructive/90",
|
|
11
11
|
},
|
|
12
12
|
},
|
|
13
13
|
defaultVariants: {
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** Derive one or two letter initials from a display name (Figma Avatar / Type=Initials). */
|
|
2
|
+
export function avatarInitials(name) {
|
|
3
|
+
const parts = name.trim().split(/\s+/).filter(Boolean);
|
|
4
|
+
if (parts.length === 0)
|
|
5
|
+
return "?";
|
|
6
|
+
if (parts.length === 1)
|
|
7
|
+
return parts[0].slice(0, 2).toUpperCase();
|
|
8
|
+
return (parts[0][0] + parts[parts.length - 1][0]).toUpperCase();
|
|
9
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
<!-- Figma: Avatar (component set 50:17, node 50:3). -->
|
|
2
|
+
<script lang="ts" module>
|
|
3
|
+
import type { VariantProps } from "tailwind-variants";
|
|
4
|
+
|
|
5
|
+
export const avatarVariants = tv({
|
|
6
|
+
base: "relative inline-flex shrink-0 items-center justify-center overflow-hidden rounded-full bg-brand-subtle text-brand-foreground",
|
|
7
|
+
variants: {
|
|
8
|
+
size: {
|
|
9
|
+
sm: "size-6 text-caption-medium",
|
|
10
|
+
default: "size-8 text-caption-medium",
|
|
11
|
+
lg: "size-10 text-label-small",
|
|
12
|
+
},
|
|
13
|
+
type: {
|
|
14
|
+
initials: "bg-brand-subtle text-brand-foreground",
|
|
15
|
+
icon: "bg-muted text-foreground",
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
defaultVariants: {
|
|
19
|
+
size: "sm",
|
|
20
|
+
type: "initials",
|
|
21
|
+
},
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
export type AvatarSize = VariantProps<typeof avatarVariants>["size"];
|
|
25
|
+
export type AvatarType = VariantProps<typeof avatarVariants>["type"];
|
|
26
|
+
</script>
|
|
27
|
+
|
|
28
|
+
<script lang="ts">
|
|
29
|
+
import type { HTMLAttributes } from "svelte/elements";
|
|
30
|
+
import type { Snippet } from "svelte";
|
|
31
|
+
import { cn, tv } from "../../../utils.js";
|
|
32
|
+
import { avatarInitials } from "./avatar-utils.js";
|
|
33
|
+
|
|
34
|
+
let {
|
|
35
|
+
class: className,
|
|
36
|
+
size = "sm",
|
|
37
|
+
type = "initials",
|
|
38
|
+
src = undefined,
|
|
39
|
+
alt = "",
|
|
40
|
+
name = "",
|
|
41
|
+
icon,
|
|
42
|
+
...restProps
|
|
43
|
+
}: HTMLAttributes<HTMLSpanElement> & {
|
|
44
|
+
size?: AvatarSize;
|
|
45
|
+
type?: AvatarType;
|
|
46
|
+
src?: string;
|
|
47
|
+
alt?: string;
|
|
48
|
+
name?: string;
|
|
49
|
+
icon?: Snippet;
|
|
50
|
+
} = $props();
|
|
51
|
+
|
|
52
|
+
const initials = $derived(avatarInitials(name || alt));
|
|
53
|
+
</script>
|
|
54
|
+
|
|
55
|
+
<span class={cn(avatarVariants({ size, type }), className)} {...restProps}>
|
|
56
|
+
{#if src}
|
|
57
|
+
<img {src} {alt} class="size-full object-cover" />
|
|
58
|
+
{:else if type === "icon" && icon}
|
|
59
|
+
<span class="flex items-center justify-center">{@render icon()}</span>
|
|
60
|
+
{:else}
|
|
61
|
+
<span aria-hidden="true">{initials}</span>
|
|
62
|
+
{/if}
|
|
63
|
+
</span>
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import type { VariantProps } from "tailwind-variants";
|
|
2
|
+
export declare const avatarVariants: import("tailwind-variants").TVReturnType<{
|
|
3
|
+
size: {
|
|
4
|
+
sm: string;
|
|
5
|
+
default: string;
|
|
6
|
+
lg: string;
|
|
7
|
+
};
|
|
8
|
+
type: {
|
|
9
|
+
initials: string;
|
|
10
|
+
icon: string;
|
|
11
|
+
};
|
|
12
|
+
}, undefined, "relative inline-flex shrink-0 items-center justify-center overflow-hidden rounded-full bg-brand-subtle text-brand-foreground", {
|
|
13
|
+
responsiveVariants?: boolean | (string | number | symbol)[] | {
|
|
14
|
+
size?: boolean | (string | number | symbol)[] | undefined;
|
|
15
|
+
type?: boolean | (string | number | symbol)[] | undefined;
|
|
16
|
+
} | undefined;
|
|
17
|
+
} & import("tailwind-variants/dist/config.js").TWMConfig & {
|
|
18
|
+
twMergeConfig: {
|
|
19
|
+
classGroups: {
|
|
20
|
+
"font-size": {
|
|
21
|
+
text: ("display-hero" | "heading-page" | "heading-section" | "body" | "body-medium" | "body-large" | "caption" | "caption-medium" | "label" | "label-small" | "code")[];
|
|
22
|
+
}[];
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
}, {
|
|
26
|
+
size: {
|
|
27
|
+
sm: string;
|
|
28
|
+
default: string;
|
|
29
|
+
lg: string;
|
|
30
|
+
};
|
|
31
|
+
type: {
|
|
32
|
+
initials: string;
|
|
33
|
+
icon: string;
|
|
34
|
+
};
|
|
35
|
+
}, undefined, import("tailwind-variants").TVReturnType<{
|
|
36
|
+
size: {
|
|
37
|
+
sm: string;
|
|
38
|
+
default: string;
|
|
39
|
+
lg: string;
|
|
40
|
+
};
|
|
41
|
+
type: {
|
|
42
|
+
initials: string;
|
|
43
|
+
icon: string;
|
|
44
|
+
};
|
|
45
|
+
}, undefined, "relative inline-flex shrink-0 items-center justify-center overflow-hidden rounded-full bg-brand-subtle text-brand-foreground", import("tailwind-variants/dist/config.js").TVConfig<{
|
|
46
|
+
size: {
|
|
47
|
+
sm: string;
|
|
48
|
+
default: string;
|
|
49
|
+
lg: string;
|
|
50
|
+
};
|
|
51
|
+
type: {
|
|
52
|
+
initials: string;
|
|
53
|
+
icon: string;
|
|
54
|
+
};
|
|
55
|
+
}, {
|
|
56
|
+
size: {
|
|
57
|
+
sm: string;
|
|
58
|
+
default: string;
|
|
59
|
+
lg: string;
|
|
60
|
+
};
|
|
61
|
+
type: {
|
|
62
|
+
initials: string;
|
|
63
|
+
icon: string;
|
|
64
|
+
};
|
|
65
|
+
}>, unknown, unknown, undefined>>;
|
|
66
|
+
export type AvatarSize = VariantProps<typeof avatarVariants>["size"];
|
|
67
|
+
export type AvatarType = VariantProps<typeof avatarVariants>["type"];
|
|
68
|
+
import type { HTMLAttributes } from "svelte/elements";
|
|
69
|
+
import type { Snippet } from "svelte";
|
|
70
|
+
type $$ComponentProps = HTMLAttributes<HTMLSpanElement> & {
|
|
71
|
+
size?: AvatarSize;
|
|
72
|
+
type?: AvatarType;
|
|
73
|
+
src?: string;
|
|
74
|
+
alt?: string;
|
|
75
|
+
name?: string;
|
|
76
|
+
icon?: Snippet;
|
|
77
|
+
};
|
|
78
|
+
declare const Avatar: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
79
|
+
type Avatar = ReturnType<typeof Avatar>;
|
|
80
|
+
export default Avatar;
|
|
@@ -1,17 +1,15 @@
|
|
|
1
|
+
<!-- Figma: Badge (component set 50:4, node 50:2). -->
|
|
1
2
|
<script lang="ts" module>
|
|
2
|
-
import {
|
|
3
|
+
import type { VariantProps } from "tailwind-variants";
|
|
3
4
|
|
|
4
5
|
export const badgeVariants = tv({
|
|
5
|
-
base: "
|
|
6
|
+
base: "inline-flex h-5 max-w-full items-center gap-1.5 rounded-full border border-transparent px-2 text-label-small focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background",
|
|
6
7
|
variants: {
|
|
7
8
|
variant: {
|
|
8
|
-
default:
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
destructive:
|
|
13
|
-
"bg-destructive text-destructive-foreground hover:bg-destructive/80 border-transparent",
|
|
14
|
-
outline: "text-foreground",
|
|
9
|
+
default: "bg-secondary text-secondary-foreground",
|
|
10
|
+
secondary: "bg-brand-subtle text-brand-foreground",
|
|
11
|
+
destructive: "bg-destructive text-destructive-foreground",
|
|
12
|
+
outline: "border-border bg-transparent text-foreground",
|
|
15
13
|
},
|
|
16
14
|
},
|
|
17
15
|
defaultVariants: {
|
|
@@ -25,17 +23,19 @@
|
|
|
25
23
|
<script lang="ts">
|
|
26
24
|
import type { WithElementRef } from "bits-ui";
|
|
27
25
|
import type { HTMLAnchorAttributes } from "svelte/elements";
|
|
28
|
-
import { cn } from "../../../utils.js";
|
|
26
|
+
import { cn, tv } from "../../../utils.js";
|
|
29
27
|
|
|
30
28
|
let {
|
|
31
29
|
ref = $bindable(null),
|
|
32
30
|
href,
|
|
33
31
|
class: className,
|
|
34
32
|
variant = "default",
|
|
33
|
+
showDot = false,
|
|
35
34
|
children,
|
|
36
35
|
...restProps
|
|
37
36
|
}: WithElementRef<HTMLAnchorAttributes> & {
|
|
38
37
|
variant?: BadgeVariant;
|
|
38
|
+
showDot?: boolean;
|
|
39
39
|
} = $props();
|
|
40
40
|
</script>
|
|
41
41
|
|
|
@@ -46,5 +46,17 @@
|
|
|
46
46
|
class={cn(badgeVariants({ variant }), className)}
|
|
47
47
|
{...restProps}
|
|
48
48
|
>
|
|
49
|
+
{#if showDot}
|
|
50
|
+
<span
|
|
51
|
+
class={cn(
|
|
52
|
+
"size-1.5 shrink-0 rounded-full bg-current",
|
|
53
|
+
variant === "default" && "bg-secondary-foreground",
|
|
54
|
+
variant === "secondary" && "bg-brand-foreground",
|
|
55
|
+
variant === "destructive" && "bg-destructive-foreground",
|
|
56
|
+
variant === "outline" && "bg-foreground"
|
|
57
|
+
)}
|
|
58
|
+
aria-hidden="true"
|
|
59
|
+
></span>
|
|
60
|
+
{/if}
|
|
49
61
|
{@render children?.()}
|
|
50
62
|
</svelte:element>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { VariantProps } from "tailwind-variants";
|
|
2
2
|
export declare const badgeVariants: import("tailwind-variants").TVReturnType<{
|
|
3
3
|
variant: {
|
|
4
4
|
default: string;
|
|
@@ -6,12 +6,17 @@ export declare const badgeVariants: import("tailwind-variants").TVReturnType<{
|
|
|
6
6
|
destructive: string;
|
|
7
7
|
outline: string;
|
|
8
8
|
};
|
|
9
|
-
}, undefined, "
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
}, undefined, "inline-flex h-5 max-w-full items-center gap-1.5 rounded-full border border-transparent px-2 text-label-small focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background", {
|
|
10
|
+
responsiveVariants?: boolean | (string | number | symbol)[] | {
|
|
11
|
+
variant?: boolean | (string | number | symbol)[] | undefined;
|
|
12
|
+
} | undefined;
|
|
13
|
+
} & import("tailwind-variants/dist/config.js").TWMConfig & {
|
|
14
|
+
twMergeConfig: {
|
|
15
|
+
classGroups: {
|
|
16
|
+
"font-size": {
|
|
17
|
+
text: ("display-hero" | "heading-page" | "heading-section" | "body" | "body-medium" | "body-large" | "caption" | "caption-medium" | "label" | "label-small" | "code")[];
|
|
18
|
+
}[];
|
|
19
|
+
};
|
|
15
20
|
};
|
|
16
21
|
}, {
|
|
17
22
|
variant: {
|
|
@@ -20,13 +25,6 @@ export declare const badgeVariants: import("tailwind-variants").TVReturnType<{
|
|
|
20
25
|
destructive: string;
|
|
21
26
|
outline: string;
|
|
22
27
|
};
|
|
23
|
-
}>, {
|
|
24
|
-
variant: {
|
|
25
|
-
default: string;
|
|
26
|
-
secondary: string;
|
|
27
|
-
destructive: string;
|
|
28
|
-
outline: string;
|
|
29
|
-
};
|
|
30
28
|
}, undefined, import("tailwind-variants").TVReturnType<{
|
|
31
29
|
variant: {
|
|
32
30
|
default: string;
|
|
@@ -34,7 +32,7 @@ export declare const badgeVariants: import("tailwind-variants").TVReturnType<{
|
|
|
34
32
|
destructive: string;
|
|
35
33
|
outline: string;
|
|
36
34
|
};
|
|
37
|
-
}, undefined, "
|
|
35
|
+
}, undefined, "inline-flex h-5 max-w-full items-center gap-1.5 rounded-full border border-transparent px-2 text-label-small focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background", import("tailwind-variants/dist/config.js").TVConfig<{
|
|
38
36
|
variant: {
|
|
39
37
|
default: string;
|
|
40
38
|
secondary: string;
|
|
@@ -54,6 +52,7 @@ import type { WithElementRef } from "bits-ui";
|
|
|
54
52
|
import type { HTMLAnchorAttributes } from "svelte/elements";
|
|
55
53
|
type $$ComponentProps = WithElementRef<HTMLAnchorAttributes> & {
|
|
56
54
|
variant?: BadgeVariant;
|
|
55
|
+
showDot?: boolean;
|
|
57
56
|
};
|
|
58
57
|
declare const Badge: import("svelte").Component<$$ComponentProps, {}, "ref">;
|
|
59
58
|
type Badge = ReturnType<typeof Badge>;
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
</script>
|
|
5
5
|
|
|
6
6
|
<script lang="ts">
|
|
7
|
-
import
|
|
7
|
+
import IconDots from "@tabler/icons-svelte/icons/dots";
|
|
8
8
|
import type { WithElementRef, WithoutChildren } from "bits-ui";
|
|
9
9
|
import type { HTMLAttributes } from "svelte/elements";
|
|
10
10
|
import { cn } from "../../../utils.js";
|
|
@@ -23,6 +23,6 @@
|
|
|
23
23
|
class={cn("flex size-9 items-center justify-center", className)}
|
|
24
24
|
{...restProps}
|
|
25
25
|
>
|
|
26
|
-
<
|
|
26
|
+
<IconDots class="size-4 stroke-[1.333]" />
|
|
27
27
|
<span class="sr-only">More</span>
|
|
28
28
|
</span>
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
} = $props();
|
|
17
17
|
|
|
18
18
|
const attrs = $derived({
|
|
19
|
-
class: cn("hover:text-foreground transition-colors", className),
|
|
19
|
+
class: cn("text-caption-medium text-muted-foreground hover:text-foreground transition-colors duration-fast", className),
|
|
20
20
|
href,
|
|
21
21
|
...restProps,
|
|
22
22
|
});
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
</script>
|
|
5
5
|
|
|
6
6
|
<script lang="ts">
|
|
7
|
-
import
|
|
7
|
+
import IconChevronRight from "@tabler/icons-svelte/icons/chevron-right";
|
|
8
8
|
import type { WithElementRef } from "bits-ui";
|
|
9
9
|
import type { HTMLLiAttributes } from "svelte/elements";
|
|
10
10
|
import { cn } from "../../../utils.js";
|
|
@@ -27,6 +27,6 @@
|
|
|
27
27
|
{#if children}
|
|
28
28
|
{@render children?.()}
|
|
29
29
|
{:else}
|
|
30
|
-
<
|
|
30
|
+
<IconChevronRight class="stroke-[1.333] rtl:-scale-x-100" />
|
|
31
31
|
{/if}
|
|
32
32
|
</li>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* True when a `class` string sets the padding of a side: `p-0`, `px-2`, `ps-4`, `pr-1`, also with a modifier in front
|
|
3
|
+
* (`!px-3`, `md:px-2`, `[&_svg]:p-0`) or behind it (`px-3!`).
|
|
4
|
+
*
|
|
5
|
+
* The Button reads this to leave its icon rule out (Figma pads the icon side by 12 and the label side by 16, see the note
|
|
6
|
+
* at the top of `button.svelte`): a caller that has chosen the sides itself, like an icon-only button with `p-0`, would
|
|
7
|
+
* otherwise get one of them changed by a rule it knows nothing about.
|
|
8
|
+
*/
|
|
9
|
+
export declare function classNameSetsPadding(className: string | null | undefined): boolean;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* True when a `class` string sets the padding of a side: `p-0`, `px-2`, `ps-4`, `pr-1`, also with a modifier in front
|
|
3
|
+
* (`!px-3`, `md:px-2`, `[&_svg]:p-0`) or behind it (`px-3!`).
|
|
4
|
+
*
|
|
5
|
+
* The Button reads this to leave its icon rule out (Figma pads the icon side by 12 and the label side by 16, see the note
|
|
6
|
+
* at the top of `button.svelte`): a caller that has chosen the sides itself, like an icon-only button with `p-0`, would
|
|
7
|
+
* otherwise get one of them changed by a rule it knows nothing about.
|
|
8
|
+
*/
|
|
9
|
+
export function classNameSetsPadding(className) {
|
|
10
|
+
if (!className)
|
|
11
|
+
return false;
|
|
12
|
+
// The utility has to start a class name (`px-` in `placeholder-x` or `peer-x` is not a padding): at the start, after a
|
|
13
|
+
// space or after the `:` of a modifier. The hyphen after the letters is what tells `pl-` from `placeholder`.
|
|
14
|
+
return /(^|[\s:])!?-?(?:p|px|ps|pe|pl|pr)-/.test(className);
|
|
15
|
+
}
|
|
@@ -1,48 +1,102 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
Figma: Button (component set 33:4, page Button); Button Small (33:215) maps to size `sm`.
|
|
3
|
+
Width: the button pads its sides by 12 (small: 8) and the label sits in a box with 4 more on each side, so a button with
|
|
4
|
+
only a label is the text + 32 wide (small: + 24). With an icon first it is the text + 48 (small: + 40): the icon touches
|
|
5
|
+
the 12 and the label keeps its 4 + 12 on the other side; with an icon at each end both sides are 12 (text + 64).
|
|
6
|
+
The 1px stroke of Outline and Stroke sits inside that padding and takes no room in Figma.
|
|
7
|
+
With bits-ui triggers (Dialog, DropdownMenu, Tooltip, …), use `{#snippet child({ props })}` and spread
|
|
8
|
+
`props` onto `<Button {...props}>` — do not wrap `<Button>` inside a default trigger (nested buttons).
|
|
9
|
+
-->
|
|
1
10
|
<script lang="ts" module>
|
|
2
11
|
import type { WithElementRef } from "bits-ui";
|
|
3
12
|
import type { HTMLAnchorAttributes, HTMLButtonAttributes } from "svelte/elements";
|
|
4
|
-
import {
|
|
13
|
+
import type { VariantProps } from "tailwind-variants";
|
|
5
14
|
|
|
6
15
|
export const buttonVariants = tv({
|
|
7
|
-
base: "
|
|
16
|
+
base: "inline-flex items-center justify-center gap-1 whitespace-nowrap rounded-lg text-label transition-colors duration-fast press-feedback 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 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 [&_svg]:stroke-[1.333]",
|
|
8
17
|
variants: {
|
|
9
18
|
variant: {
|
|
10
19
|
default: "bg-primary text-primary-foreground hover:bg-primary/90",
|
|
11
|
-
destructive:
|
|
20
|
+
destructive:
|
|
21
|
+
"bg-destructive text-destructive-foreground hover:bg-destructive/90",
|
|
12
22
|
outline:
|
|
13
|
-
"border-input bg-background hover:bg-accent hover:text-
|
|
14
|
-
secondary:
|
|
15
|
-
|
|
23
|
+
"border border-input bg-background text-foreground hover:bg-accent hover:text-foreground",
|
|
24
|
+
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",
|
|
28
|
+
stroke:
|
|
29
|
+
"border border-border-strong/30 bg-transparent text-foreground hover:bg-accent hover:text-foreground",
|
|
16
30
|
link: "text-primary underline-offset-4 hover:underline",
|
|
17
31
|
},
|
|
18
32
|
size: {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
33
|
+
// The 12 of the side (small: 8) and the 4 of the label box (see the note at the top), as Figma
|
|
34
|
+
default: "h-9 px-4",
|
|
35
|
+
sm: "h-8 px-3",
|
|
36
|
+
lg: "h-10 px-6",
|
|
37
|
+
icon: "h-9 w-9",
|
|
38
|
+
"icon-sm": "h-8 w-8",
|
|
39
|
+
},
|
|
40
|
+
// Switched on by the Button below and not by every caller of `buttonVariants` (a calendar cell or a menu trigger
|
|
41
|
+
// sets its own padding): an icon sits at the side with no label box, so that side is 12 (small: 8)
|
|
42
|
+
iconPadding: {
|
|
43
|
+
true: "",
|
|
44
|
+
false: "",
|
|
23
45
|
},
|
|
24
46
|
},
|
|
47
|
+
compoundVariants: [
|
|
48
|
+
// The first icon is taken as the leading one (CSS cannot tell a leading icon from a trailing one, text is no
|
|
49
|
+
// element); a second icon makes the other side 12 as well. Either way the width is the one Figma draws.
|
|
50
|
+
{
|
|
51
|
+
size: "default",
|
|
52
|
+
iconPadding: true,
|
|
53
|
+
class: "has-[>svg]:ps-3 has-[>svg:nth-of-type(2)]:pe-3",
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
size: "sm",
|
|
57
|
+
iconPadding: true,
|
|
58
|
+
class: "has-[>svg]:ps-2 has-[>svg:nth-of-type(2)]:pe-2",
|
|
59
|
+
},
|
|
60
|
+
// Figma draws the 1px stroke of Outline and Stroke inside the padding, a CSS border sits outside it: those two take
|
|
61
|
+
// 1px off every side, so that they are as wide as the other styles
|
|
62
|
+
{ variant: ["outline", "stroke"], size: "default", class: "px-[15px]" },
|
|
63
|
+
{ variant: ["outline", "stroke"], size: "sm", class: "px-[11px]" },
|
|
64
|
+
{
|
|
65
|
+
variant: ["outline", "stroke"],
|
|
66
|
+
size: "default",
|
|
67
|
+
iconPadding: true,
|
|
68
|
+
class: "has-[>svg]:ps-[11px] has-[>svg:nth-of-type(2)]:pe-[11px]",
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
variant: ["outline", "stroke"],
|
|
72
|
+
size: "sm",
|
|
73
|
+
iconPadding: true,
|
|
74
|
+
class: "has-[>svg]:ps-[7px] has-[>svg:nth-of-type(2)]:pe-[7px]",
|
|
75
|
+
},
|
|
76
|
+
],
|
|
25
77
|
defaultVariants: {
|
|
26
78
|
variant: "default",
|
|
27
79
|
size: "default",
|
|
80
|
+
iconPadding: false,
|
|
28
81
|
},
|
|
29
82
|
});
|
|
30
83
|
|
|
31
84
|
export type ButtonVariant = VariantProps<typeof buttonVariants>["variant"];
|
|
32
85
|
export type ButtonSize = VariantProps<typeof buttonVariants>["size"];
|
|
33
86
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
87
|
+
export type ButtonProps = WithElementRef<HTMLButtonAttributes> &
|
|
88
|
+
WithElementRef<HTMLAnchorAttributes> & {
|
|
89
|
+
ref?: any;
|
|
90
|
+
href?: string;
|
|
91
|
+
class?: string;
|
|
92
|
+
variant?: ButtonVariant;
|
|
93
|
+
size?: ButtonSize;
|
|
94
|
+
};
|
|
42
95
|
</script>
|
|
43
96
|
|
|
44
97
|
<script lang="ts">
|
|
45
|
-
import { cn } from "../../../utils.js";
|
|
98
|
+
import { cn, tv } from "../../../utils.js";
|
|
99
|
+
import { classNameSetsPadding } from "./button-padding.js";
|
|
46
100
|
|
|
47
101
|
let {
|
|
48
102
|
class: className,
|
|
@@ -54,24 +108,20 @@
|
|
|
54
108
|
children,
|
|
55
109
|
...restProps
|
|
56
110
|
}: ButtonProps = $props();
|
|
111
|
+
|
|
112
|
+
// A caller that sets the padding itself (`p-0` on an icon-only button, `px-2`, `!px-3`, …) has chosen the sides: the rule
|
|
113
|
+
// for an icon would change one of them, so it stays off then
|
|
114
|
+
const classes = $derived(
|
|
115
|
+
cn(buttonVariants({ variant, size, iconPadding: !classNameSetsPadding(className), className })),
|
|
116
|
+
);
|
|
57
117
|
</script>
|
|
58
118
|
|
|
59
119
|
{#if href}
|
|
60
|
-
<a
|
|
61
|
-
bind:this={ref}
|
|
62
|
-
class={cn(buttonVariants({ variant, size, className }))}
|
|
63
|
-
{href}
|
|
64
|
-
{...restProps}
|
|
65
|
-
>
|
|
120
|
+
<a bind:this={ref} class={classes} {href} {...restProps}>
|
|
66
121
|
{@render children?.()}
|
|
67
122
|
</a>
|
|
68
123
|
{:else}
|
|
69
|
-
<button
|
|
70
|
-
bind:this={ref}
|
|
71
|
-
class={cn(buttonVariants({ variant, size, className }))}
|
|
72
|
-
{type}
|
|
73
|
-
{...restProps}
|
|
74
|
-
>
|
|
124
|
+
<button bind:this={ref} class={classes} {type} {...restProps}>
|
|
75
125
|
{@render children?.()}
|
|
76
126
|
</button>
|
|
77
127
|
{/if}
|