@infonomic/uikit 2.0.0 → 2.1.1

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 (314) hide show
  1. package/dist/components/button/index.js +1 -17
  2. package/dist/components/card/card.d.ts.map +1 -1
  3. package/dist/tsconfig.build.tsbuildinfo +1 -1
  4. package/package.json +35 -31
  5. package/src/astro.d.ts +43 -0
  6. package/src/astro.js +2 -2
  7. package/src/components/@types/shared.ts +24 -0
  8. package/src/components/accordion/accordion.module.css +60 -0
  9. package/src/components/accordion/accordion.stories.tsx +117 -0
  10. package/src/components/accordion/accordion.tsx +105 -0
  11. package/src/components/animation/fade-in-lift.stories.tsx +81 -0
  12. package/src/components/animation/fade-in-lift.tsx +42 -0
  13. package/src/components/avatar/avatar.module.css +54 -0
  14. package/src/components/avatar/avatar.stories.tsx +28 -0
  15. package/src/components/avatar/avatar.tsx +19 -0
  16. package/src/components/button/@types/button.ts +17 -0
  17. package/src/components/button/button-group.module.css +17 -0
  18. package/src/components/button/button-group.stories.tsx +45 -0
  19. package/src/components/button/button-group.tsx +132 -0
  20. package/src/components/button/button-icon.stories.tsx +145 -0
  21. package/src/components/button/button-intents.stories.tsx +50 -0
  22. package/src/components/button/button-variants.stories.tsx +60 -0
  23. package/src/components/button/button.astro +86 -0
  24. package/src/components/button/button.module.css +533 -0
  25. package/src/components/button/button.tsx +81 -0
  26. package/src/components/button/control-buttons.module.css +144 -0
  27. package/src/components/button/control-buttons.stories.tsx +60 -0
  28. package/src/components/button/control-buttons.tsx +137 -0
  29. package/src/components/button/copy-button.module.css +31 -0
  30. package/src/components/button/copy-button.stories.tsx +50 -0
  31. package/src/components/button/copy-button.tsx +92 -0
  32. package/src/components/button/icon-button.astro +47 -0
  33. package/src/components/button/icon-button.tsx +44 -0
  34. package/src/components/button/index.ts +5 -0
  35. package/src/components/calendar/calendar.module.css +315 -0
  36. package/src/components/calendar/calendar.stories.tsx +139 -0
  37. package/src/components/calendar/calendar.tsx +173 -0
  38. package/src/components/card/card-content.astro +14 -0
  39. package/src/components/card/card-description.astro +14 -0
  40. package/src/components/card/card-footer.astro +14 -0
  41. package/src/components/card/card-header.astro +14 -0
  42. package/src/components/card/card-title.astro +14 -0
  43. package/src/components/card/card.astro +41 -0
  44. package/src/components/card/card.module.css +67 -0
  45. package/src/components/card/card.stories.tsx +61 -0
  46. package/src/components/card/card.tsx +86 -0
  47. package/src/components/container/container.astro +13 -0
  48. package/src/components/container/container.module.css +28 -0
  49. package/src/components/container/container.stories.tsx +42 -0
  50. package/src/components/container/container.tsx +23 -0
  51. package/src/components/dropdown/dropdown.module.css +131 -0
  52. package/src/components/dropdown/dropdown.stories.tsx +103 -0
  53. package/src/components/dropdown/dropdown.tsx +193 -0
  54. package/src/components/hamburger/hamburger.astro +30 -0
  55. package/src/components/hamburger/hamburger.tsx +66 -0
  56. package/src/components/input/@types/checkbox.ts +20 -0
  57. package/src/components/input/@types/input.ts +20 -0
  58. package/src/components/input/checkbox-group.tsx +78 -0
  59. package/src/components/input/checkbox.module.css +267 -0
  60. package/src/components/input/checkbox.stories.tsx +240 -0
  61. package/src/components/input/checkbox.tsx +95 -0
  62. package/src/components/input/error-text.astro +14 -0
  63. package/src/components/input/error-text.module.css +19 -0
  64. package/src/components/input/error-text.tsx +18 -0
  65. package/src/components/input/errors.tsx +37 -0
  66. package/src/components/input/help-text.astro +13 -0
  67. package/src/components/input/help-text.module.css +19 -0
  68. package/src/components/input/help-text.tsx +13 -0
  69. package/src/components/input/index.tsx +8 -0
  70. package/src/components/input/input-adornment.astro +26 -0
  71. package/src/components/input/input-adornment.module.css +18 -0
  72. package/src/components/input/input-adornment.tsx +36 -0
  73. package/src/components/input/input.astro +99 -0
  74. package/src/components/input/input.module.css +310 -0
  75. package/src/components/input/input.stories.tsx +174 -0
  76. package/src/components/input/input.tsx +103 -0
  77. package/src/components/input/label.astro +24 -0
  78. package/src/components/input/label.module.css +28 -0
  79. package/src/components/input/label.tsx +25 -0
  80. package/src/components/input/radio-group.module.css +219 -0
  81. package/src/components/input/radio-group.stories.tsx +73 -0
  82. package/src/components/input/radio-group.tsx +67 -0
  83. package/src/components/input/select.module.css +75 -0
  84. package/src/components/input/select.stories.tsx +34 -0
  85. package/src/components/input/select.tsx +115 -0
  86. package/src/components/input/text-area.module.css +9 -0
  87. package/src/components/input/text-area.stories.tsx +51 -0
  88. package/src/components/input/text-area.tsx +81 -0
  89. package/src/components/input/utils.ts +21 -0
  90. package/src/components/notifications/@types/alert.ts +12 -0
  91. package/src/components/notifications/@types/toast.ts +12 -0
  92. package/src/components/notifications/alert.module.css +114 -0
  93. package/src/components/notifications/alert.stories.tsx +39 -0
  94. package/src/components/notifications/alert.tsx +117 -0
  95. package/src/components/notifications/index.ts +2 -0
  96. package/src/components/notifications/toast.module.css +237 -0
  97. package/src/components/notifications/toast.stories.tsx +42 -0
  98. package/src/components/notifications/toast.tsx +124 -0
  99. package/src/components/overlay/index.stories.tsx +29 -0
  100. package/src/components/overlay/index.ts +2 -0
  101. package/src/components/overlay/overlay.module.css +41 -0
  102. package/src/components/overlay/overlay.tsx +61 -0
  103. package/src/components/pager/@types/index.ts +2 -0
  104. package/src/components/pager/ellipses.tsx +18 -0
  105. package/src/components/pager/event-pager.tsx +18 -0
  106. package/src/components/pager/first-button.tsx +53 -0
  107. package/src/components/pager/hooks/types/usePagination.ts +80 -0
  108. package/src/components/pager/hooks/usePagination.ts +140 -0
  109. package/src/components/pager/icons/first.tsx +33 -0
  110. package/src/components/pager/icons/index.tsx +4 -0
  111. package/src/components/pager/icons/last.tsx +33 -0
  112. package/src/components/pager/icons/next.tsx +20 -0
  113. package/src/components/pager/icons/previous.tsx +20 -0
  114. package/src/components/pager/index.ts +4 -0
  115. package/src/components/pager/last-button.tsx +57 -0
  116. package/src/components/pager/next-button.tsx +55 -0
  117. package/src/components/pager/number-button.tsx +83 -0
  118. package/src/components/pager/pagination.module.css +165 -0
  119. package/src/components/pager/pagination.stories.tsx +190 -0
  120. package/src/components/pager/pagination.tsx +266 -0
  121. package/src/components/pager/previous-button.tsx +51 -0
  122. package/src/components/scroll-area/scroll-area.module.css +80 -0
  123. package/src/components/scroll-area/scroll-area.stories.tsx +33 -0
  124. package/src/components/scroll-area/scroll-area.tsx +22 -0
  125. package/src/components/scroll-to-top/scroll-to-top.tsx +59 -0
  126. package/src/components/section/section.astro +13 -0
  127. package/src/components/section/section.module.css +7 -0
  128. package/src/components/section/section.tsx +23 -0
  129. package/src/components/shimmer/shimmer.module.css +53 -0
  130. package/src/components/shimmer/shimmer.stories.tsx +24 -0
  131. package/src/components/shimmer/shimmer.tsx +70 -0
  132. package/src/components/table/table.module.css +100 -0
  133. package/src/components/table/table.stories.tsx +95 -0
  134. package/src/components/table/table.tsx +165 -0
  135. package/src/components/tabs/tabs.module.css +64 -0
  136. package/src/components/tabs/tabs.stories.tsx +47 -0
  137. package/src/components/tabs/tabs.tsx +75 -0
  138. package/src/components/timeline/timeline.module.css +87 -0
  139. package/src/components/timeline/timeline.stories.tsx +50 -0
  140. package/src/components/timeline/timeline.tsx +177 -0
  141. package/src/components/tooltip/tooltip.module.css +55 -0
  142. package/src/components/tooltip/tooltip.stories.tsx +59 -0
  143. package/src/components/tooltip/tooltip.tsx +51 -0
  144. package/src/declarations.d.ts +4 -0
  145. package/src/hooks/use-media-query.ts +20 -0
  146. package/src/icons/activity-icon.tsx +40 -0
  147. package/src/icons/calendar-icon.tsx +39 -0
  148. package/src/icons/check-icon.tsx +33 -0
  149. package/src/icons/chevron-down-icon.tsx +39 -0
  150. package/src/icons/chevron-left-double-icon.tsx +58 -0
  151. package/src/icons/chevron-left-icon.tsx +58 -0
  152. package/src/icons/chevron-right-double-icon.tsx +58 -0
  153. package/src/icons/chevron-right-icon.tsx +58 -0
  154. package/src/icons/chevrons-up-down.tsx +37 -0
  155. package/src/icons/close-icon.astro +38 -0
  156. package/src/icons/close-icon.tsx +30 -0
  157. package/src/icons/copy-icon.tsx +35 -0
  158. package/src/icons/danger-icon.tsx +18 -0
  159. package/src/icons/dashboard-icon.tsx +41 -0
  160. package/src/icons/delete-icon.tsx +34 -0
  161. package/src/icons/document-icon.tsx +38 -0
  162. package/src/icons/download-icon.tsx +39 -0
  163. package/src/icons/edit-icon.tsx +35 -0
  164. package/src/icons/ellipsis-icon.tsx +38 -0
  165. package/src/icons/email-icon.tsx +33 -0
  166. package/src/icons/external-link-icon.tsx +39 -0
  167. package/src/icons/github-icon.tsx +27 -0
  168. package/src/icons/globe-icon.tsx +50 -0
  169. package/src/icons/google-icon.tsx +44 -0
  170. package/src/icons/gripper-vertical-icon.tsx +43 -0
  171. package/src/icons/history-icon.tsx +32 -0
  172. package/src/icons/home-icon.tsx +34 -0
  173. package/src/icons/icon-element.astro +27 -0
  174. package/src/icons/icon-element.tsx +32 -0
  175. package/src/icons/icon-sprite.tsx +18 -0
  176. package/src/icons/icons.module.css +147 -0
  177. package/src/icons/index.stories.tsx +25 -0
  178. package/src/icons/index.ts +39 -0
  179. package/src/icons/info-icon.tsx +18 -0
  180. package/src/icons/infonomic-icon.tsx +173 -0
  181. package/src/icons/light-icon.astro +36 -0
  182. package/src/icons/light-icon.tsx +29 -0
  183. package/src/icons/location-pin-icon.tsx +36 -0
  184. package/src/icons/moon-icon.astro +38 -0
  185. package/src/icons/moon-icon.tsx +42 -0
  186. package/src/icons/plus-icon.tsx +34 -0
  187. package/src/icons/primary-icon.tsx +22 -0
  188. package/src/icons/refresh-icon.tsx +33 -0
  189. package/src/icons/return-icon.tsx +36 -0
  190. package/src/icons/roles-icon.tsx +34 -0
  191. package/src/icons/search-icon.astro +40 -0
  192. package/src/icons/search-icon.tsx +29 -0
  193. package/src/icons/search-menu-icon.tsx +42 -0
  194. package/src/icons/settings-gear-icon.tsx +36 -0
  195. package/src/icons/settings-sliders-icon.tsx +43 -0
  196. package/src/icons/sign-out-icon.tsx +35 -0
  197. package/src/icons/source/icon-calendar.svg +1 -0
  198. package/src/icons/source/icon-check.svg +4 -0
  199. package/src/icons/source/icon-close.svg +3 -0
  200. package/src/icons/source/icon-coinbase.svg +9 -0
  201. package/src/icons/source/icon-copy.svg +4 -0
  202. package/src/icons/source/icon-document.svg +5 -0
  203. package/src/icons/source/icon-download.svg +4 -0
  204. package/src/icons/source/icon-edit.svg +6 -0
  205. package/src/icons/source/icon-eth-purple.svg +15 -0
  206. package/src/icons/source/icon-etherscan.svg +5 -0
  207. package/src/icons/source/icon-external-link.svg +4 -0
  208. package/src/icons/source/icon-globe.svg +7 -0
  209. package/src/icons/source/icon-gripper-vertical.svg +9 -0
  210. package/src/icons/source/icon-info.svg +4 -0
  211. package/src/icons/source/icon-infonomic.svg +43 -0
  212. package/src/icons/source/icon-ledger.svg +4 -0
  213. package/src/icons/source/icon-light.svg +3 -0
  214. package/src/icons/source/icon-location-pin.svg +8 -0
  215. package/src/icons/source/icon-logout.svg +6 -0
  216. package/src/icons/source/icon-metamask.svg +32 -0
  217. package/src/icons/source/icon-moon.svg +3 -0
  218. package/src/icons/source/icon-plus.svg +4 -0
  219. package/src/icons/source/icon-refresh.svg +4 -0
  220. package/src/icons/source/icon-return.svg +4 -0
  221. package/src/icons/source/icon-search-menu.svg +13 -0
  222. package/src/icons/source/icon-search.svg +3 -0
  223. package/src/icons/source/icon-settings-gear.svg +5 -0
  224. package/src/icons/source/icon-settings.svg +12 -0
  225. package/src/icons/source/icon-wallet.svg +3 -0
  226. package/src/icons/source/icon-walletconnect.svg +4 -0
  227. package/src/icons/source/icon-x.svg +4 -0
  228. package/src/icons/stopwatch-icon.tsx +39 -0
  229. package/src/icons/success-icon.tsx +18 -0
  230. package/src/icons/types/icon.ts +8 -0
  231. package/src/icons/user-icon.tsx +33 -0
  232. package/src/icons/users-icon.tsx +35 -0
  233. package/src/icons/wallet-icon.tsx +29 -0
  234. package/src/icons/warning-icon.tsx +18 -0
  235. package/src/icons/x-icon.tsx +33 -0
  236. package/src/loaders/ellipses.tsx +36 -0
  237. package/src/loaders/loaders.stories.tsx +46 -0
  238. package/src/loaders/ring.tsx +33 -0
  239. package/src/loaders/spinner.tsx +28 -0
  240. package/src/loaders/types/index.ts +6 -0
  241. package/src/react.ts +99 -0
  242. package/src/styles/base/animations.css +143 -0
  243. package/src/styles/base/base.css +5 -0
  244. package/src/styles/base/colors.css +163 -0
  245. package/src/styles/base/colors.stories.tsx +671 -0
  246. package/src/styles/base/reset.css +464 -0
  247. package/src/styles/base/typography.css +25 -0
  248. package/src/styles/base/vars.css +188 -0
  249. package/src/styles/components/card.css +20 -0
  250. package/src/styles/components/checkbox.css +55 -0
  251. package/src/styles/components/components.css +11 -0
  252. package/src/styles/components/directional-button.css +92 -0
  253. package/src/styles/components/dropdown.css +19 -0
  254. package/src/styles/components/fade-in-lift.css +13 -0
  255. package/src/styles/components/hamburger.css +107 -0
  256. package/src/styles/components/icon-element.css +4 -0
  257. package/src/styles/components/list-checkbox.css +60 -0
  258. package/src/styles/components/loaders.css +196 -0
  259. package/src/styles/components/popover.css +15 -0
  260. package/src/styles/components/scroll-to-top.css +89 -0
  261. package/src/styles/components/toast.css +18 -0
  262. package/src/styles/styles.css +6 -0
  263. package/src/styles/theme/autofill.css +58 -0
  264. package/src/styles/theme/scrollers.css +52 -0
  265. package/src/styles/theme/theme.css +130 -0
  266. package/src/styles/theme/theme.stories.tsx +33 -0
  267. package/src/styles/typography/code.stories.tsx +76 -0
  268. package/src/styles/typography/default.stories.tsx +51 -0
  269. package/src/styles/typography/fonts.css +30 -0
  270. package/src/styles/typography/lists.stories.tsx +50 -0
  271. package/src/styles/typography/prose.css +404 -0
  272. package/src/styles/typography/quote.stories.tsx +37 -0
  273. package/src/styles/typography.css +24 -0
  274. package/src/styles/utils/scroll-layout-shift.css +9 -0
  275. package/src/styles/utils/utility-classes.css +1278 -0
  276. package/src/styles/utils/utils.css +2 -0
  277. package/src/theme/theme-provider/index.ts +1 -0
  278. package/src/theme/theme-provider/provider.tsx +44 -0
  279. package/src/utils/capitalize.ts +6 -0
  280. package/src/utils/externalLinkProps.ts +6 -0
  281. package/src/utils/findMatch.ts +7 -0
  282. package/src/utils/getPortalRoot.ts +3 -0
  283. package/src/utils/isTouchDevice.ts +11 -0
  284. package/src/utils/objectsToArray.ts +15 -0
  285. package/src/utils/objectsToString.ts +5 -0
  286. package/src/utils/polymorphic.ts +16 -0
  287. package/src/utils/to-kebab-case.ts +5 -0
  288. package/src/widgets/datepicker/datepicker.module.css +189 -0
  289. package/src/widgets/datepicker/datepicker.stories.tsx +25 -0
  290. package/src/widgets/datepicker/datepicker.tsx +310 -0
  291. package/src/widgets/drawer/drawer-container.tsx +26 -0
  292. package/src/widgets/drawer/drawer-content.tsx +26 -0
  293. package/src/widgets/drawer/drawer-context.tsx +49 -0
  294. package/src/widgets/drawer/drawer-header.tsx +27 -0
  295. package/src/widgets/drawer/drawer-top-actions.tsx +27 -0
  296. package/src/widgets/drawer/drawer-wrapper.tsx +54 -0
  297. package/src/widgets/drawer/drawer.module.css +116 -0
  298. package/src/widgets/drawer/drawer.stories.tsx +224 -0
  299. package/src/widgets/drawer/drawer.tsx +115 -0
  300. package/src/widgets/drawer/motionDomAnimation.ts +4 -0
  301. package/src/widgets/drawer/motionDomMax.ts +4 -0
  302. package/src/widgets/modal/modal-actions.tsx +26 -0
  303. package/src/widgets/modal/modal-container.tsx +26 -0
  304. package/src/widgets/modal/modal-content.tsx +26 -0
  305. package/src/widgets/modal/modal-header.tsx +27 -0
  306. package/src/widgets/modal/modal-wrapper.tsx +50 -0
  307. package/src/widgets/modal/modal.module.css +85 -0
  308. package/src/widgets/modal/modal.stories.tsx +71 -0
  309. package/src/widgets/modal/modal.tsx +110 -0
  310. package/src/widgets/modal/motionDomAnimation.ts +4 -0
  311. package/src/widgets/modal/motionDomMax.ts +4 -0
  312. package/src/widgets/search/index.ts +1 -0
  313. package/src/widgets/search/search.stories.tsx +18 -0
  314. package/src/widgets/search/search.tsx +186 -0
