@infonomic/uikit 2.0.0 → 2.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/components/card/card.d.ts.map +1 -1
- package/package.json +9 -5
- package/src/astro.d.ts +43 -0
- package/src/astro.js +2 -2
- package/src/components/@types/shared.ts +24 -0
- package/src/components/accordion/accordion.module.css +60 -0
- package/src/components/accordion/accordion.stories.tsx +117 -0
- package/src/components/accordion/accordion.tsx +105 -0
- package/src/components/animation/fade-in-lift.stories.tsx +81 -0
- package/src/components/animation/fade-in-lift.tsx +42 -0
- package/src/components/avatar/avatar.module.css +54 -0
- package/src/components/avatar/avatar.stories.tsx +28 -0
- package/src/components/avatar/avatar.tsx +19 -0
- package/src/components/button/@types/button.ts +17 -0
- package/src/components/button/button-group.module.css +17 -0
- package/src/components/button/button-group.stories.tsx +45 -0
- package/src/components/button/button-group.tsx +132 -0
- package/src/components/button/button-icon.stories.tsx +145 -0
- package/src/components/button/button-intents.stories.tsx +50 -0
- package/src/components/button/button-variants.stories.tsx +60 -0
- package/src/components/button/button.astro +86 -0
- package/src/components/button/button.module.css +533 -0
- package/src/components/button/button.tsx +81 -0
- package/src/components/button/control-buttons.module.css +144 -0
- package/src/components/button/control-buttons.stories.tsx +60 -0
- package/src/components/button/control-buttons.tsx +137 -0
- package/src/components/button/copy-button.module.css +31 -0
- package/src/components/button/copy-button.stories.tsx +50 -0
- package/src/components/button/copy-button.tsx +92 -0
- package/src/components/button/icon-button.astro +47 -0
- package/src/components/button/icon-button.tsx +44 -0
- package/src/components/button/index.ts +5 -0
- package/src/components/calendar/calendar.module.css +315 -0
- package/src/components/calendar/calendar.stories.tsx +139 -0
- package/src/components/calendar/calendar.tsx +173 -0
- package/src/components/card/card-content.astro +14 -0
- package/src/components/card/card-description.astro +14 -0
- package/src/components/card/card-footer.astro +14 -0
- package/src/components/card/card-header.astro +14 -0
- package/src/components/card/card-title.astro +14 -0
- package/src/components/card/card.astro +41 -0
- package/src/components/card/card.module.css +67 -0
- package/src/components/card/card.stories.tsx +61 -0
- package/src/components/card/card.tsx +86 -0
- package/src/components/container/container.astro +13 -0
- package/src/components/container/container.module.css +28 -0
- package/src/components/container/container.stories.tsx +42 -0
- package/src/components/container/container.tsx +23 -0
- package/src/components/dropdown/dropdown.module.css +131 -0
- package/src/components/dropdown/dropdown.stories.tsx +103 -0
- package/src/components/dropdown/dropdown.tsx +193 -0
- package/src/components/hamburger/hamburger.astro +30 -0
- package/src/components/hamburger/hamburger.tsx +66 -0
- package/src/components/input/@types/checkbox.ts +20 -0
- package/src/components/input/@types/input.ts +20 -0
- package/src/components/input/checkbox-group.tsx +78 -0
- package/src/components/input/checkbox.module.css +267 -0
- package/src/components/input/checkbox.stories.tsx +240 -0
- package/src/components/input/checkbox.tsx +95 -0
- package/src/components/input/error-text.astro +14 -0
- package/src/components/input/error-text.module.css +19 -0
- package/src/components/input/error-text.tsx +18 -0
- package/src/components/input/errors.tsx +37 -0
- package/src/components/input/help-text.astro +13 -0
- package/src/components/input/help-text.module.css +19 -0
- package/src/components/input/help-text.tsx +13 -0
- package/src/components/input/index.tsx +8 -0
- package/src/components/input/input-adornment.astro +26 -0
- package/src/components/input/input-adornment.module.css +18 -0
- package/src/components/input/input-adornment.tsx +36 -0
- package/src/components/input/input.astro +99 -0
- package/src/components/input/input.module.css +310 -0
- package/src/components/input/input.stories.tsx +174 -0
- package/src/components/input/input.tsx +103 -0
- package/src/components/input/label.astro +24 -0
- package/src/components/input/label.module.css +28 -0
- package/src/components/input/label.tsx +25 -0
- package/src/components/input/radio-group.module.css +219 -0
- package/src/components/input/radio-group.stories.tsx +73 -0
- package/src/components/input/radio-group.tsx +67 -0
- package/src/components/input/select.module.css +75 -0
- package/src/components/input/select.stories.tsx +34 -0
- package/src/components/input/select.tsx +115 -0
- package/src/components/input/text-area.module.css +9 -0
- package/src/components/input/text-area.stories.tsx +51 -0
- package/src/components/input/text-area.tsx +81 -0
- package/src/components/input/utils.ts +21 -0
- package/src/components/notifications/@types/alert.ts +12 -0
- package/src/components/notifications/@types/toast.ts +12 -0
- package/src/components/notifications/alert.module.css +114 -0
- package/src/components/notifications/alert.stories.tsx +39 -0
- package/src/components/notifications/alert.tsx +117 -0
- package/src/components/notifications/index.ts +2 -0
- package/src/components/notifications/toast.module.css +237 -0
- package/src/components/notifications/toast.stories.tsx +42 -0
- package/src/components/notifications/toast.tsx +124 -0
- package/src/components/overlay/index.stories.tsx +29 -0
- package/src/components/overlay/index.ts +2 -0
- package/src/components/overlay/overlay.module.css +41 -0
- package/src/components/overlay/overlay.tsx +61 -0
- package/src/components/pager/@types/index.ts +2 -0
- package/src/components/pager/ellipses.tsx +18 -0
- package/src/components/pager/event-pager.tsx +18 -0
- package/src/components/pager/first-button.tsx +53 -0
- package/src/components/pager/hooks/types/usePagination.ts +80 -0
- package/src/components/pager/hooks/usePagination.ts +140 -0
- package/src/components/pager/icons/first.tsx +33 -0
- package/src/components/pager/icons/index.tsx +4 -0
- package/src/components/pager/icons/last.tsx +33 -0
- package/src/components/pager/icons/next.tsx +20 -0
- package/src/components/pager/icons/previous.tsx +20 -0
- package/src/components/pager/index.ts +4 -0
- package/src/components/pager/last-button.tsx +57 -0
- package/src/components/pager/next-button.tsx +55 -0
- package/src/components/pager/number-button.tsx +83 -0
- package/src/components/pager/pagination.module.css +165 -0
- package/src/components/pager/pagination.stories.tsx +190 -0
- package/src/components/pager/pagination.tsx +266 -0
- package/src/components/pager/previous-button.tsx +51 -0
- package/src/components/scroll-area/scroll-area.module.css +80 -0
- package/src/components/scroll-area/scroll-area.stories.tsx +33 -0
- package/src/components/scroll-area/scroll-area.tsx +22 -0
- package/src/components/scroll-to-top/scroll-to-top.tsx +59 -0
- package/src/components/section/section.astro +13 -0
- package/src/components/section/section.module.css +7 -0
- package/src/components/section/section.tsx +23 -0
- package/src/components/shimmer/shimmer.module.css +53 -0
- package/src/components/shimmer/shimmer.stories.tsx +24 -0
- package/src/components/shimmer/shimmer.tsx +70 -0
- package/src/components/table/table.module.css +100 -0
- package/src/components/table/table.stories.tsx +95 -0
- package/src/components/table/table.tsx +165 -0
- package/src/components/tabs/tabs.module.css +64 -0
- package/src/components/tabs/tabs.stories.tsx +47 -0
- package/src/components/tabs/tabs.tsx +75 -0
- package/src/components/timeline/timeline.module.css +87 -0
- package/src/components/timeline/timeline.stories.tsx +50 -0
- package/src/components/timeline/timeline.tsx +177 -0
- package/src/components/tooltip/tooltip.module.css +55 -0
- package/src/components/tooltip/tooltip.stories.tsx +59 -0
- package/src/components/tooltip/tooltip.tsx +51 -0
- package/src/declarations.d.ts +4 -0
- package/src/hooks/use-media-query.ts +20 -0
- package/src/icons/activity-icon.tsx +40 -0
- package/src/icons/calendar-icon.tsx +39 -0
- package/src/icons/check-icon.tsx +33 -0
- package/src/icons/chevron-down-icon.tsx +39 -0
- package/src/icons/chevron-left-double-icon.tsx +58 -0
- package/src/icons/chevron-left-icon.tsx +58 -0
- package/src/icons/chevron-right-double-icon.tsx +58 -0
- package/src/icons/chevron-right-icon.tsx +58 -0
- package/src/icons/chevrons-up-down.tsx +37 -0
- package/src/icons/close-icon.astro +38 -0
- package/src/icons/close-icon.tsx +30 -0
- package/src/icons/copy-icon.tsx +35 -0
- package/src/icons/danger-icon.tsx +18 -0
- package/src/icons/dashboard-icon.tsx +41 -0
- package/src/icons/delete-icon.tsx +34 -0
- package/src/icons/document-icon.tsx +38 -0
- package/src/icons/download-icon.tsx +39 -0
- package/src/icons/edit-icon.tsx +35 -0
- package/src/icons/ellipsis-icon.tsx +38 -0
- package/src/icons/email-icon.tsx +33 -0
- package/src/icons/external-link-icon.tsx +39 -0
- package/src/icons/github-icon.tsx +27 -0
- package/src/icons/globe-icon.tsx +50 -0
- package/src/icons/google-icon.tsx +44 -0
- package/src/icons/gripper-vertical-icon.tsx +43 -0
- package/src/icons/history-icon.tsx +32 -0
- package/src/icons/home-icon.tsx +34 -0
- package/src/icons/icon-element.astro +27 -0
- package/src/icons/icon-element.tsx +32 -0
- package/src/icons/icon-sprite.tsx +18 -0
- package/src/icons/icons.module.css +147 -0
- package/src/icons/index.stories.tsx +25 -0
- package/src/icons/index.ts +39 -0
- package/src/icons/info-icon.tsx +18 -0
- package/src/icons/infonomic-icon.tsx +173 -0
- package/src/icons/light-icon.astro +36 -0
- package/src/icons/light-icon.tsx +29 -0
- package/src/icons/location-pin-icon.tsx +36 -0
- package/src/icons/moon-icon.astro +38 -0
- package/src/icons/moon-icon.tsx +42 -0
- package/src/icons/plus-icon.tsx +34 -0
- package/src/icons/primary-icon.tsx +22 -0
- package/src/icons/refresh-icon.tsx +33 -0
- package/src/icons/return-icon.tsx +36 -0
- package/src/icons/roles-icon.tsx +34 -0
- package/src/icons/search-icon.astro +40 -0
- package/src/icons/search-icon.tsx +29 -0
- package/src/icons/search-menu-icon.tsx +42 -0
- package/src/icons/settings-gear-icon.tsx +36 -0
- package/src/icons/settings-sliders-icon.tsx +43 -0
- package/src/icons/sign-out-icon.tsx +35 -0
- package/src/icons/source/icon-calendar.svg +1 -0
- package/src/icons/source/icon-check.svg +4 -0
- package/src/icons/source/icon-close.svg +3 -0
- package/src/icons/source/icon-coinbase.svg +9 -0
- package/src/icons/source/icon-copy.svg +4 -0
- package/src/icons/source/icon-document.svg +5 -0
- package/src/icons/source/icon-download.svg +4 -0
- package/src/icons/source/icon-edit.svg +6 -0
- package/src/icons/source/icon-eth-purple.svg +15 -0
- package/src/icons/source/icon-etherscan.svg +5 -0
- package/src/icons/source/icon-external-link.svg +4 -0
- package/src/icons/source/icon-globe.svg +7 -0
- package/src/icons/source/icon-gripper-vertical.svg +9 -0
- package/src/icons/source/icon-info.svg +4 -0
- package/src/icons/source/icon-infonomic.svg +43 -0
- package/src/icons/source/icon-ledger.svg +4 -0
- package/src/icons/source/icon-light.svg +3 -0
- package/src/icons/source/icon-location-pin.svg +8 -0
- package/src/icons/source/icon-logout.svg +6 -0
- package/src/icons/source/icon-metamask.svg +32 -0
- package/src/icons/source/icon-moon.svg +3 -0
- package/src/icons/source/icon-plus.svg +4 -0
- package/src/icons/source/icon-refresh.svg +4 -0
- package/src/icons/source/icon-return.svg +4 -0
- package/src/icons/source/icon-search-menu.svg +13 -0
- package/src/icons/source/icon-search.svg +3 -0
- package/src/icons/source/icon-settings-gear.svg +5 -0
- package/src/icons/source/icon-settings.svg +12 -0
- package/src/icons/source/icon-wallet.svg +3 -0
- package/src/icons/source/icon-walletconnect.svg +4 -0
- package/src/icons/source/icon-x.svg +4 -0
- package/src/icons/stopwatch-icon.tsx +39 -0
- package/src/icons/success-icon.tsx +18 -0
- package/src/icons/types/icon.ts +8 -0
- package/src/icons/user-icon.tsx +33 -0
- package/src/icons/users-icon.tsx +35 -0
- package/src/icons/wallet-icon.tsx +29 -0
- package/src/icons/warning-icon.tsx +18 -0
- package/src/icons/x-icon.tsx +33 -0
- package/src/loaders/ellipses.tsx +36 -0
- package/src/loaders/loaders.stories.tsx +46 -0
- package/src/loaders/ring.tsx +33 -0
- package/src/loaders/spinner.tsx +28 -0
- package/src/loaders/types/index.ts +6 -0
- package/src/react.ts +99 -0
- package/src/styles/base/animations.css +143 -0
- package/src/styles/base/base.css +5 -0
- package/src/styles/base/colors.css +163 -0
- package/src/styles/base/colors.stories.tsx +671 -0
- package/src/styles/base/reset.css +464 -0
- package/src/styles/base/typography.css +25 -0
- package/src/styles/base/vars.css +188 -0
- package/src/styles/components/card.css +20 -0
- package/src/styles/components/checkbox.css +55 -0
- package/src/styles/components/components.css +11 -0
- package/src/styles/components/directional-button.css +92 -0
- package/src/styles/components/dropdown.css +19 -0
- package/src/styles/components/fade-in-lift.css +13 -0
- package/src/styles/components/hamburger.css +107 -0
- package/src/styles/components/icon-element.css +4 -0
- package/src/styles/components/list-checkbox.css +60 -0
- package/src/styles/components/loaders.css +196 -0
- package/src/styles/components/popover.css +15 -0
- package/src/styles/components/scroll-to-top.css +89 -0
- package/src/styles/components/toast.css +18 -0
- package/src/styles/styles.css +6 -0
- package/src/styles/theme/autofill.css +58 -0
- package/src/styles/theme/scrollers.css +52 -0
- package/src/styles/theme/theme.css +130 -0
- package/src/styles/theme/theme.stories.tsx +33 -0
- package/src/styles/typography/code.stories.tsx +76 -0
- package/src/styles/typography/default.stories.tsx +51 -0
- package/src/styles/typography/fonts.css +30 -0
- package/src/styles/typography/lists.stories.tsx +50 -0
- package/src/styles/typography/prose.css +404 -0
- package/src/styles/typography/quote.stories.tsx +37 -0
- package/src/styles/typography.css +24 -0
- package/src/styles/utils/scroll-layout-shift.css +9 -0
- package/src/styles/utils/utility-classes.css +1278 -0
- package/src/styles/utils/utils.css +2 -0
- package/src/theme/theme-provider/index.ts +1 -0
- package/src/theme/theme-provider/provider.tsx +44 -0
- package/src/utils/capitalize.ts +6 -0
- package/src/utils/externalLinkProps.ts +6 -0
- package/src/utils/findMatch.ts +7 -0
- package/src/utils/getPortalRoot.ts +3 -0
- package/src/utils/isTouchDevice.ts +11 -0
- package/src/utils/objectsToArray.ts +15 -0
- package/src/utils/objectsToString.ts +5 -0
- package/src/utils/polymorphic.ts +16 -0
- package/src/utils/to-kebab-case.ts +5 -0
- package/src/widgets/datepicker/datepicker.module.css +189 -0
- package/src/widgets/datepicker/datepicker.stories.tsx +25 -0
- package/src/widgets/datepicker/datepicker.tsx +310 -0
- package/src/widgets/drawer/drawer-container.tsx +26 -0
- package/src/widgets/drawer/drawer-content.tsx +26 -0
- package/src/widgets/drawer/drawer-context.tsx +49 -0
- package/src/widgets/drawer/drawer-header.tsx +27 -0
- package/src/widgets/drawer/drawer-top-actions.tsx +27 -0
- package/src/widgets/drawer/drawer-wrapper.tsx +54 -0
- package/src/widgets/drawer/drawer.module.css +116 -0
- package/src/widgets/drawer/drawer.stories.tsx +224 -0
- package/src/widgets/drawer/drawer.tsx +115 -0
- package/src/widgets/drawer/motionDomAnimation.ts +4 -0
- package/src/widgets/drawer/motionDomMax.ts +4 -0
- package/src/widgets/modal/modal-actions.tsx +26 -0
- package/src/widgets/modal/modal-container.tsx +26 -0
- package/src/widgets/modal/modal-content.tsx +26 -0
- package/src/widgets/modal/modal-header.tsx +27 -0
- package/src/widgets/modal/modal-wrapper.tsx +50 -0
- package/src/widgets/modal/modal.module.css +85 -0
- package/src/widgets/modal/modal.stories.tsx +71 -0
- package/src/widgets/modal/modal.tsx +110 -0
- package/src/widgets/modal/motionDomAnimation.ts +4 -0
- package/src/widgets/modal/motionDomMax.ts +4 -0
- package/src/widgets/search/index.ts +1 -0
- package/src/widgets/search/search.stories.tsx +18 -0
- package/src/widgets/search/search.tsx +186 -0
|
@@ -0,0 +1,533 @@
|
|
|
1
|
+
@layer infonomic-base, infonomic-utilities, infonomic-theme, infonomic-typography, infonomic-components;
|
|
2
|
+
|
|
3
|
+
@layer infonomic-components {
|
|
4
|
+
.button {
|
|
5
|
+
border: none;
|
|
6
|
+
cursor: pointer;
|
|
7
|
+
font-weight: normal;
|
|
8
|
+
text-align: center;
|
|
9
|
+
display: inline-flex;
|
|
10
|
+
gap: var(--gap-2);
|
|
11
|
+
line-height: 0;
|
|
12
|
+
align-items: center;
|
|
13
|
+
white-space: nowrap;
|
|
14
|
+
justify-content: center;
|
|
15
|
+
outline: 2px solid transparent;
|
|
16
|
+
outline-offset: 2px;
|
|
17
|
+
transition: background-color var(--transition-normal), box-shadow var(--transition-normal);
|
|
18
|
+
border-radius: var(--border-radius-sm);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.button:disabled,
|
|
22
|
+
.button[disabled] {
|
|
23
|
+
pointer-events: none;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.button:focus,
|
|
27
|
+
.button:active {
|
|
28
|
+
--ring-offset-color: var(--background);
|
|
29
|
+
--ring-offset-shadow: var(--ring-inset) 0 0 0 var(--ring-offset-width) var(--ring-offset-color);
|
|
30
|
+
--ring-shadow: var(--ring-inset) 0 0 0 calc(1px + var(--ring-offset-width)) var(--ring-color);
|
|
31
|
+
box-shadow: var(--ring-offset-shadow), var(--ring-shadow), var(--shadow, 0 0 #0000);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.button.square {
|
|
35
|
+
aspect-ratio: 1 / 1;
|
|
36
|
+
padding: 0;
|
|
37
|
+
border-radius: var(--border-radius-sm);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.button.round {
|
|
41
|
+
aspect-ratio: 1 / 1;
|
|
42
|
+
padding: 0;
|
|
43
|
+
border-radius: var(--border-radius-full);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/* Sizes */
|
|
47
|
+
.xs {
|
|
48
|
+
min-height: 26px;
|
|
49
|
+
font-size: 0.7rem;
|
|
50
|
+
padding: 0.2rem 0.4rem;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.sm {
|
|
54
|
+
min-height: 32px;
|
|
55
|
+
font-size: 0.775rem;
|
|
56
|
+
padding: 0.25rem 0.5rem;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.md {
|
|
60
|
+
min-height: 38px;
|
|
61
|
+
font-size: 0.95rem;
|
|
62
|
+
padding: 0.625rem 1.25rem;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.lg {
|
|
66
|
+
min-height: 46px;
|
|
67
|
+
font-size: 1.1rem;
|
|
68
|
+
padding: 0.75rem 1.5rem;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.xl {
|
|
72
|
+
min-height: 54px;
|
|
73
|
+
font-size: 1.2rem;
|
|
74
|
+
padding: 0.75rem 1.5rem;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/* Variants */
|
|
78
|
+
.filled {
|
|
79
|
+
color: var(--button-variant-filled-foreground);
|
|
80
|
+
background-color: var(--button-variant-filled);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
.filled:hover {
|
|
84
|
+
background-color: var(--button-variant-filled-hover);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.filled:focus,
|
|
88
|
+
.filled:active {
|
|
89
|
+
--ring-color: var(--button-ring-color);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
.filled:disabled,
|
|
93
|
+
.filled[disabled] {
|
|
94
|
+
background-color: oklch(from var(--button-variant-filled) calc(l * 1.1) calc(c * 0.85) h);
|
|
95
|
+
color: oklch(from var(--button-variant-filled-foreground) calc(l * 0.9) calc(c * 0.85) h);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
.outlined {
|
|
99
|
+
border: 1px solid var(--button-variant-outlined-border);
|
|
100
|
+
color: var(--button-variant-outlined-foreground);
|
|
101
|
+
background-color: var(--button-variant-outlined);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
.outlined:disabled,
|
|
105
|
+
.outlined[disabled] {
|
|
106
|
+
border-color: oklch(from var(--button-variant-outlined-border) calc(l * 1.5) calc(c * 0.8) h);
|
|
107
|
+
color: oklch(from var(--button-variant-outlined-foreground) calc(l * 1.1) calc(c * 0.7) h);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
.outlined:hover {
|
|
111
|
+
background-color: var(--button-variant-outlined-hover);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
.outlined:focus,
|
|
115
|
+
.outlined:active {
|
|
116
|
+
--ring-color: var(--button-ring-color);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
.gradient {
|
|
120
|
+
color: var(--button-variant-gradient-foreground);
|
|
121
|
+
background: linear-gradient(45deg,
|
|
122
|
+
var(--button-variant-gradient-start),
|
|
123
|
+
var(--button-variant-gradient-end));
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
.gradient:disabled,
|
|
127
|
+
.gradient[disabled] {
|
|
128
|
+
background: unset;
|
|
129
|
+
background-color: oklch(from var(--button-variant-gradient-end) calc(l * 1.2) calc(c * 0.85) h);
|
|
130
|
+
color: oklch(from var(--button-variant-gradient-foreground) calc(l * 0.9) calc(c * 0.85) h);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
.gradient:hover {
|
|
134
|
+
color: var(--button-variant-gradient-foreground);
|
|
135
|
+
background: linear-gradient(45deg,
|
|
136
|
+
var(--button-variant-gradient-start),
|
|
137
|
+
var(--button-variant-gradient-end));
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
.gradient:focus,
|
|
141
|
+
.gradient:active {
|
|
142
|
+
--ring-color: var(--button-ring-color);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
.text {
|
|
146
|
+
background-color: var(--button-variant-text);
|
|
147
|
+
color: var(--button-variant-text-foreground);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
.text:disabled,
|
|
151
|
+
.text[disabled] {
|
|
152
|
+
color: oklch(from var(--button-variant-text-foreground) calc(l * 1.5) calc(c * 0.5) h);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
.text:hover {
|
|
156
|
+
background-color: var(--button-variant-text-hover);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
.text:focus,
|
|
160
|
+
.text:active {
|
|
161
|
+
--ring-color: var(--button-ring-color);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/* Intents */
|
|
165
|
+
.primary {
|
|
166
|
+
--button: var(--primary-600);
|
|
167
|
+
--button-ring-color: var(--button);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
.primary.filled {
|
|
171
|
+
--button-variant-filled: var(--button);
|
|
172
|
+
--button-variant-filled-foreground: white;
|
|
173
|
+
--button-variant-filled-hover: oklch(from var(--button) calc(l * 0.9) c h);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
.primary.outlined {
|
|
177
|
+
--button-variant-outlined: transparent;
|
|
178
|
+
--button-variant-outlined-foreground: var(--primary-700);
|
|
179
|
+
--button-variant-outlined-hover: oklch(from var(--button) calc(l * 2.15) calc(c * 0.2) h);
|
|
180
|
+
--button-variant-outlined-border: var(--primary-700);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
.primary.text {
|
|
184
|
+
--button-variant-text: transparent;
|
|
185
|
+
--button-variant-text-foreground: oklch(from var(--button) calc(l * 0.7) c h);
|
|
186
|
+
--button-variant-text-hover: oklch(from var(--canvas-50) calc(l * 0.995) c h);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
.primary.gradient {
|
|
190
|
+
--button-variant-gradient-start: var(--primary-500);
|
|
191
|
+
--button-variant-gradient-end: var(--primary-700);
|
|
192
|
+
--button-variant-gradient-foreground: white;
|
|
193
|
+
--button-variant-gradient-hover: var(--gray-900);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
.secondary {
|
|
197
|
+
--button: var(--secondary-500);
|
|
198
|
+
--button-ring-color: var(--button);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
.secondary.filled {
|
|
202
|
+
--button-variant-filled: var(--button);
|
|
203
|
+
--button-variant-filled-foreground: black;
|
|
204
|
+
--button-variant-filled-hover: oklch(from var(--button) calc(l * 0.95) c h);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
.secondary.outlined {
|
|
208
|
+
--button-variant-outlined: transparent;
|
|
209
|
+
--button-variant-outlined-foreground: var(--secondary-950);
|
|
210
|
+
--button-variant-outlined-hover: oklch(from var(--button) calc(l * 1.6) calc(c * 0.2) h);
|
|
211
|
+
--button-variant-outlined-border: var(--secondary-700);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
.secondary.text {
|
|
215
|
+
--button-variant-text: transparent;
|
|
216
|
+
--button-variant-text-foreground: oklch(from var(--button) calc(l * 0.7) c h);
|
|
217
|
+
--button-variant-text-hover: oklch(from var(--canvas-50) calc(l * 0.995) c h);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
.secondary.gradient {
|
|
221
|
+
--button-variant-gradient-start: var(--secondary-500);
|
|
222
|
+
--button-variant-gradient-end: var(--secondary-700);
|
|
223
|
+
--button-variant-gradient-foreground: black;
|
|
224
|
+
--button-variant-gradient-hover: var(--gray-900);
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
.noeffect {
|
|
228
|
+
--button: var(--gray-100);
|
|
229
|
+
--button-ring-color: var(--gray-200);
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
.noeffect.filled {
|
|
233
|
+
--button-variant-filled: var(--button);
|
|
234
|
+
--button-variant-filled-foreground: black;
|
|
235
|
+
--button-variant-filled-hover: oklch(from var(--button) calc(l * 0.95) c h);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
.noeffect.outlined {
|
|
239
|
+
--button-variant-outlined: transparent;
|
|
240
|
+
--button-variant-outlined-foreground: var(--gray-800);
|
|
241
|
+
--button-variant-outlined-hover: oklch(from var(--button) calc(l * 2.9) calc(c * 0.2) h);
|
|
242
|
+
--button-variant-outlined-border: var(--gray-500);
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
.noeffect.text {
|
|
246
|
+
--button-variant-text: transparent;
|
|
247
|
+
--button-variant-text-foreground: oklch(from var(--button) calc(l * 0.5) c h);
|
|
248
|
+
--button-variant-text-hover: oklch(from var(--canvas-50) calc(l * 0.995) c h);
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
.noeffect.gradient {
|
|
252
|
+
--button-variant-gradient-start: var(--gray-100);
|
|
253
|
+
--button-variant-gradient-end: var(--gray-200);
|
|
254
|
+
--button-variant-gradient-foreground: black;
|
|
255
|
+
--button-variant-gradient-hover: var(--gray-400);
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
.success {
|
|
259
|
+
--button: var(--green-400);
|
|
260
|
+
--button-ring-color: var(--button);
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
.success.filled {
|
|
264
|
+
--button-variant-filled: var(--button);
|
|
265
|
+
--button-variant-filled-foreground: white;
|
|
266
|
+
--button-variant-filled-hover: oklch(from var(--button) calc(l * 0.9) c h);
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
.success.outlined {
|
|
270
|
+
--button-variant-outlined: transparent;
|
|
271
|
+
--button-variant-outlined-foreground: var(--green-600);
|
|
272
|
+
--button-variant-outlined-hover: oklch(from var(--button) calc(l * 1.6) calc(c * 0.2) h);
|
|
273
|
+
--button-variant-outlined-border: var(--green-600);
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
.success.text {
|
|
277
|
+
--button-variant-text: transparent;
|
|
278
|
+
--button-variant-text-foreground: oklch(from var(--button) calc(l * 0.7) c h);
|
|
279
|
+
--button-variant-text-hover: oklch(from var(--canvas-50) calc(l * 0.995) c h);
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
.success.gradient {
|
|
283
|
+
--button-variant-gradient-start: var(--green-500);
|
|
284
|
+
--button-variant-gradient-end: var(--green-700);
|
|
285
|
+
--button-variant-gradient-foreground: white;
|
|
286
|
+
--button-variant-gradient-hover: var(--gray-900);
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
.info {
|
|
290
|
+
--button: var(--blue-400);
|
|
291
|
+
--button-ring-color: var(--button);
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
.info.filled {
|
|
295
|
+
--button-variant-filled: var(--button);
|
|
296
|
+
--button-variant-filled-foreground: white;
|
|
297
|
+
--button-variant-filled-hover: oklch(from var(--button) calc(l * 0.9) c h);
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
.info.outlined {
|
|
301
|
+
--button-variant-outlined: transparent;
|
|
302
|
+
--button-variant-outlined-foreground: var(--blue-300);
|
|
303
|
+
--button-variant-outlined-hover: oklch(from var(--button) calc(l * 1.9) calc(c * 0.2) h);
|
|
304
|
+
--button-variant-outlined-border: var(--blue-500);
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
.info.text {
|
|
308
|
+
--button-variant-text: transparent;
|
|
309
|
+
--button-variant-text-foreground: oklch(from var(--button) calc(l * 0.7) c h);
|
|
310
|
+
--button-variant-text-hover: oklch(from var(--canvas-50) calc(l * 0.995) c h);
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
.info.gradient {
|
|
314
|
+
--button-variant-gradient-start: var(--blue-500);
|
|
315
|
+
--button-variant-gradient-end: var(--blue-700);
|
|
316
|
+
--button-variant-gradient-foreground: white;
|
|
317
|
+
--button-variant-gradient-hover: var(--gray-900);
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
.warning {
|
|
321
|
+
--button: var(--yellow-300);
|
|
322
|
+
--button-ring-color: var(--button);
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
.warning.filled {
|
|
326
|
+
--button-variant-filled: var(--button);
|
|
327
|
+
--button-variant-filled-foreground: black;
|
|
328
|
+
--button-variant-filled-hover: oklch(from var(--button) calc(l * 0.95) c h);
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
.warning.outlined {
|
|
332
|
+
--button-variant-outlined: transparent;
|
|
333
|
+
--button-variant-outlined-foreground: var(--yellow-700);
|
|
334
|
+
--button-variant-outlined-hover: oklch(from var(--button) calc(l * 1.9) calc(c * 0.2) h);
|
|
335
|
+
--button-variant-outlined-border: var(--yellow-500);
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
.warning.text {
|
|
339
|
+
--button-variant-text: transparent;
|
|
340
|
+
--button-variant-text-foreground: oklch(from var(--button) calc(l * 0.6) c h);
|
|
341
|
+
--button-variant-text-hover: oklch(from var(--canvas-50) calc(l * 0.995) c h);
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
.warning.gradient {
|
|
345
|
+
--button-variant-gradient-start: var(--yellow-300);
|
|
346
|
+
--button-variant-gradient-end: var(--yellow-400);
|
|
347
|
+
--button-variant-gradient-foreground: black;
|
|
348
|
+
--button-variant-gradient-hover: var(--gray-900);
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
.danger {
|
|
352
|
+
--button: var(--red-400);
|
|
353
|
+
--button-ring-color: var(--button);
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
.danger.filled {
|
|
357
|
+
--button-variant-filled: var(--button);
|
|
358
|
+
--button-variant-filled-foreground: white;
|
|
359
|
+
--button-variant-filled-hover: oklch(from var(--button) calc(l * 0.9) c h);
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
.danger.outlined {
|
|
363
|
+
--button-variant-outlined: transparent;
|
|
364
|
+
--button-variant-outlined-foreground: var(--red-500);
|
|
365
|
+
--button-variant-outlined-hover: oklch(from var(--button) calc(l * 1.8) calc(c * 0.3) h);
|
|
366
|
+
--button-variant-outlined-border: var(--red-500);
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
.danger.text {
|
|
370
|
+
--button-variant-text: transparent;
|
|
371
|
+
--button-variant-text-foreground: oklch(from var(--button) calc(l * 0.7) c h);
|
|
372
|
+
--button-variant-text-hover: oklch(from var(--canvas-50) calc(l * 0.995) c h);
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
.danger.gradient {
|
|
376
|
+
--button-variant-gradient-start: var(--red-500);
|
|
377
|
+
--button-variant-gradient-end: var(--red-700);
|
|
378
|
+
--button-variant-gradient-foreground: white;
|
|
379
|
+
--button-variant-gradient-hover: var(--gray-900);
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
/* Full width */
|
|
383
|
+
.fullWidth {
|
|
384
|
+
width: 100%;
|
|
385
|
+
display: flex;
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
/* 🌙 Dark via `.dark` class. We rely on the
|
|
389
|
+
* consuming application to detect a user's preferred
|
|
390
|
+
* color scheme - either by header or cookie, and set
|
|
391
|
+
* a root html class accordingly
|
|
392
|
+
*/
|
|
393
|
+
:global(.dark) {
|
|
394
|
+
|
|
395
|
+
.button:focus:not(:where([class~="not-dark"], [class~="not-dark"] *)),
|
|
396
|
+
.button:active:not(:where([class~="not-dark"], [class~="not-dark"] *)) {
|
|
397
|
+
--ring-offset-color: var(--background);
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
.primary:not(:where([class~="not-dark"], [class~="not-dark"] *)) {
|
|
401
|
+
--button: var(--primary-600);
|
|
402
|
+
--button-ring-color: var(--button);
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
.primary.filled:not(:where([class~="not-dark"], [class~="not-dark"] *)) {
|
|
406
|
+
--button-variant-filled: var(--button);
|
|
407
|
+
--button-variant-filled-foreground: white;
|
|
408
|
+
--button-variant-filled-hover: oklch(from var(--button) calc(l * 0.9) c h);
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
.primary.outlined:not(:where([class~="not-dark"], [class~="not-dark"] *)) {
|
|
412
|
+
--button-variant-outlined-foreground: var(--primary-100);
|
|
413
|
+
--button-variant-outlined-hover: oklch(from var(--button) calc(l * 0.45) calc(c * 0.1) h);
|
|
414
|
+
--button-variant-outlined-border: var(--primary-500);
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
.primary.text:not(:where([class~="not-dark"], [class~="not-dark"] *)) {
|
|
418
|
+
--button-variant-text: transparent;
|
|
419
|
+
--button-variant-text-foreground: var(--button);
|
|
420
|
+
--button-variant-text-hover: var(--canvas-800);
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
.secondary.outlined:not(:where([class~="not-dark"], [class~="not-dark"] *)) {
|
|
424
|
+
--button-variant-outlined-foreground: var(--secondary-500);
|
|
425
|
+
--button-variant-outlined-hover: oklch(from var(--button) calc(l * 0.3) calc(c * 0.1) h);
|
|
426
|
+
--button-variant-outlined-border: var(--secondary-500);
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
.secondary.text:not(:where([class~="not-dark"], [class~="not-dark"] *)) {
|
|
430
|
+
--button-variant-text-foreground: var(--button);
|
|
431
|
+
--button-variant-text-hover: var(--canvas-800);
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
.noeffect:not(:where([class~="not-dark"], [class~="not-dark"] *)) {
|
|
435
|
+
--button: var(--gray-900);
|
|
436
|
+
--button-ring-color: var(--gray-900);
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
.noeffect.filled:not(:where([class~="not-dark"], [class~="not-dark"] *)) {
|
|
440
|
+
--button-variant-filled: var(--button);
|
|
441
|
+
--button-variant-filled-foreground: white;
|
|
442
|
+
--button-variant-filled-hover: oklch(from var(--button) calc(l * 0.95) c h);
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
.noeffect.outlined:not(:where([class~="not-dark"], [class~="not-dark"] *)) {
|
|
446
|
+
--button-variant-outlined: transparent;
|
|
447
|
+
--button-variant-outlined-foreground: var(--gray-300);
|
|
448
|
+
--button-variant-outlined-hover: oklch(from var(--button) calc(l * 0.75) calc(c * 0.2) h);
|
|
449
|
+
--button-variant-outlined-border: var(--gray-500);
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
.noeffect.text:not(:where([class~="not-dark"], [class~="not-dark"] *)) {
|
|
453
|
+
--button-variant-text: transparent;
|
|
454
|
+
--button-variant-text-foreground: var(--gray-300);
|
|
455
|
+
--button-variant-text-hover: var(--canvas-800);
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
.noeffect.gradient:not(:where([class~="not-dark"], [class~="not-dark"] *)) {
|
|
459
|
+
--button-variant-gradient-start: var(--gray-950);
|
|
460
|
+
--button-variant-gradient-end: var(--gray-900);
|
|
461
|
+
--button-variant-gradient-foreground: white;
|
|
462
|
+
--button-variant-gradient-hover: var(--gray-900);
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
.success.outlined:not(:where([class~="not-dark"], [class~="not-dark"] *)) {
|
|
466
|
+
--button-variant-outlined-foreground: var(--green-500);
|
|
467
|
+
--button-variant-outlined-hover: oklch(from var(--button) calc(l * 0.35) calc(c * 0.1) h);
|
|
468
|
+
--button-variant-outlined-border: var(--green-500);
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
.success.text:not(:where([class~="not-dark"], [class~="not-dark"] *)) {
|
|
472
|
+
--button-variant-text-foreground: var(--button);
|
|
473
|
+
--button-variant-text-hover: var(--canvas-800);
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
.info.outlined:not(:where([class~="not-dark"], [class~="not-dark"] *)) {
|
|
477
|
+
--button-variant-outlined-foreground: var(--blue-300);
|
|
478
|
+
--button-variant-outlined-hover: oklch(from var(--button) calc(l * 0.43) calc(c * 0.1) h);
|
|
479
|
+
--button-variant-outlined-border: var(--blue-500);
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
.info.text:not(:where([class~="not-dark"], [class~="not-dark"] *)) {
|
|
483
|
+
--button-variant-text-foreground: var(--button);
|
|
484
|
+
--button-variant-text-hover: var(--canvas-800);
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
.warning.outlined:not(:where([class~="not-dark"], [class~="not-dark"] *)) {
|
|
488
|
+
--button-variant-outlined-foreground: var(--yellow-500);
|
|
489
|
+
--button-variant-outlined-hover: oklch(from var(--button) calc(l * 0.31) calc(c * 0.1) h);
|
|
490
|
+
--button-variant-outlined-border: var(--yellow-500);
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
.warning.text:not(:where([class~="not-dark"], [class~="not-dark"] *)) {
|
|
494
|
+
--button-variant-text-foreground: var(--button);
|
|
495
|
+
--button-variant-text-hover: var(--canvas-800);
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
.danger.outlined:not(:where([class~="not-dark"], [class~="not-dark"] *)) {
|
|
499
|
+
--button-variant-outlined-foreground: var(--red-500);
|
|
500
|
+
--button-variant-outlined-hover: oklch(from var(--button) calc(l * 0.4) calc(c * 0.1) h);
|
|
501
|
+
--button-variant-outlined-border: var(--red-500);
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
.danger.text:not(:where([class~="not-dark"], [class~="not-dark"] *)) {
|
|
505
|
+
--button-variant-text-foreground: var(--button);
|
|
506
|
+
--button-variant-text-hover: var(--canvas-800);
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
.filled:disabled:not(:where([class~="not-dark"], [class~="not-dark"] *)),
|
|
510
|
+
.filled[disabled]:not(:where([class~="not-dark"], [class~="not-dark"] *)) {
|
|
511
|
+
background-color: oklch(from var(--button-variant-filled) calc(l * 0.85) calc(c * 0.85) h);
|
|
512
|
+
color: oklch(from var(--button-variant-filled-foreground) calc(l * 0.85) calc(c * 0.85) h);
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
.outlined:disabled:not(:where([class~="not-dark"], [class~="not-dark"] *)),
|
|
516
|
+
.outlined[disabled]:not(:where([class~="not-dark"], [class~="not-dark"] *)) {
|
|
517
|
+
border-color: oklch(from var(--button-variant-outlined-border) calc(l * 0.8) calc(c * 0.8) h);
|
|
518
|
+
color: oklch(from var(--button-variant-outlined-foreground) calc(l * 0.8) calc(c * 0.8) h);
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
.gradient:disabled:not(:where([class~="not-dark"], [class~="not-dark"] *)),
|
|
522
|
+
.gradient[disabled]:not(:where([class~="not-dark"], [class~="not-dark"] *)) {
|
|
523
|
+
background: unset;
|
|
524
|
+
background-color: oklch(from var(--button-variant-gradient-end) calc(l * 0.85) calc(c * 0.85) h);
|
|
525
|
+
color: oklch(from var(--button-variant-gradient-foreground) calc(l * 0.85) calc(c * 0.85) h);
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
.text:disabled:not(:where([class~="not-dark"], [class~="not-dark"] *)),
|
|
529
|
+
.text[disabled]:not(:where([class~="not-dark"], [class~="not-dark"] *)) {
|
|
530
|
+
color: oklch(from var(--button-variant-text-foreground) calc(l * 0.85) calc(c * 0.85) h);
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { Slot } from '@radix-ui/react-slot'
|
|
3
|
+
import cx from 'classnames'
|
|
4
|
+
// @ts-ignore
|
|
5
|
+
import Ripple from 'material-ripple-effects'
|
|
6
|
+
import type React from 'react'
|
|
7
|
+
|
|
8
|
+
import type { Intent, Size, Variant } from './@types/button.js'
|
|
9
|
+
|
|
10
|
+
import styles from './button.module.css'
|
|
11
|
+
|
|
12
|
+
export type ButtonRefType<C extends React.ElementType> = React.ComponentPropsWithRef<C>['ref']
|
|
13
|
+
|
|
14
|
+
type AsButton = { asChild?: false } & React.ComponentPropsWithoutRef<'button'>
|
|
15
|
+
|
|
16
|
+
interface AsSlot {
|
|
17
|
+
asChild?: true
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export type ButtonProps<C extends React.ElementType = 'button'> = {
|
|
21
|
+
variant?: Variant
|
|
22
|
+
size?: Size
|
|
23
|
+
type?: 'submit' | 'reset' | 'button'
|
|
24
|
+
intent?: Intent
|
|
25
|
+
fullWidth?: boolean
|
|
26
|
+
ripple?: boolean
|
|
27
|
+
className?: string
|
|
28
|
+
children: React.ReactNode
|
|
29
|
+
ref?: React.RefObject<ButtonRefType<C>>
|
|
30
|
+
} & (AsButton | AsSlot) &
|
|
31
|
+
React.HTMLAttributes<HTMLElement>
|
|
32
|
+
|
|
33
|
+
export const Button = <C extends React.ElementType = 'button'>({
|
|
34
|
+
variant = 'filled',
|
|
35
|
+
size = 'md',
|
|
36
|
+
type = 'button',
|
|
37
|
+
intent = 'primary',
|
|
38
|
+
fullWidth = false,
|
|
39
|
+
ripple = true,
|
|
40
|
+
className,
|
|
41
|
+
children,
|
|
42
|
+
asChild,
|
|
43
|
+
ref,
|
|
44
|
+
...rest
|
|
45
|
+
}: ButtonProps<C>) => {
|
|
46
|
+
const Comp: React.ElementType = asChild != null && asChild === true ? Slot : 'button'
|
|
47
|
+
|
|
48
|
+
let onMouseDown: React.MouseEventHandler<HTMLButtonElement> | undefined
|
|
49
|
+
if (ripple === true) {
|
|
50
|
+
const rippleEffect = new Ripple()
|
|
51
|
+
onMouseDown = (e: React.MouseEvent<HTMLButtonElement>) => {
|
|
52
|
+
if (rest.onMouseDown) {
|
|
53
|
+
;(rest.onMouseDown as React.MouseEventHandler<HTMLButtonElement>)(e)
|
|
54
|
+
}
|
|
55
|
+
rippleEffect.create(e, variant === 'filled' || variant === 'gradient' ? 'light' : 'dark')
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return (
|
|
60
|
+
<Comp
|
|
61
|
+
ref={ref}
|
|
62
|
+
type={type}
|
|
63
|
+
className={cx(
|
|
64
|
+
'button',
|
|
65
|
+
intent,
|
|
66
|
+
variant,
|
|
67
|
+
size,
|
|
68
|
+
styles.button,
|
|
69
|
+
styles[variant],
|
|
70
|
+
styles[size],
|
|
71
|
+
styles[intent],
|
|
72
|
+
{ [styles.fullWidth]: fullWidth === true },
|
|
73
|
+
className
|
|
74
|
+
)}
|
|
75
|
+
onMouseDown={onMouseDown}
|
|
76
|
+
{...rest}
|
|
77
|
+
>
|
|
78
|
+
{children}
|
|
79
|
+
</Comp>
|
|
80
|
+
)
|
|
81
|
+
}
|