@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.
Files changed (312) hide show
  1. package/dist/components/card/card.d.ts.map +1 -1
  2. package/package.json +9 -5
  3. package/src/astro.d.ts +43 -0
  4. package/src/astro.js +2 -2
  5. package/src/components/@types/shared.ts +24 -0
  6. package/src/components/accordion/accordion.module.css +60 -0
  7. package/src/components/accordion/accordion.stories.tsx +117 -0
  8. package/src/components/accordion/accordion.tsx +105 -0
  9. package/src/components/animation/fade-in-lift.stories.tsx +81 -0
  10. package/src/components/animation/fade-in-lift.tsx +42 -0
  11. package/src/components/avatar/avatar.module.css +54 -0
  12. package/src/components/avatar/avatar.stories.tsx +28 -0
  13. package/src/components/avatar/avatar.tsx +19 -0
  14. package/src/components/button/@types/button.ts +17 -0
  15. package/src/components/button/button-group.module.css +17 -0
  16. package/src/components/button/button-group.stories.tsx +45 -0
  17. package/src/components/button/button-group.tsx +132 -0
  18. package/src/components/button/button-icon.stories.tsx +145 -0
  19. package/src/components/button/button-intents.stories.tsx +50 -0
  20. package/src/components/button/button-variants.stories.tsx +60 -0
  21. package/src/components/button/button.astro +86 -0
  22. package/src/components/button/button.module.css +533 -0
  23. package/src/components/button/button.tsx +81 -0
  24. package/src/components/button/control-buttons.module.css +144 -0
  25. package/src/components/button/control-buttons.stories.tsx +60 -0
  26. package/src/components/button/control-buttons.tsx +137 -0
  27. package/src/components/button/copy-button.module.css +31 -0
  28. package/src/components/button/copy-button.stories.tsx +50 -0
  29. package/src/components/button/copy-button.tsx +92 -0
  30. package/src/components/button/icon-button.astro +47 -0
  31. package/src/components/button/icon-button.tsx +44 -0
  32. package/src/components/button/index.ts +5 -0
  33. package/src/components/calendar/calendar.module.css +315 -0
  34. package/src/components/calendar/calendar.stories.tsx +139 -0
  35. package/src/components/calendar/calendar.tsx +173 -0
  36. package/src/components/card/card-content.astro +14 -0
  37. package/src/components/card/card-description.astro +14 -0
  38. package/src/components/card/card-footer.astro +14 -0
  39. package/src/components/card/card-header.astro +14 -0
  40. package/src/components/card/card-title.astro +14 -0
  41. package/src/components/card/card.astro +41 -0
  42. package/src/components/card/card.module.css +67 -0
  43. package/src/components/card/card.stories.tsx +61 -0
  44. package/src/components/card/card.tsx +86 -0
  45. package/src/components/container/container.astro +13 -0
  46. package/src/components/container/container.module.css +28 -0
  47. package/src/components/container/container.stories.tsx +42 -0
  48. package/src/components/container/container.tsx +23 -0
  49. package/src/components/dropdown/dropdown.module.css +131 -0
  50. package/src/components/dropdown/dropdown.stories.tsx +103 -0
  51. package/src/components/dropdown/dropdown.tsx +193 -0
  52. package/src/components/hamburger/hamburger.astro +30 -0
  53. package/src/components/hamburger/hamburger.tsx +66 -0
  54. package/src/components/input/@types/checkbox.ts +20 -0
  55. package/src/components/input/@types/input.ts +20 -0
  56. package/src/components/input/checkbox-group.tsx +78 -0
  57. package/src/components/input/checkbox.module.css +267 -0
  58. package/src/components/input/checkbox.stories.tsx +240 -0
  59. package/src/components/input/checkbox.tsx +95 -0
  60. package/src/components/input/error-text.astro +14 -0
  61. package/src/components/input/error-text.module.css +19 -0
  62. package/src/components/input/error-text.tsx +18 -0
  63. package/src/components/input/errors.tsx +37 -0
  64. package/src/components/input/help-text.astro +13 -0
  65. package/src/components/input/help-text.module.css +19 -0
  66. package/src/components/input/help-text.tsx +13 -0
  67. package/src/components/input/index.tsx +8 -0
  68. package/src/components/input/input-adornment.astro +26 -0
  69. package/src/components/input/input-adornment.module.css +18 -0
  70. package/src/components/input/input-adornment.tsx +36 -0
  71. package/src/components/input/input.astro +99 -0
  72. package/src/components/input/input.module.css +310 -0
  73. package/src/components/input/input.stories.tsx +174 -0
  74. package/src/components/input/input.tsx +103 -0
  75. package/src/components/input/label.astro +24 -0
  76. package/src/components/input/label.module.css +28 -0
  77. package/src/components/input/label.tsx +25 -0
  78. package/src/components/input/radio-group.module.css +219 -0
  79. package/src/components/input/radio-group.stories.tsx +73 -0
  80. package/src/components/input/radio-group.tsx +67 -0
  81. package/src/components/input/select.module.css +75 -0
  82. package/src/components/input/select.stories.tsx +34 -0
  83. package/src/components/input/select.tsx +115 -0
  84. package/src/components/input/text-area.module.css +9 -0
  85. package/src/components/input/text-area.stories.tsx +51 -0
  86. package/src/components/input/text-area.tsx +81 -0
  87. package/src/components/input/utils.ts +21 -0
  88. package/src/components/notifications/@types/alert.ts +12 -0
  89. package/src/components/notifications/@types/toast.ts +12 -0
  90. package/src/components/notifications/alert.module.css +114 -0
  91. package/src/components/notifications/alert.stories.tsx +39 -0
  92. package/src/components/notifications/alert.tsx +117 -0
  93. package/src/components/notifications/index.ts +2 -0
  94. package/src/components/notifications/toast.module.css +237 -0
  95. package/src/components/notifications/toast.stories.tsx +42 -0
  96. package/src/components/notifications/toast.tsx +124 -0
  97. package/src/components/overlay/index.stories.tsx +29 -0
  98. package/src/components/overlay/index.ts +2 -0
  99. package/src/components/overlay/overlay.module.css +41 -0
  100. package/src/components/overlay/overlay.tsx +61 -0
  101. package/src/components/pager/@types/index.ts +2 -0
  102. package/src/components/pager/ellipses.tsx +18 -0
  103. package/src/components/pager/event-pager.tsx +18 -0
  104. package/src/components/pager/first-button.tsx +53 -0
  105. package/src/components/pager/hooks/types/usePagination.ts +80 -0
  106. package/src/components/pager/hooks/usePagination.ts +140 -0
  107. package/src/components/pager/icons/first.tsx +33 -0
  108. package/src/components/pager/icons/index.tsx +4 -0
  109. package/src/components/pager/icons/last.tsx +33 -0
  110. package/src/components/pager/icons/next.tsx +20 -0
  111. package/src/components/pager/icons/previous.tsx +20 -0
  112. package/src/components/pager/index.ts +4 -0
  113. package/src/components/pager/last-button.tsx +57 -0
  114. package/src/components/pager/next-button.tsx +55 -0
  115. package/src/components/pager/number-button.tsx +83 -0
  116. package/src/components/pager/pagination.module.css +165 -0
  117. package/src/components/pager/pagination.stories.tsx +190 -0
  118. package/src/components/pager/pagination.tsx +266 -0
  119. package/src/components/pager/previous-button.tsx +51 -0
  120. package/src/components/scroll-area/scroll-area.module.css +80 -0
  121. package/src/components/scroll-area/scroll-area.stories.tsx +33 -0
  122. package/src/components/scroll-area/scroll-area.tsx +22 -0
  123. package/src/components/scroll-to-top/scroll-to-top.tsx +59 -0
  124. package/src/components/section/section.astro +13 -0
  125. package/src/components/section/section.module.css +7 -0
  126. package/src/components/section/section.tsx +23 -0
  127. package/src/components/shimmer/shimmer.module.css +53 -0
  128. package/src/components/shimmer/shimmer.stories.tsx +24 -0
  129. package/src/components/shimmer/shimmer.tsx +70 -0
  130. package/src/components/table/table.module.css +100 -0
  131. package/src/components/table/table.stories.tsx +95 -0
  132. package/src/components/table/table.tsx +165 -0
  133. package/src/components/tabs/tabs.module.css +64 -0
  134. package/src/components/tabs/tabs.stories.tsx +47 -0
  135. package/src/components/tabs/tabs.tsx +75 -0
  136. package/src/components/timeline/timeline.module.css +87 -0
  137. package/src/components/timeline/timeline.stories.tsx +50 -0
  138. package/src/components/timeline/timeline.tsx +177 -0
  139. package/src/components/tooltip/tooltip.module.css +55 -0
  140. package/src/components/tooltip/tooltip.stories.tsx +59 -0
  141. package/src/components/tooltip/tooltip.tsx +51 -0
  142. package/src/declarations.d.ts +4 -0
  143. package/src/hooks/use-media-query.ts +20 -0
  144. package/src/icons/activity-icon.tsx +40 -0
  145. package/src/icons/calendar-icon.tsx +39 -0
  146. package/src/icons/check-icon.tsx +33 -0
  147. package/src/icons/chevron-down-icon.tsx +39 -0
  148. package/src/icons/chevron-left-double-icon.tsx +58 -0
  149. package/src/icons/chevron-left-icon.tsx +58 -0
  150. package/src/icons/chevron-right-double-icon.tsx +58 -0
  151. package/src/icons/chevron-right-icon.tsx +58 -0
  152. package/src/icons/chevrons-up-down.tsx +37 -0
  153. package/src/icons/close-icon.astro +38 -0
  154. package/src/icons/close-icon.tsx +30 -0
  155. package/src/icons/copy-icon.tsx +35 -0
  156. package/src/icons/danger-icon.tsx +18 -0
  157. package/src/icons/dashboard-icon.tsx +41 -0
  158. package/src/icons/delete-icon.tsx +34 -0
  159. package/src/icons/document-icon.tsx +38 -0
  160. package/src/icons/download-icon.tsx +39 -0
  161. package/src/icons/edit-icon.tsx +35 -0
  162. package/src/icons/ellipsis-icon.tsx +38 -0
  163. package/src/icons/email-icon.tsx +33 -0
  164. package/src/icons/external-link-icon.tsx +39 -0
  165. package/src/icons/github-icon.tsx +27 -0
  166. package/src/icons/globe-icon.tsx +50 -0
  167. package/src/icons/google-icon.tsx +44 -0
  168. package/src/icons/gripper-vertical-icon.tsx +43 -0
  169. package/src/icons/history-icon.tsx +32 -0
  170. package/src/icons/home-icon.tsx +34 -0
  171. package/src/icons/icon-element.astro +27 -0
  172. package/src/icons/icon-element.tsx +32 -0
  173. package/src/icons/icon-sprite.tsx +18 -0
  174. package/src/icons/icons.module.css +147 -0
  175. package/src/icons/index.stories.tsx +25 -0
  176. package/src/icons/index.ts +39 -0
  177. package/src/icons/info-icon.tsx +18 -0
  178. package/src/icons/infonomic-icon.tsx +173 -0
  179. package/src/icons/light-icon.astro +36 -0
  180. package/src/icons/light-icon.tsx +29 -0
  181. package/src/icons/location-pin-icon.tsx +36 -0
  182. package/src/icons/moon-icon.astro +38 -0
  183. package/src/icons/moon-icon.tsx +42 -0
  184. package/src/icons/plus-icon.tsx +34 -0
  185. package/src/icons/primary-icon.tsx +22 -0
  186. package/src/icons/refresh-icon.tsx +33 -0
  187. package/src/icons/return-icon.tsx +36 -0
  188. package/src/icons/roles-icon.tsx +34 -0
  189. package/src/icons/search-icon.astro +40 -0
  190. package/src/icons/search-icon.tsx +29 -0
  191. package/src/icons/search-menu-icon.tsx +42 -0
  192. package/src/icons/settings-gear-icon.tsx +36 -0
  193. package/src/icons/settings-sliders-icon.tsx +43 -0
  194. package/src/icons/sign-out-icon.tsx +35 -0
  195. package/src/icons/source/icon-calendar.svg +1 -0
  196. package/src/icons/source/icon-check.svg +4 -0
  197. package/src/icons/source/icon-close.svg +3 -0
  198. package/src/icons/source/icon-coinbase.svg +9 -0
  199. package/src/icons/source/icon-copy.svg +4 -0
  200. package/src/icons/source/icon-document.svg +5 -0
  201. package/src/icons/source/icon-download.svg +4 -0
  202. package/src/icons/source/icon-edit.svg +6 -0
  203. package/src/icons/source/icon-eth-purple.svg +15 -0
  204. package/src/icons/source/icon-etherscan.svg +5 -0
  205. package/src/icons/source/icon-external-link.svg +4 -0
  206. package/src/icons/source/icon-globe.svg +7 -0
  207. package/src/icons/source/icon-gripper-vertical.svg +9 -0
  208. package/src/icons/source/icon-info.svg +4 -0
  209. package/src/icons/source/icon-infonomic.svg +43 -0
  210. package/src/icons/source/icon-ledger.svg +4 -0
  211. package/src/icons/source/icon-light.svg +3 -0
  212. package/src/icons/source/icon-location-pin.svg +8 -0
  213. package/src/icons/source/icon-logout.svg +6 -0
  214. package/src/icons/source/icon-metamask.svg +32 -0
  215. package/src/icons/source/icon-moon.svg +3 -0
  216. package/src/icons/source/icon-plus.svg +4 -0
  217. package/src/icons/source/icon-refresh.svg +4 -0
  218. package/src/icons/source/icon-return.svg +4 -0
  219. package/src/icons/source/icon-search-menu.svg +13 -0
  220. package/src/icons/source/icon-search.svg +3 -0
  221. package/src/icons/source/icon-settings-gear.svg +5 -0
  222. package/src/icons/source/icon-settings.svg +12 -0
  223. package/src/icons/source/icon-wallet.svg +3 -0
  224. package/src/icons/source/icon-walletconnect.svg +4 -0
  225. package/src/icons/source/icon-x.svg +4 -0
  226. package/src/icons/stopwatch-icon.tsx +39 -0
  227. package/src/icons/success-icon.tsx +18 -0
  228. package/src/icons/types/icon.ts +8 -0
  229. package/src/icons/user-icon.tsx +33 -0
  230. package/src/icons/users-icon.tsx +35 -0
  231. package/src/icons/wallet-icon.tsx +29 -0
  232. package/src/icons/warning-icon.tsx +18 -0
  233. package/src/icons/x-icon.tsx +33 -0
  234. package/src/loaders/ellipses.tsx +36 -0
  235. package/src/loaders/loaders.stories.tsx +46 -0
  236. package/src/loaders/ring.tsx +33 -0
  237. package/src/loaders/spinner.tsx +28 -0
  238. package/src/loaders/types/index.ts +6 -0
  239. package/src/react.ts +99 -0
  240. package/src/styles/base/animations.css +143 -0
  241. package/src/styles/base/base.css +5 -0
  242. package/src/styles/base/colors.css +163 -0
  243. package/src/styles/base/colors.stories.tsx +671 -0
  244. package/src/styles/base/reset.css +464 -0
  245. package/src/styles/base/typography.css +25 -0
  246. package/src/styles/base/vars.css +188 -0
  247. package/src/styles/components/card.css +20 -0
  248. package/src/styles/components/checkbox.css +55 -0
  249. package/src/styles/components/components.css +11 -0
  250. package/src/styles/components/directional-button.css +92 -0
  251. package/src/styles/components/dropdown.css +19 -0
  252. package/src/styles/components/fade-in-lift.css +13 -0
  253. package/src/styles/components/hamburger.css +107 -0
  254. package/src/styles/components/icon-element.css +4 -0
  255. package/src/styles/components/list-checkbox.css +60 -0
  256. package/src/styles/components/loaders.css +196 -0
  257. package/src/styles/components/popover.css +15 -0
  258. package/src/styles/components/scroll-to-top.css +89 -0
  259. package/src/styles/components/toast.css +18 -0
  260. package/src/styles/styles.css +6 -0
  261. package/src/styles/theme/autofill.css +58 -0
  262. package/src/styles/theme/scrollers.css +52 -0
  263. package/src/styles/theme/theme.css +130 -0
  264. package/src/styles/theme/theme.stories.tsx +33 -0
  265. package/src/styles/typography/code.stories.tsx +76 -0
  266. package/src/styles/typography/default.stories.tsx +51 -0
  267. package/src/styles/typography/fonts.css +30 -0
  268. package/src/styles/typography/lists.stories.tsx +50 -0
  269. package/src/styles/typography/prose.css +404 -0
  270. package/src/styles/typography/quote.stories.tsx +37 -0
  271. package/src/styles/typography.css +24 -0
  272. package/src/styles/utils/scroll-layout-shift.css +9 -0
  273. package/src/styles/utils/utility-classes.css +1278 -0
  274. package/src/styles/utils/utils.css +2 -0
  275. package/src/theme/theme-provider/index.ts +1 -0
  276. package/src/theme/theme-provider/provider.tsx +44 -0
  277. package/src/utils/capitalize.ts +6 -0
  278. package/src/utils/externalLinkProps.ts +6 -0
  279. package/src/utils/findMatch.ts +7 -0
  280. package/src/utils/getPortalRoot.ts +3 -0
  281. package/src/utils/isTouchDevice.ts +11 -0
  282. package/src/utils/objectsToArray.ts +15 -0
  283. package/src/utils/objectsToString.ts +5 -0
  284. package/src/utils/polymorphic.ts +16 -0
  285. package/src/utils/to-kebab-case.ts +5 -0
  286. package/src/widgets/datepicker/datepicker.module.css +189 -0
  287. package/src/widgets/datepicker/datepicker.stories.tsx +25 -0
  288. package/src/widgets/datepicker/datepicker.tsx +310 -0
  289. package/src/widgets/drawer/drawer-container.tsx +26 -0
  290. package/src/widgets/drawer/drawer-content.tsx +26 -0
  291. package/src/widgets/drawer/drawer-context.tsx +49 -0
  292. package/src/widgets/drawer/drawer-header.tsx +27 -0
  293. package/src/widgets/drawer/drawer-top-actions.tsx +27 -0
  294. package/src/widgets/drawer/drawer-wrapper.tsx +54 -0
  295. package/src/widgets/drawer/drawer.module.css +116 -0
  296. package/src/widgets/drawer/drawer.stories.tsx +224 -0
  297. package/src/widgets/drawer/drawer.tsx +115 -0
  298. package/src/widgets/drawer/motionDomAnimation.ts +4 -0
  299. package/src/widgets/drawer/motionDomMax.ts +4 -0
  300. package/src/widgets/modal/modal-actions.tsx +26 -0
  301. package/src/widgets/modal/modal-container.tsx +26 -0
  302. package/src/widgets/modal/modal-content.tsx +26 -0
  303. package/src/widgets/modal/modal-header.tsx +27 -0
  304. package/src/widgets/modal/modal-wrapper.tsx +50 -0
  305. package/src/widgets/modal/modal.module.css +85 -0
  306. package/src/widgets/modal/modal.stories.tsx +71 -0
  307. package/src/widgets/modal/modal.tsx +110 -0
  308. package/src/widgets/modal/motionDomAnimation.ts +4 -0
  309. package/src/widgets/modal/motionDomMax.ts +4 -0
  310. package/src/widgets/search/index.ts +1 -0
  311. package/src/widgets/search/search.stories.tsx +18 -0
  312. 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
+ }