@@ -0,0 +1,144 @@
1
+ @layer infonomic-base, infonomic-utilities, infonomic-theme, infonomic-components;
2
+
3
+ @layer infonomic-components {
4
+
5
+ .stop-button,
6
+ .play-button,
7
+ .directional-button {
8
+ display: flex;
9
+ align-items: center;
10
+ justify-content: center;
11
+ text-decoration: none;
12
+ border-style: none;
13
+ border-radius: 100%;
14
+ padding: 0;
15
+ margin: 0;
16
+ outline: none;
17
+ color: white;
18
+ background-color: var(--primary-500);
19
+ transition-property: all, color;
20
+ transition-duration: 0.3s, 1ms;
21
+ transition-timing-function: cubic-bezier(0.25, 0.8, 0.5, 1), ease;
22
+ transition-delay: 0s, 0s;
23
+ cursor: pointer;
24
+ }
25
+
26
+ .directional-button span {
27
+ width: 40%;
28
+ padding-bottom: 3px;
29
+ }
30
+
31
+ .play-button span {
32
+ width: 80%;
33
+ height: 80%;
34
+ }
35
+
36
+ .stop-button span {
37
+ width: 50%;
38
+ height: 50%;
39
+ }
40
+
41
+ .directional-button span .icon path {
42
+ stroke: none;
43
+ fill: white;
44
+ }
45
+
46
+ .stop-button:hover,
47
+ .play-button:hover,
48
+ .stop-button:focus,
49
+ .play-button:focus,
50
+ .directional-button:hover,
51
+ .directional-button:focus {
52
+ color: white;
53
+ background-color: var(--primary-600);
54
+ transform: translateY(-5px);
55
+ }
56
+
57
+ /* Sizes */
58
+ .xs {
59
+ width: 20px;
60
+ min-width: 20px;
61
+ height: 20px;
62
+ min-height: 20px;
63
+ }
64
+
65
+ .sm {
66
+ width: 30px;
67
+ min-width: 30px;
68
+ height: 30px;
69
+ min-height: 30px;
70
+ }
71
+
72
+ .md {
73
+ width: 40px;
74
+ min-width: 40px;
75
+ height: 40px;
76
+ min-height: 40px;
77
+ }
78
+
79
+ .lg {
80
+ width: 50px;
81
+ min-width: 50px;
82
+ height: 50px;
83
+ min-height: 50px;
84
+ }
85
+
86
+ .xl {
87
+ width: 40px;
88
+ min-width: 40px;
89
+ height: 40px;
90
+ min-height: 40px;
91
+ }
92
+
93
+ /* Up is default so no need to rotate */
94
+ .up:hover,
95
+ .up:focus {
96
+ transform: translateY(-5px);
97
+ }
98
+
99
+ .down span,
100
+ .down span {
101
+ transform: rotate(180deg);
102
+ }
103
+
104
+ .down:hover,
105
+ .down:focus {
106
+ transform: translateY(5px);
107
+ }
108
+
109
+ .left span,
110
+ .left span {
111
+ transform: rotate(-90deg);
112
+ }
113
+
114
+ .left:hover,
115
+ .left:focus {
116
+ transform: translateX(-5px);
117
+ }
118
+
119
+ .right span,
120
+ .right span {
121
+ transform: rotate(90deg);
122
+ }
123
+
124
+ .right:hover,
125
+ .right:focus {
126
+ transform: translateX(5px);
127
+ }
128
+
129
+ :global(.dark) .play-button,
130
+ :global(.dark) .stop-button,
131
+ :global(.dark) .directional-button {
132
+ background-color: var(--primary-500);
133
+ }
134
+
135
+ :global(.dark) .play-button:hover,
136
+ :global(.dark) .stop-button:hover,
137
+ :global(.dark) .play-button:focus,
138
+ :global(.dark) .stop-button:focus,
139
+ :global(.dark) .directional-button:hover,
140
+ :global(.dark) .directional-button:focus {
141
+ color: white;
142
+ background-color: var(--primary-600);
143
+ }
144
+ }
@@ -0,0 +1,60 @@
1
+ import type { Meta, StoryObj } from '@storybook/react-vite'
2
+
3
+ import { DirectionalButton, PlayButton, StopButton } from './control-buttons.js'
4
+
5
+ type Story = StoryObj<typeof DirectionalButton>
6
+
7
+ const ControlsDemo = (): React.JSX.Element => {
8
+ return (
9
+ <>
10
+ <div className="ml-12 mb-6">
11
+ <h2 style={{ fontSize: '1.2rem', margin: '1rem 0' }}>Small</h2>
12
+ <div className="flex items-center gap-4 mb-6">
13
+ <DirectionalButton direction="left" size="sm" />
14
+ <StopButton size="sm" />
15
+ <PlayButton size="sm" />
16
+ <DirectionalButton direction="right" size="sm" />
17
+ <DirectionalButton direction="up" size="sm" />
18
+ <DirectionalButton direction="down" size="sm" />
19
+ </div>
20
+ </div>
21
+ <div className="ml-12 mb-6">
22
+ <h2 style={{ fontSize: '1.2rem', margin: '1rem 0' }}>Medium</h2>
23
+ <div className="flex items-center gap-4 mb-6">
24
+ <DirectionalButton direction="left" size="md" />
25
+ <StopButton size="md" />
26
+ <PlayButton size="md" />
27
+ <DirectionalButton direction="right" size="md" />
28
+ <DirectionalButton direction="up" size="md" />
29
+ <DirectionalButton direction="down" size="md" />
30
+ </div>
31
+ </div>
32
+ <div className="ml-12 mb-6">
33
+ <h2 style={{ fontSize: '1.2rem', margin: '1rem 0' }}>Large</h2>
34
+ <div className="flex items-center gap-4 mb-6">
35
+ <DirectionalButton direction="left" size="lg" />
36
+ <StopButton size="lg" />
37
+ <PlayButton size="lg" />
38
+ <DirectionalButton direction="right" size="lg" />
39
+ <DirectionalButton direction="up" size="lg" />
40
+ <DirectionalButton direction="down" size="lg" />
41
+ </div>
42
+ </div>
43
+ </>
44
+ )
45
+ }
46
+
47
+ export const Controls: Story = {
48
+ render: () => <ControlsDemo />,
49
+ }
50
+
51
+ const meta: Meta<typeof DirectionalButton> = {
52
+ /* 👇 The title prop is optional.
53
+ * See https://storybook.js.org/docs/react/configure/overview#configure-story-loading
54
+ * to learn how to generate automatic titles
55
+ */
56
+ title: 'Components/Button',
57
+ component: ControlsDemo,
58
+ }
59
+
60
+ export default meta
@@ -0,0 +1,137 @@
1
+ 'use client'
2
+ import cx from 'classnames'
3
+ import type React from 'react'
4
+ import type { Size } from './@types/button.js'
5
+ import styles from './control-buttons.module.css'
6
+
7
+ type ButtonType = React.JSX.IntrinsicElements['button']
8
+
9
+ interface ControlButtonProps extends ButtonType {
10
+ size?: Size
11
+ className?: string
12
+ onClick?: () => void
13
+ ref?: React.RefObject<HTMLButtonElement>
14
+ }
15
+
16
+ interface DirectionalButtonProps extends ControlButtonProps {
17
+ direction: 'up' | 'down' | 'left' | 'right'
18
+ }
19
+
20
+ export const DirectionalButton = ({
21
+ size = 'md',
22
+ direction,
23
+ className,
24
+ onClick,
25
+ ref,
26
+ ...rest
27
+ }: DirectionalButtonProps) => {
28
+ const handleClick = (): void => {
29
+ if (onClick != null) {
30
+ onClick()
31
+ }
32
+ }
33
+
34
+ return (
35
+ <button
36
+ ref={ref}
37
+ {...rest}
38
+ onClick={handleClick}
39
+ type="button"
40
+ aria-label={direction}
41
+ className={cx(
42
+ 'control-button',
43
+ direction,
44
+ size,
45
+ styles['directional-button'],
46
+ styles[direction],
47
+ styles[size],
48
+ className
49
+ )}
50
+ >
51
+ <span>
52
+ <svg className="icon" focusable="false" aria-hidden="true" viewBox="0 0 51 32">
53
+ <path
54
+ fill="currentColor"
55
+ d="M25.4,9.8L45.6,30l4.5-4.5L25.4,0.8L0.8,25.4L5.3,30L25.4,9.8z"
56
+ />
57
+ </svg>
58
+ </span>
59
+ </button>
60
+ )
61
+ }
62
+
63
+ export const PlayButton = ({
64
+ size = 'md',
65
+ className,
66
+ onClick,
67
+ ref,
68
+ ...rest
69
+ }: ControlButtonProps) => {
70
+ const handleClick = (): void => {
71
+ if (onClick != null) {
72
+ onClick()
73
+ }
74
+ }
75
+
76
+ return (
77
+ <button
78
+ ref={ref}
79
+ {...rest}
80
+ onClick={handleClick}
81
+ type="button"
82
+ aria-label="play"
83
+ className={cx('control-button', 'play', size, styles['play-button'], styles[size], className)}
84
+ >
85
+ <span>
86
+ <svg className="icon" focusable="false" aria-hidden="true" viewBox="0 0 32 32">
87
+ <path
88
+ d="M12 8L26 16L12 24V8Z"
89
+ fill="none"
90
+ stroke="currentColor"
91
+ strokeWidth="2"
92
+ strokeLinejoin="round"
93
+ />
94
+ </svg>
95
+ </span>
96
+ </button>
97
+ )
98
+ }
99
+
100
+ export const StopButton = ({
101
+ size = 'md',
102
+ className,
103
+ onClick,
104
+ ref,
105
+ ...rest
106
+ }: ControlButtonProps) => {
107
+ const handleClick = (): void => {
108
+ if (onClick != null) {
109
+ onClick()
110
+ }
111
+ }
112
+
113
+ return (
114
+ <button
115
+ ref={ref}
116
+ {...rest}
117
+ onClick={handleClick}
118
+ type="button"
119
+ aria-label="stop"
120
+ className={cx('control-button', 'stop', size, styles['stop-button'], styles[size], className)}
121
+ >
122
+ <span>
123
+ <svg className="icon" focusable="false" aria-hidden="true" viewBox="0 0 32 32">
124
+ <rect
125
+ x="4"
126
+ y="4"
127
+ width="24"
128
+ height="24"
129
+ fill="none"
130
+ stroke="currentColor"
131
+ strokeWidth="3"
132
+ />
133
+ </svg>
134
+ </span>
135
+ </button>
136
+ )
137
+ }
@@ -0,0 +1,31 @@
1
+ @layer infonomic-base, infonomic-utilities, infonomic-theme, infonomic-typography, infonomic-components;
2
+
3
+ @layer infonomic-components {
4
+ .copy-button-container {
5
+ display: inline-block;
6
+ }
7
+
8
+ .copy-button {
9
+ width: 32px;
10
+ height: 32px;
11
+ min-width: 32px;
12
+ }
13
+
14
+ .copy-button-foreground {
15
+ fill: var(--gray-700);
16
+ }
17
+
18
+ .copy-button-foreground-reversed {
19
+ fill: var(--gray-200);
20
+ }
21
+
22
+ .dark {
23
+ .copy-button-foreground {
24
+ fill: var(--gray-200);
25
+ }
26
+
27
+ .copy-button-foreground-reversed {
28
+ fill: var(--gray-700);
29
+ }
30
+ }
31
+ }
@@ -0,0 +1,50 @@
1
+ import type React from 'react'
2
+
3
+ import type { Meta, StoryObj } from '@storybook/react-vite'
4
+
5
+ import { intent } from '../@types/shared.js'
6
+ import { variant } from './@types/button.js'
7
+ import { CopyButton } from './copy-button.js'
8
+
9
+ type Story = StoryObj<typeof CopyButton>
10
+
11
+ const CopyDemo = (): React.JSX.Element => {
12
+ return (
13
+ <div style={{ marginLeft: '12rem', marginTop: '4rem' }}>
14
+ {intent.map((i) => {
15
+ return (
16
+ <div
17
+ key={i}
18
+ style={{ display: 'flex', alignItems: 'center', gap: '16px', marginBottom: '16px' }}
19
+ >
20
+ {variant.map((v) => {
21
+ return (
22
+ <CopyButton
23
+ text="I should be in your clipboard."
24
+ key={`${i}-${v}`}
25
+ intent={i}
26
+ variant={v}
27
+ />
28
+ )
29
+ })}
30
+ </div>
31
+ )
32
+ })}
33
+ </div>
34
+ )
35
+ }
36
+
37
+ export const Copy: Story = {
38
+ render: () => <CopyDemo />,
39
+ }
40
+
41
+ const meta: Meta<typeof CopyButton> = {
42
+ /* 👇 The title prop is optional.
43
+ * See https://storybook.js.org/docs/react/configure/overview#configure-story-loading
44
+ * to learn how to generate automatic titles
45
+ */
46
+ title: 'Components/Button',
47
+ component: CopyButton,
48
+ }
49
+
50
+ export default meta
@@ -0,0 +1,92 @@
1
+ 'use client'
2
+
3
+ import cx from 'classnames'
4
+ import type React from 'react'
5
+ import { useEffect, useState } from 'react'
6
+
7
+ import { CopyIcon } from '../../icons'
8
+ import { Tooltip } from '../tooltip/tooltip.js'
9
+ import type { ButtonProps } from './button.js'
10
+ import { Button } from './button.js'
11
+
12
+ import styles from './copy-button.module.css'
13
+
14
+ interface CopyButtonProps extends Omit<ButtonProps, 'children'> {
15
+ text: string
16
+ hoverText?: string
17
+ copiedText?: string
18
+ containerClassName?: string
19
+ svgClassName?: string
20
+ }
21
+
22
+ export function CopyButton({
23
+ text,
24
+ hoverText = 'Copy',
25
+ copiedText = 'Copied!',
26
+ variant,
27
+ size = 'sm',
28
+ intent,
29
+ fullWidth,
30
+ ripple,
31
+ className,
32
+ containerClassName,
33
+ svgClassName,
34
+ ...rest
35
+ }: CopyButtonProps): React.JSX.Element {
36
+ const [copied, setCopied] = useState<boolean | undefined>(undefined)
37
+
38
+ const handleCopied = (): void => {
39
+ // TODO: Permissions check?
40
+ if (navigator.clipboard != null && navigator.permissions != null) {
41
+ void navigator.clipboard.writeText(text).then(() => {
42
+ setCopied(true)
43
+ })
44
+ } else if (document.queryCommandSupported('copy')) {
45
+ const element = document.createElement('textarea')
46
+ element.value = text
47
+ document.body.appendChild(element)
48
+ element.select()
49
+ document.execCommand('copy')
50
+ document.body.removeChild(element)
51
+ setCopied(true)
52
+ }
53
+ }
54
+
55
+ useEffect(() => {
56
+ if (copied === true) {
57
+ setTimeout(() => {
58
+ setCopied(undefined)
59
+ }, 900)
60
+ }
61
+ })
62
+
63
+ const svgColor =
64
+ intent === 'noeffect' ||
65
+ intent === 'secondary' ||
66
+ intent === 'warning' ||
67
+ variant === 'outlined' ||
68
+ variant === 'text'
69
+ ? styles['copy-button-foreground']
70
+ : styles['copy-button-foreground-reversed']
71
+
72
+ const tooltipText = copied != null && copied ? copiedText : hoverText
73
+
74
+ return (
75
+ <div className={cx(styles['copy-button-container'], containerClassName)}>
76
+ <Tooltip side="top" sideOffset={2} text={tooltipText} open={copied}>
77
+ <Button
78
+ variant={variant}
79
+ size={size}
80
+ intent={intent}
81
+ fullWidth={fullWidth}
82
+ ripple={ripple}
83
+ className={cx('copy-button', variant, size, intent, styles['copy-button'], className)}
84
+ onClick={handleCopied}
85
+ {...rest}
86
+ >
87
+ <CopyIcon svgClassName={cx(svgColor, svgClassName)} width="18px" height="18px" />
88
+ </Button>
89
+ </Tooltip>
90
+ </div>
91
+ )
92
+ }
@@ -0,0 +1,47 @@
1
+ ---
2
+ import type { HTMLAttributes } from 'astro/types'
3
+ import type { Intent, Size, Variant } from './@types/button.js'
4
+ import Button from './button.astro'
5
+
6
+ import styles from './button.module.css'
7
+
8
+ interface Props extends HTMLAttributes<'button'>, Omit<HTMLAttributes<'a'>, 'type'> {
9
+ variant?: Variant
10
+ size?: Size
11
+ type?: 'submit' | 'reset' | 'button'
12
+ intent?: Intent
13
+ fullWidth?: boolean
14
+ ripple?: boolean
15
+ class?: string
16
+ as?: 'button' | 'a'
17
+ href?: string
18
+ square?: boolean
19
+ round?: boolean
20
+ }
21
+
22
+ const {
23
+ square = false,
24
+ round = true,
25
+ variant,
26
+ size,
27
+ type,
28
+ intent,
29
+ class: className,
30
+ ...rest
31
+ } = Astro.props as Props
32
+ ---
33
+
34
+ <Button
35
+ class:list={[
36
+ 'icon-button',
37
+ variant,
38
+ size,
39
+ intent,
40
+ { [styles.square]: square },
41
+ { [styles.round]: !square && round },
42
+ className
43
+ ]}
44
+ {...rest}
45
+ >
46
+ <slot />
47
+ </Button>
@@ -0,0 +1,44 @@
1
+ 'use client'
2
+
3
+ import cx from 'classnames'
4
+ import type React from 'react'
5
+ import { Button } from './button'
6
+ import type { ButtonProps } from './button.js'
7
+
8
+ import styles from './button.module.css'
9
+
10
+ type IconButtonProps<C extends React.ElementType = 'button'> = ButtonProps<C> & {
11
+ square?: boolean
12
+ round?: boolean
13
+ }
14
+
15
+ export const IconButton = <C extends React.ElementType = 'button'>({
16
+ square = false,
17
+ round = true,
18
+ variant,
19
+ size = 'sm',
20
+ intent,
21
+ className,
22
+ children,
23
+ ...rest
24
+ }: IconButtonProps<C>) => {
25
+ return (
26
+ <Button
27
+ variant={variant}
28
+ size={size}
29
+ intent={intent}
30
+ className={cx(
31
+ 'icon-button',
32
+ variant,
33
+ size,
34
+ intent,
35
+ { [styles.square]: square },
36
+ { [styles.round]: !square && round },
37
+ className
38
+ )}
39
+ {...rest}
40
+ >
41
+ {children}
42
+ </Button>
43
+ )
44
+ }
@@ -0,0 +1,5 @@
1
+ export * from './button'
2
+ export * from './icon-button'
3
+ export * from './copy-button'
4
+ export * from './control-buttons'
5
+ export * from './button-group'