polpo 0.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 (332) hide show
  1. package/.eslintrc.cjs +9 -0
  2. package/.storybook/decorators.tsx +61 -0
  3. package/.storybook/main.ts +47 -0
  4. package/.storybook/manager-head.html +2 -0
  5. package/.storybook/manager.ts +7 -0
  6. package/.storybook/preview-head.html +2 -0
  7. package/.storybook/preview.ts +38 -0
  8. package/.storybook/theme.ts +47 -0
  9. package/.turbo/daemon/f5c5c8fb195b01d0-turbo.log.2024-05-26 +0 -0
  10. package/.turbo/turbo-build$colon$watch.log +96 -0
  11. package/.turbo/turbo-build-storybook.log +0 -0
  12. package/.turbo/turbo-build.log +77 -0
  13. package/.turbo/turbo-lint$colon$fix.log +2 -0
  14. package/.turbo/turbo-lint.log +4 -0
  15. package/README.md +68 -0
  16. package/dist/chunk-M4KRSYE7.js +3 -0
  17. package/dist/chunk-M4KRSYE7.js.map +1 -0
  18. package/dist/chunk-U5XSMSKZ.js +3 -0
  19. package/dist/chunk-U5XSMSKZ.js.map +1 -0
  20. package/dist/get-modal-position-DPftPoU2.d.cts +28 -0
  21. package/dist/get-modal-position-DPftPoU2.d.ts +28 -0
  22. package/dist/helpers.cjs +3 -0
  23. package/dist/helpers.cjs.map +1 -0
  24. package/dist/helpers.d.cts +15 -0
  25. package/dist/helpers.d.ts +15 -0
  26. package/dist/helpers.js +3 -0
  27. package/dist/helpers.js.map +1 -0
  28. package/dist/hooks.cjs +3 -0
  29. package/dist/hooks.cjs.map +1 -0
  30. package/dist/hooks.d.cts +121 -0
  31. package/dist/hooks.d.ts +121 -0
  32. package/dist/hooks.js +3 -0
  33. package/dist/hooks.js.map +1 -0
  34. package/dist/ui.cjs +1987 -0
  35. package/dist/ui.cjs.map +1 -0
  36. package/dist/ui.d.cts +3932 -0
  37. package/dist/ui.d.ts +3932 -0
  38. package/dist/ui.js +1987 -0
  39. package/dist/ui.js.map +1 -0
  40. package/package.json +98 -0
  41. package/src/components/accordion/accordion-item.stories.tsx +128 -0
  42. package/src/components/accordion/accordion-item.tsx +119 -0
  43. package/src/components/accordion/accordion.stories.tsx +74 -0
  44. package/src/components/accordion/accordion.style.ts +42 -0
  45. package/src/components/accordion/accordion.tsx +56 -0
  46. package/src/components/accordion/index.ts +2 -0
  47. package/src/components/buttons/button/button.stories.tsx +103 -0
  48. package/src/components/buttons/button/button.style.ts +147 -0
  49. package/src/components/buttons/button/button.tsx +119 -0
  50. package/src/components/buttons/button/index.ts +1 -0
  51. package/src/components/buttons/index.ts +1 -0
  52. package/src/components/cards/flip-card/flip-card.stories.tsx +61 -0
  53. package/src/components/cards/flip-card/flip-card.style.ts +45 -0
  54. package/src/components/cards/flip-card/flip-card.tsx +55 -0
  55. package/src/components/cards/flip-card/index.ts +1 -0
  56. package/src/components/cards/hover-card/hover-card.stories.tsx +45 -0
  57. package/src/components/cards/hover-card/hover-card.style.ts +13 -0
  58. package/src/components/cards/hover-card/hover-card.tsx +71 -0
  59. package/src/components/cards/hover-card/index.ts +1 -0
  60. package/src/components/cards/index.ts +3 -0
  61. package/src/components/cards/slide-card/index.ts +1 -0
  62. package/src/components/cards/slide-card/slide-card.stories.tsx +47 -0
  63. package/src/components/cards/slide-card/slide-card.tsx +42 -0
  64. package/src/components/form/checkbox/checkbox.stories.tsx +34 -0
  65. package/src/components/form/checkbox/checkbox.style.ts +75 -0
  66. package/src/components/form/checkbox/checkbox.tsx +76 -0
  67. package/src/components/form/checkbox/index.ts +1 -0
  68. package/src/components/form/controller/controller.tsx +42 -0
  69. package/src/components/form/controller/index.ts +1 -0
  70. package/src/components/form/date-picker/date-picker.stories.tsx +38 -0
  71. package/src/components/form/date-picker/date-picker.tsx +67 -0
  72. package/src/components/form/date-picker/index.ts +1 -0
  73. package/src/components/form/field/field.stories.tsx +49 -0
  74. package/src/components/form/field/field.style.ts +79 -0
  75. package/src/components/form/field/field.tsx +83 -0
  76. package/src/components/form/field/field.types.ts +28 -0
  77. package/src/components/form/field/index.ts +2 -0
  78. package/src/components/form/form.stories.types.tsx +50 -0
  79. package/src/components/form/form.types.ts +37 -0
  80. package/src/components/form/index.ts +14 -0
  81. package/src/components/form/input/index.ts +1 -0
  82. package/src/components/form/input/input.stories.tsx +41 -0
  83. package/src/components/form/input/input.tsx +73 -0
  84. package/src/components/form/input-color/index.ts +1 -0
  85. package/src/components/form/input-color/input-color.stories.tsx +46 -0
  86. package/src/components/form/input-color/input-color.style.ts +93 -0
  87. package/src/components/form/input-color/input-color.tsx +159 -0
  88. package/src/components/form/input-file/index.ts +1 -0
  89. package/src/components/form/input-file/input-file.stories.tsx +40 -0
  90. package/src/components/form/input-file/input-file.style.ts +143 -0
  91. package/src/components/form/input-file/input-file.tsx +214 -0
  92. package/src/components/form/input-password/index.ts +1 -0
  93. package/src/components/form/input-password/input-password.stories.tsx +37 -0
  94. package/src/components/form/input-password/input-password.tsx +83 -0
  95. package/src/components/form/radio/index.ts +1 -0
  96. package/src/components/form/radio/radio.stories.tsx +43 -0
  97. package/src/components/form/radio/radio.style.ts +58 -0
  98. package/src/components/form/radio/radio.tsx +76 -0
  99. package/src/components/form/select/index.ts +1 -0
  100. package/src/components/form/select/options.tsx +140 -0
  101. package/src/components/form/select/select-option.tsx +84 -0
  102. package/src/components/form/select/select.stories.tsx +89 -0
  103. package/src/components/form/select/select.style.ts +164 -0
  104. package/src/components/form/select/select.tsx +327 -0
  105. package/src/components/form/select/select.types.ts +93 -0
  106. package/src/components/form/slider/index.ts +1 -0
  107. package/src/components/form/slider/slider.stories.tsx +40 -0
  108. package/src/components/form/slider/slider.style.ts +90 -0
  109. package/src/components/form/slider/slider.tsx +108 -0
  110. package/src/components/form/switch/index.ts +1 -0
  111. package/src/components/form/switch/switch.stories.tsx +38 -0
  112. package/src/components/form/switch/switch.style.ts +120 -0
  113. package/src/components/form/switch/switch.tsx +111 -0
  114. package/src/components/form/textarea/index.ts +1 -0
  115. package/src/components/form/textarea/textarea.stories.tsx +43 -0
  116. package/src/components/form/textarea/textarea.style.ts +7 -0
  117. package/src/components/form/textarea/textarea.tsx +76 -0
  118. package/src/components/icon/icon.stories.tsx +63 -0
  119. package/src/components/icon/icon.tsx +64 -0
  120. package/src/components/icon/icons/index.ts +18 -0
  121. package/src/components/icon/icons/object.tsx +482 -0
  122. package/src/components/icon/icons/social.tsx +72 -0
  123. package/src/components/icon/icons/symbol.tsx +776 -0
  124. package/src/components/icon/index.ts +5 -0
  125. package/src/components/image/image.stories.tsx +25 -0
  126. package/src/components/image/image.tsx +7 -0
  127. package/src/components/image/index.ts +1 -0
  128. package/src/components/index.ts +16 -0
  129. package/src/components/infinity-scroll/index.ts +1 -0
  130. package/src/components/infinity-scroll/infinity-scroll.stories.tsx +75 -0
  131. package/src/components/infinity-scroll/infinity-scroll.style.ts +30 -0
  132. package/src/components/infinity-scroll/infinity-scroll.tsx +56 -0
  133. package/src/components/line/index.ts +1 -0
  134. package/src/components/line/line.stories.tsx +67 -0
  135. package/src/components/line/line.style.ts +57 -0
  136. package/src/components/line/line.tsx +76 -0
  137. package/src/components/loaders/index.ts +1 -0
  138. package/src/components/loaders/simple-loader/index.ts +1 -0
  139. package/src/components/loaders/simple-loader/simple-loader.stories.tsx +21 -0
  140. package/src/components/loaders/simple-loader/simple-loader.style.ts +13 -0
  141. package/src/components/loaders/simple-loader/simple-loader.tsx +15 -0
  142. package/src/components/modals/action-modal/action-modal.stories.tsx +134 -0
  143. package/src/components/modals/action-modal/action-modal.style.ts +129 -0
  144. package/src/components/modals/action-modal/action-modal.tsx +150 -0
  145. package/src/components/modals/action-modal/index.ts +1 -0
  146. package/src/components/modals/aside-modal/aside-modal.stories.tsx +82 -0
  147. package/src/components/modals/aside-modal/aside-modal.style.ts +108 -0
  148. package/src/components/modals/aside-modal/aside-modal.tsx +66 -0
  149. package/src/components/modals/aside-modal/index.ts +1 -0
  150. package/src/components/modals/confirmation-modal/confirmation-modal.stories.tsx +50 -0
  151. package/src/components/modals/confirmation-modal/confirmation-modal.style.ts +17 -0
  152. package/src/components/modals/confirmation-modal/confirmation-modal.tsx +43 -0
  153. package/src/components/modals/confirmation-modal/index.ts +1 -0
  154. package/src/components/modals/index.ts +4 -0
  155. package/src/components/modals/modal/index.ts +1 -0
  156. package/src/components/modals/modal/modal.style.ts +10 -0
  157. package/src/components/modals/modal/modal.tsx +132 -0
  158. package/src/components/ripple/index.ts +1 -0
  159. package/src/components/ripple/ripple.stories.tsx +38 -0
  160. package/src/components/ripple/ripple.style.ts +33 -0
  161. package/src/components/ripple/ripple.tsx +63 -0
  162. package/src/components/smart-table/index.ts +1 -0
  163. package/src/components/smart-table/smart-table.column.tsx +63 -0
  164. package/src/components/smart-table/smart-table.helpers.tsx +59 -0
  165. package/src/components/smart-table/smart-table.hooks.ts +27 -0
  166. package/src/components/smart-table/smart-table.row.tsx +29 -0
  167. package/src/components/smart-table/smart-table.stories.tsx +301 -0
  168. package/src/components/smart-table/smart-table.style.ts +102 -0
  169. package/src/components/smart-table/smart-table.tsx +112 -0
  170. package/src/components/smart-table/smart-table.types.ts +41 -0
  171. package/src/components/tabs/index.ts +1 -0
  172. package/src/components/tabs/tabs-container.stories.tsx +159 -0
  173. package/src/components/tabs/tabs-list.tsx +131 -0
  174. package/src/components/tabs/tabs.stories.tsx +68 -0
  175. package/src/components/tabs/tabs.style.ts +132 -0
  176. package/src/components/tabs/tabs.tsx +117 -0
  177. package/src/components/tag/index.ts +1 -0
  178. package/src/components/tag/tag.stories.tsx +49 -0
  179. package/src/components/tag/tag.style.ts +24 -0
  180. package/src/components/tag/tag.tsx +44 -0
  181. package/src/components/tooltips/click-to-copy/click-to-copy.stories.tsx +39 -0
  182. package/src/components/tooltips/click-to-copy/click-to-copy.tsx +41 -0
  183. package/src/components/tooltips/click-to-copy/index.ts +1 -0
  184. package/src/components/tooltips/index.ts +2 -0
  185. package/src/components/tooltips/tooltip/index.ts +1 -0
  186. package/src/components/tooltips/tooltip/tooltip.stories.tsx +35 -0
  187. package/src/components/tooltips/tooltip/tooltip.style.ts +62 -0
  188. package/src/components/tooltips/tooltip/tooltip.tsx +45 -0
  189. package/src/components/typography/index.ts +2 -0
  190. package/src/components/typography/typography.constants.ts +43 -0
  191. package/src/components/typography/typography.stories.tsx +106 -0
  192. package/src/components/typography/typography.style.ts +76 -0
  193. package/src/components/typography/typography.tsx +79 -0
  194. package/src/contexts/fetch-context/fetch-context.tsx +114 -0
  195. package/src/contexts/fetch-context/index.ts +1 -0
  196. package/src/contexts/form-context/form-context.tsx +43 -0
  197. package/src/contexts/form-context/index.ts +1 -0
  198. package/src/contexts/index.ts +3 -0
  199. package/src/contexts/theme-context/index.ts +3 -0
  200. package/src/contexts/theme-context/theme-context.tsx +158 -0
  201. package/src/contexts/theme-context/theme.animations.ts +180 -0
  202. package/src/contexts/theme-context/theme.defaults.ts +205 -0
  203. package/src/contexts/theme-context/theme.style.ts +78 -0
  204. package/src/contexts/theme-context/themes.ts +96 -0
  205. package/src/core/http-client.d.ts +11 -0
  206. package/src/core/http-client.d.ts.map +1 -0
  207. package/src/core/http-client.ts +47 -0
  208. package/src/core/index.d.ts +2 -0
  209. package/src/core/index.d.ts.map +1 -0
  210. package/src/core/index.ts +1 -0
  211. package/src/core/variants/color.ts +36 -0
  212. package/src/core/variants/index.ts +3 -0
  213. package/src/core/variants/radius.ts +56 -0
  214. package/src/core/variants/size.ts +44 -0
  215. package/src/helpers/format-bytes.ts +11 -0
  216. package/src/helpers/format-dates.ts +11 -0
  217. package/src/helpers/get-modal-position.ts +66 -0
  218. package/src/helpers/index.ts +4 -0
  219. package/src/helpers/text/index.ts +1 -0
  220. package/src/helpers/text/to-capitalize.ts +17 -0
  221. package/src/hooks/index.ts +23 -0
  222. package/src/hooks/use-async.ts +88 -0
  223. package/src/hooks/use-classnames.ts +13 -0
  224. package/src/hooks/use-constant.ts +3 -0
  225. package/src/hooks/use-debounce.ts +15 -0
  226. package/src/hooks/use-dimensions.ts +22 -0
  227. package/src/hooks/use-event-listener.ts +71 -0
  228. package/src/hooks/use-file-reader.ts +69 -0
  229. package/src/hooks/use-hover.ts +17 -0
  230. package/src/hooks/use-in-view.ts +20 -0
  231. package/src/hooks/use-input-handlers.ts +49 -0
  232. package/src/hooks/use-media-query.ts +25 -0
  233. package/src/hooks/use-modal-in-container.ts +94 -0
  234. package/src/hooks/use-mouse-position.ts +16 -0
  235. package/src/hooks/use-observer.ts +18 -0
  236. package/src/hooks/use-on-click-outside-ref.ts +17 -0
  237. package/src/hooks/use-online-status.ts +12 -0
  238. package/src/hooks/use-render-count.ts +11 -0
  239. package/src/hooks/use-safe-dispatch.ts +22 -0
  240. package/src/hooks/use-scroll.ts +31 -0
  241. package/src/hooks/use-state-history.ts +22 -0
  242. package/src/hooks/use-toggle-values.ts +14 -0
  243. package/src/hooks/use-toggle.ts +11 -0
  244. package/src/hooks/use-viewport.ts +38 -0
  245. package/src/index.ts +5 -0
  246. package/src/layouts/flex/flex.tsx +75 -0
  247. package/src/layouts/flex/index.ts +1 -0
  248. package/src/layouts/grid/grid.tsx +86 -0
  249. package/src/layouts/grid/index.ts +1 -0
  250. package/src/layouts/index.ts +3 -0
  251. package/src/layouts/section-layout/index.ts +1 -0
  252. package/src/layouts/section-layout/section-layout.stories.tsx +55 -0
  253. package/src/layouts/section-layout/section-layout.style.ts +21 -0
  254. package/src/layouts/section-layout/section-layout.tsx +46 -0
  255. package/src/stories/GettingStarted.mdx +66 -0
  256. package/src/types/generics.ts +68 -0
  257. package/src/types/index.ts +1 -0
  258. package/svg/Name=airplane, Category=object.svg +3 -0
  259. package/svg/Name=arrow-circle, Category=symbol.svg +3 -0
  260. package/svg/Name=arrow-down, Category=symbol.svg +3 -0
  261. package/svg/Name=arrow-left, Category=symbol.svg +3 -0
  262. package/svg/Name=arrow-right, Category=symbol.svg +3 -0
  263. package/svg/Name=arrow-up, Category=symbol.svg +3 -0
  264. package/svg/Name=bell, Category=object.svg +3 -0
  265. package/svg/Name=bicycle, Category=object.svg +3 -0
  266. package/svg/Name=book-open, Category=object.svg +3 -0
  267. package/svg/Name=book-solid, Category=object.svg +6 -0
  268. package/svg/Name=box-shadow, Category=symbol.svg +5 -0
  269. package/svg/Name=calendar, Category=object.svg +3 -0
  270. package/svg/Name=camera, Category=object.svg +3 -0
  271. package/svg/Name=caret-down, Category=symbol.svg +3 -0
  272. package/svg/Name=caret-left, Category=symbol.svg +3 -0
  273. package/svg/Name=caret-right, Category=symbol.svg +3 -0
  274. package/svg/Name=caret-up, Category=symbol.svg +3 -0
  275. package/svg/Name=checkmark, Category=symbol.svg +3 -0
  276. package/svg/Name=clean-computer, Category=object.svg +10 -0
  277. package/svg/Name=codepen, Category=social.svg +3 -0
  278. package/svg/Name=creative, Category=symbol.svg +5 -0
  279. package/svg/Name=cross, Category=symbol.svg +4 -0
  280. package/svg/Name=crossed-flags, Category=object.svg +4 -0
  281. package/svg/Name=cv, Category=symbol.svg +5 -0
  282. package/svg/Name=design-ui, Category=symbol.svg +9 -0
  283. package/svg/Name=document, Category=object.svg +3 -0
  284. package/svg/Name=door-closed, Category=object.svg +3 -0
  285. package/svg/Name=door-open, Category=object.svg +3 -0
  286. package/svg/Name=double-caret-down, Category=symbol.svg +4 -0
  287. package/svg/Name=double-caret-left, Category=symbol.svg +4 -0
  288. package/svg/Name=double-caret-righ, Category=symbol.svg +4 -0
  289. package/svg/Name=double-caret-up, Category=symbol.svg +4 -0
  290. package/svg/Name=download, Category=symbol.svg +5 -0
  291. package/svg/Name=dropper, Category=object.svg +5 -0
  292. package/svg/Name=envelope, Category=object.svg +3 -0
  293. package/svg/Name=exclamation-close, Category=symbol.svg +4 -0
  294. package/svg/Name=exclamation-open, Category=symbol.svg +4 -0
  295. package/svg/Name=external-link, Category=symbol.svg +3 -0
  296. package/svg/Name=eye, Category=object.svg +4 -0
  297. package/svg/Name=eye-hidden, Category=object.svg +7 -0
  298. package/svg/Name=facebook, Category=social.svg +3 -0
  299. package/svg/Name=form, Category=symbol.svg +8 -0
  300. package/svg/Name=game-control, Category=object.svg +3 -0
  301. package/svg/Name=gear, Category=object.svg +3 -0
  302. package/svg/Name=github, Category=social.svg +3 -0
  303. package/svg/Name=house, Category=object.svg +3 -0
  304. package/svg/Name=hyphen, Category=symbol.svg +3 -0
  305. package/svg/Name=info, Category=symbol.svg +3 -0
  306. package/svg/Name=instagram, Category=social.svg +3 -0
  307. package/svg/Name=link, Category=symbol.svg +5 -0
  308. package/svg/Name=linkedin, Category=social.svg +3 -0
  309. package/svg/Name=magnifying-glass, Category=object.svg +3 -0
  310. package/svg/Name=message, Category=symbol.svg +4 -0
  311. package/svg/Name=moon, Category=object.svg +5 -0
  312. package/svg/Name=order-list, Category=symbol.svg +7 -0
  313. package/svg/Name=pencil, Category=object.svg +3 -0
  314. package/svg/Name=pin-location, Category=symbol.svg +3 -0
  315. package/svg/Name=question-mark-close, Category=symbol.svg +3 -0
  316. package/svg/Name=question-mark-open, Category=symbol.svg +3 -0
  317. package/svg/Name=share, Category=symbol.svg +5 -0
  318. package/svg/Name=spinner, Category=symbol.svg +9 -0
  319. package/svg/Name=star, Category=object.svg +3 -0
  320. package/svg/Name=star-empty, Category=object.svg +3 -0
  321. package/svg/Name=sun, Category=object.svg +11 -0
  322. package/svg/Name=text-shadow, Category=symbol.svg +4 -0
  323. package/svg/Name=thinking, Category=symbol.svg +3 -0
  324. package/svg/Name=trash-can, Category=object.svg +4 -0
  325. package/svg/Name=upload, Category=symbol.svg +5 -0
  326. package/svg/Name=user, Category=symbol.svg +4 -0
  327. package/svg/Name=warning, Category=symbol.svg +5 -0
  328. package/svg/Name=whatsapp, Category=social.svg +3 -0
  329. package/svgconfig.json +4 -0
  330. package/tsconfig.json +14 -0
  331. package/tsup.config.cjs +21 -0
  332. package/vite.config.ts +13 -0
@@ -0,0 +1,147 @@
1
+ import styled from 'styled-components';
2
+
3
+ import { RadiusStyles, SizeStyles } from '../../../core/variants';
4
+
5
+ export type ButtonStyleProps = {
6
+ $color: string;
7
+ $colorDark: string;
8
+ $colorContrast: string;
9
+ };
10
+
11
+ export const ButtonStyle = styled.button<ButtonStyleProps>`
12
+ cursor: pointer;
13
+ font-weight: bold;
14
+ display: grid;
15
+ grid-auto-flow: column;
16
+ gap: 0.7em;
17
+ align-items: center;
18
+ white-space: nowrap;
19
+ text-overflow: ellipsis;
20
+ overflow: hidden;
21
+ justify-items: center;
22
+ text-align: center;
23
+ justify-content: center;
24
+ position: relative;
25
+ user-select: none;
26
+
27
+ ${SizeStyles}
28
+ ${RadiusStyles}
29
+
30
+ .button-loader-icon {
31
+ animation: spin 800ms linear infinite;
32
+ font-size: 1.2em;
33
+ }
34
+
35
+ &.fit {
36
+ width: fit-content;
37
+ }
38
+
39
+ &.full {
40
+ width: 100%;
41
+ }
42
+
43
+ .button-left-icon,
44
+ .button-right-icon {
45
+ font-size: 1.2em;
46
+ opacity: 1;
47
+ }
48
+
49
+ .button-text {
50
+ display: grid;
51
+ align-items: center;
52
+ }
53
+
54
+ .ripple-effect {
55
+ background: ${props => props.$colorContrast};
56
+ }
57
+
58
+ padding: 1em;
59
+ font-size: ${props => props.theme.constants.typography.label.fontSize};
60
+ background: ${props => props.$color};
61
+ color: ${props => props.$colorContrast};
62
+ box-shadow: 0 0 0 0 transparent;
63
+ transition: all 250ms ease;
64
+ border: 1px solid ${props => props.$color};
65
+
66
+ &:not(:disabled) {
67
+ &:not(.no-shadow) {
68
+ &:hover {
69
+ box-shadow:
70
+ 0 1.4em 0.5em -1em ${props => props.theme.colors.black}88,
71
+ 0 0.7em 1em -0.5em ${props => props.theme.colors.black}88;
72
+ }
73
+
74
+ &:active {
75
+ box-shadow:
76
+ 0 0.3em 0.4em -0.2em ${props => props.theme.colors.black}88,
77
+ 0 0.2em 0.8em -0.1em ${props => props.theme.colors.black}88;
78
+ }
79
+ }
80
+
81
+ &:hover {
82
+ transform: scale(1.02);
83
+ }
84
+
85
+ &:active {
86
+ background: ${props => props.$colorDark};
87
+ border-color: ${props => props.$colorDark};
88
+ transform: scale(0.98);
89
+ }
90
+ }
91
+
92
+ &:disabled {
93
+ background: ${props => props.theme.colors.gray6};
94
+ color: ${props => props.theme.colors.gray9};
95
+ border: 1px solid ${props => props.theme.colors.gray6};
96
+ cursor: not-allowed;
97
+ pointer-events: none;
98
+ }
99
+
100
+ &.is-loading {
101
+ pointer-events: none;
102
+ }
103
+
104
+ &.ghost-variant {
105
+ background: transparent;
106
+ color: ${props => props.$color};
107
+ border: 1px solid;
108
+
109
+ &:not(:disabled):hover {
110
+ background: ${props => props.$color}22;
111
+ }
112
+
113
+ &:not(:disabled):active {
114
+ background: ${props => props.$color}55;
115
+ }
116
+
117
+ &:disabled {
118
+ color: ${props => props.theme.colors.gray6};
119
+ }
120
+
121
+ .ripple-effect {
122
+ background: ${props => props.$color};
123
+ }
124
+ }
125
+
126
+ &.flat-variant {
127
+ background: transparent;
128
+ color: ${props => props.$color};
129
+ border: 0;
130
+
131
+ &:not(:disabled):hover {
132
+ background: ${props => props.$color}22;
133
+ }
134
+
135
+ &:not(:disabled):active {
136
+ background: ${props => props.$color}55;
137
+ }
138
+
139
+ &:disabled {
140
+ color: ${props => props.theme.colors.gray6};
141
+ }
142
+
143
+ .ripple-effect {
144
+ background: ${props => props.$color};
145
+ }
146
+ }
147
+ `;
@@ -0,0 +1,119 @@
1
+ import React, { ButtonHTMLAttributes } from 'react';
2
+ import { useTheme } from 'styled-components';
3
+
4
+ import { ThemeColor } from '../../../contexts';
5
+ import { SizeVariants, useSizeClassName, RadiusVariants, useRadiusClassName } from '../../../core/variants';
6
+ import { Icon, IconNameT } from '../../icon';
7
+ import { Ripple } from '../../ripple';
8
+
9
+ import { ButtonStyle, ButtonStyleProps } from './button.style';
10
+
11
+ import { useClassNames } from '@polpo/hooks';
12
+
13
+ export enum ButtonVariant {
14
+ SOLID = 'solid',
15
+ GHOST = 'ghost',
16
+ FLAT = 'flat',
17
+ }
18
+
19
+ export enum ButtonColor {
20
+ PRIMARY = 'primary',
21
+ SECONDARY = 'secondary',
22
+ TERTIARY = 'tertiary',
23
+ INFO = 'info',
24
+ WARNING = 'warning',
25
+ ALERT = 'alert',
26
+ ACTIVE = 'active',
27
+ }
28
+
29
+ const getColor = (color?: ThemeColor): ButtonStyleProps | null => {
30
+ if (color) {
31
+ return {
32
+ $color: color.main,
33
+ $colorDark: color.dark,
34
+ $colorContrast: color.contrast,
35
+ };
36
+ }
37
+
38
+ return null;
39
+ };
40
+
41
+ export type ButtonProps = {
42
+ children?: React.ReactNode;
43
+ disabled?: boolean;
44
+ isLoading?: boolean;
45
+ size?: `${SizeVariants}`;
46
+ radius?: `${RadiusVariants}`;
47
+ variant?: `${ButtonVariant}`;
48
+ leftIcon?: IconNameT;
49
+ rightIcon?: IconNameT;
50
+ onClick?: ButtonHTMLAttributes<HTMLButtonElement>['onClick'];
51
+ width?: 'fit' | 'full';
52
+ className?: string;
53
+ style?: React.CSSProperties;
54
+ type?: ButtonHTMLAttributes<HTMLButtonElement>['type'];
55
+ noShadow?: boolean;
56
+ color?: `${ButtonColor}`;
57
+ };
58
+
59
+ const ButtonComponent = (
60
+ {
61
+ children,
62
+ disabled = false,
63
+ radius = RadiusVariants.Medium,
64
+ isLoading = false,
65
+ size = SizeVariants.Medium,
66
+ variant = 'solid',
67
+ leftIcon,
68
+ rightIcon,
69
+ onClick,
70
+ width = 'fit',
71
+ className = '',
72
+ style = {},
73
+ noShadow = false,
74
+ color,
75
+ type = 'button',
76
+ }: ButtonProps,
77
+ ref: React.ForwardedRef<HTMLButtonElement>,
78
+ ) => {
79
+ const theme = useTheme();
80
+ const buttonSize = useSizeClassName(size);
81
+ const buttonRadius = useRadiusClassName(radius);
82
+ const buttonClassName = useClassNames({
83
+ [buttonRadius]: true,
84
+ [buttonSize]: true,
85
+ 'ghost-variant': variant === ButtonVariant.GHOST,
86
+ 'flat-variant': variant === ButtonVariant.FLAT,
87
+ 'is-loading': !disabled && isLoading,
88
+ 'no-shadow': noShadow,
89
+ [width]: !!width,
90
+ [className]: !!className,
91
+ });
92
+
93
+ const buttonColors: ButtonStyleProps = (color && getColor(theme.colors[color])) || {
94
+ $color: theme.colors.text.main,
95
+ $colorDark: theme.colors.text.dark,
96
+ $colorContrast: theme.colors.background.main,
97
+ };
98
+
99
+ return (
100
+ <ButtonStyle
101
+ ref={ref}
102
+ {...buttonColors}
103
+ className={buttonClassName}
104
+ style={style}
105
+ disabled={disabled}
106
+ onClick={onClick}
107
+ type={type}
108
+ >
109
+ {leftIcon && (!isLoading || disabled) && <Icon className='button-left-icon' name={leftIcon} />}
110
+ <span className='button-text'>
111
+ {!disabled && isLoading ? <Icon name='spinner' className='button-loader-icon' /> : children}
112
+ </span>
113
+ {rightIcon && (!isLoading || disabled) && <Icon className='button-right-icon' name={rightIcon} />}
114
+ <Ripple />
115
+ </ButtonStyle>
116
+ );
117
+ };
118
+
119
+ export const Button = React.forwardRef(ButtonComponent);
@@ -0,0 +1 @@
1
+ export * from './button';
@@ -0,0 +1 @@
1
+ export * from './button';
@@ -0,0 +1,61 @@
1
+ import { Grid } from '../../../layouts';
2
+ import { Typography } from '../../typography';
3
+
4
+ import { FlipCard } from './flip-card';
5
+
6
+ import type { Meta, StoryObj } from '@storybook/react';
7
+
8
+ const meta: Meta<typeof FlipCard> = {
9
+ title: 'Cards/FlipCard',
10
+ component: FlipCard,
11
+ argTypes: {
12
+ cardZIndex: { control: false },
13
+ flipDirection: {
14
+ control: 'inline-radio',
15
+ options: ['horizontal', 'vertical'],
16
+ },
17
+ flipSpeed: {
18
+ control: { type: 'range', step: 25, min: 0, max: 2000 },
19
+ },
20
+ isFlipped: { control: 'boolean' },
21
+ children: { control: false },
22
+ },
23
+ args: {
24
+ flipDirection: 'vertical',
25
+ flipSpeed: 500,
26
+ isFlipped: false,
27
+ },
28
+ render: args => (
29
+ <FlipCard {...args}>
30
+ <Grid
31
+ pc='center'
32
+ style={{
33
+ background: 'linear-gradient(90deg, rgba(34,193,195,1) 0%, rgba(253,187,45,1) 100%)',
34
+ width: '300px',
35
+ height: '300px',
36
+ borderRadius: '10px',
37
+ }}
38
+ >
39
+ <Typography variant='hero'>A</Typography>
40
+ </Grid>
41
+ <Grid
42
+ pc='center'
43
+ style={{
44
+ background: 'linear-gradient(90deg, rgba(230,96,255,1) 0%, rgba(91,170,255,1) 100%)',
45
+ width: '300px',
46
+ height: '300px',
47
+ borderRadius: '10px',
48
+ }}
49
+ >
50
+ <Typography variant='hero'>B</Typography>
51
+ </Grid>
52
+ </FlipCard>
53
+ ),
54
+ };
55
+
56
+ export default meta;
57
+ type Story = StoryObj<typeof FlipCard>;
58
+
59
+ export const Default: Story = {
60
+ args: {},
61
+ };
@@ -0,0 +1,45 @@
1
+ import { CSSProperties } from 'react';
2
+ import styled from 'styled-components';
3
+
4
+ type FlipCardStyleProps = {
5
+ $cardZIndex: CSSProperties['zIndex'];
6
+ $isFlipped: boolean;
7
+ $flipSpeed: number;
8
+ $frontRotate: CSSProperties['transform'];
9
+ $backRotate: CSSProperties['transform'];
10
+ };
11
+
12
+ export const FlipCardStyle = styled.section<FlipCardStyleProps>`
13
+ perspective: 1000px;
14
+ z-index: ${({ $cardZIndex }) => $cardZIndex};
15
+
16
+ .flipper {
17
+ height: 100%;
18
+ position: relative;
19
+ width: 100%;
20
+ transform-style: preserve-3d;
21
+ }
22
+
23
+ .front,
24
+ .back {
25
+ -webkit-backface-visibility: hidden;
26
+ backface-visibility: hidden;
27
+ transform-style: preserve-3d;
28
+ transition: ${({ $flipSpeed }) => $flipSpeed}ms;
29
+ height: 100%;
30
+ left: 0;
31
+ top: 0;
32
+ width: 100%;
33
+ }
34
+
35
+ .front {
36
+ position: ${({ $isFlipped }) => ($isFlipped ? 'absolute' : 'relative')};
37
+ transform: ${({ $frontRotate }) => $frontRotate};
38
+ z-index: 2;
39
+ }
40
+
41
+ .back {
42
+ position: ${({ $isFlipped }) => ($isFlipped ? 'relative' : 'absolute')};
43
+ transform: ${({ $backRotate }) => $backRotate};
44
+ }
45
+ `;
@@ -0,0 +1,55 @@
1
+ import { CSSProperties, useMemo } from 'react';
2
+
3
+ import { FlipCardStyle } from './flip-card.style';
4
+
5
+ type FlipCardProps = {
6
+ cardZIndex?: CSSProperties['zIndex'];
7
+ isFlipped?: boolean;
8
+ flipSpeed?: number;
9
+ flipDirection?: 'horizontal' | 'vertical';
10
+ children: [React.ReactNode, React.ReactNode];
11
+ };
12
+
13
+ export const FlipCard = ({
14
+ cardZIndex = 'auto',
15
+ flipDirection = 'vertical',
16
+ flipSpeed = 500,
17
+ isFlipped = false,
18
+ children,
19
+ }: FlipCardProps): React.ReactElement => {
20
+ const getComponent = (key: 0 | 1): React.ReactNode => {
21
+ if (children.length !== 2) {
22
+ throw new Error('Component FlipCard requires 2 children');
23
+ }
24
+
25
+ return children[key] as React.ReactNode;
26
+ };
27
+
28
+ const frontRotate = useMemo(() => {
29
+ const deg = isFlipped ? 180 : 0;
30
+
31
+ return `rotate${flipDirection === 'horizontal' ? 'Y' : 'X'}(${deg}deg)`;
32
+ }, [flipDirection, isFlipped]);
33
+
34
+ const backRotate = useMemo(() => {
35
+ const deg = isFlipped ? 0 : -180;
36
+
37
+ return `rotate${flipDirection === 'horizontal' ? 'Y' : 'X'}(${deg}deg)`;
38
+ }, [flipDirection, isFlipped]);
39
+
40
+ return (
41
+ <FlipCardStyle
42
+ $cardZIndex={cardZIndex}
43
+ $flipSpeed={flipSpeed}
44
+ $isFlipped={isFlipped}
45
+ $frontRotate={frontRotate}
46
+ $backRotate={backRotate}
47
+ >
48
+ <section className='flipper'>
49
+ <section className='front'>{getComponent(0)}</section>
50
+
51
+ <section className='back'>{getComponent(1)}</section>
52
+ </section>
53
+ </FlipCardStyle>
54
+ );
55
+ };
@@ -0,0 +1 @@
1
+ export * from './flip-card';
@@ -0,0 +1,45 @@
1
+ import { Grid } from '../../../layouts';
2
+ import { Typography } from '../../typography';
3
+
4
+ import { HoverCard } from './hover-card';
5
+
6
+ import type { Meta, StoryObj } from '@storybook/react';
7
+
8
+ const meta: Meta<typeof HoverCard> = {
9
+ title: 'Cards/HoverCard',
10
+ component: HoverCard,
11
+ argTypes: {
12
+ className: { control: false },
13
+ width: { control: 'inline-radio', options: ['fit-content', '100%'] },
14
+ translationZ: { control: { type: 'range', min: 1, max: 60 } },
15
+ threshold: { control: { type: 'range', min: 1, max: 60 } },
16
+ children: { control: false },
17
+ },
18
+ render: ({ children, ...args }) => (
19
+ <HoverCard {...args}>
20
+ <Grid
21
+ pc='center'
22
+ style={{
23
+ background: 'linear-gradient(90deg, rgba(34,193,195,1) 0%, rgba(253,187,45,1) 100%)',
24
+ width: '300px',
25
+ height: '300px',
26
+ borderRadius: '10px',
27
+ }}
28
+ >
29
+ <Typography variant='header4'>{children}</Typography>
30
+ </Grid>
31
+ </HoverCard>
32
+ ),
33
+ args: {
34
+ children: 'Hover me',
35
+ threshold: 5,
36
+ translationZ: 25,
37
+ },
38
+ };
39
+
40
+ export default meta;
41
+ type Story = StoryObj<typeof HoverCard>;
42
+
43
+ export const Default: Story = {
44
+ args: {},
45
+ };
@@ -0,0 +1,13 @@
1
+ import styled from 'styled-components';
2
+
3
+ export const HoverCardStyle = styled.span`
4
+ display: inline-block;
5
+ transition: all 300ms ease;
6
+
7
+ .card-hover-layer {
8
+ transition: all 100ms ease;
9
+ width: 100%;
10
+ height: 100%;
11
+ display: grid;
12
+ }
13
+ `;
@@ -0,0 +1,71 @@
1
+ import { MouseEvent, MouseEventHandler, useCallback, useRef } from 'react';
2
+
3
+ import { HoverCardStyle } from './hover-card.style';
4
+
5
+ import { useEventListener } from '@polpo/hooks';
6
+
7
+ type HoverCardProps = {
8
+ children: React.ReactNode;
9
+ threshold?: number;
10
+ translationZ?: number;
11
+ width?: 'fit-content' | '100%';
12
+ className?: string;
13
+ };
14
+
15
+ export const HoverCard = ({
16
+ children,
17
+ threshold = 5,
18
+ translationZ = 25,
19
+ width = 'fit-content',
20
+ className = '',
21
+ }: HoverCardProps) => {
22
+ const refCard = useRef<HTMLElement>(null);
23
+ const refLayer = useRef<HTMLElement>(null);
24
+
25
+ const mouseMoveCallback = useCallback(
26
+ (e: MouseEvent) => {
27
+ const card = refCard.current;
28
+ const layer = refLayer.current;
29
+
30
+ if (!card || !layer) return;
31
+
32
+ const { clientX, clientY, currentTarget } = e;
33
+ const { clientWidth, clientHeight } = currentTarget;
34
+ const { top, left } = card.getBoundingClientRect();
35
+
36
+ const horizontal = (clientX - left) / clientWidth;
37
+ const vertical = (clientY - top) / clientHeight;
38
+
39
+ const relativePercentageX = horizontal * 2 - 1;
40
+ const relativePercentageY = vertical * 2 - 1;
41
+
42
+ const rotateY = (relativePercentageY * threshold).toFixed(2);
43
+ const rotateX = (relativePercentageX * threshold).toFixed(2);
44
+
45
+ layer.style.transform = `perspective(${clientWidth}px) rotateX(${-rotateY}deg) rotateY(${rotateX}deg)`;
46
+ card.style.transform = `perspective(${clientWidth}px) translateZ(${translationZ}px)`;
47
+ },
48
+ [threshold, translationZ],
49
+ );
50
+
51
+ const mouseLeaveCallback = useCallback<MouseEventHandler>(e => {
52
+ const card = refCard.current;
53
+ const layer = refLayer.current;
54
+
55
+ if (!card || !layer) return;
56
+
57
+ layer.style.transform = `perspective(${e.currentTarget.clientWidth}px) rotateX(0) rotateY(0)`;
58
+ card.style.transform = `perspective(${e.currentTarget.clientWidth}px) translateZ(0)`;
59
+ }, []);
60
+
61
+ useEventListener('mousemove', mouseMoveCallback as unknown as EventListener, refCard);
62
+ useEventListener('mouseleave', mouseLeaveCallback as unknown as EventListener, refCard);
63
+
64
+ return (
65
+ <HoverCardStyle ref={refCard} style={{ width }} className={className}>
66
+ <span className='card-hover-layer' ref={refLayer}>
67
+ {children}
68
+ </span>
69
+ </HoverCardStyle>
70
+ );
71
+ };
@@ -0,0 +1 @@
1
+ export * from './hover-card';
@@ -0,0 +1,3 @@
1
+ export * from './slide-card';
2
+ export * from './flip-card';
3
+ export * from './hover-card';
@@ -0,0 +1 @@
1
+ export * from './slide-card';
@@ -0,0 +1,47 @@
1
+ import { Grid } from '../../../layouts';
2
+ import { Typography } from '../../typography';
3
+
4
+ import { SlideCard } from './slide-card';
5
+
6
+ import type { Meta, StoryObj } from '@storybook/react';
7
+
8
+ const meta: Meta<typeof SlideCard> = {
9
+ title: 'Cards/SlideCard',
10
+ component: SlideCard,
11
+ argTypes: {
12
+ children: { control: false },
13
+ className: { control: false },
14
+ style: { control: false },
15
+ isOpen: { control: 'boolean' },
16
+ },
17
+ decorators: [
18
+ Story => (
19
+ <Grid gap='1em' style={{ width: '500px' }}>
20
+ <section>
21
+ <Typography variant='header4'>Slide Card</Typography>
22
+ <Typography variant='label'>Toggle the card on the controls</Typography>
23
+ </section>
24
+ <Story />
25
+ </Grid>
26
+ ),
27
+ ],
28
+ args: {
29
+ isOpen: true,
30
+ children: (
31
+ <section style={{ border: '1px solid', padding: '1em', borderRadius: '1em' }}>
32
+ <Typography>
33
+ Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aperiam assumenda atque blanditiis commodi delectus
34
+ deleniti distinctio excepturi explicabo facere fuga laboriosam natus nihil pariatur perspiciatis quaerat qui
35
+ recusandae rerum sed, unde voluptatem.
36
+ </Typography>
37
+ </section>
38
+ ),
39
+ },
40
+ };
41
+
42
+ export default meta;
43
+ type Story = StoryObj<typeof SlideCard>;
44
+
45
+ export const Default: Story = {
46
+ args: {},
47
+ };
@@ -0,0 +1,42 @@
1
+ import { motion } from 'framer-motion';
2
+ import React from 'react';
3
+
4
+ const variants = {
5
+ vertical: {
6
+ open: {
7
+ height: 'auto',
8
+ /*
9
+ * transition: {
10
+ * type: 'spring',
11
+ * damping: 10,
12
+ * stiffness: 200,
13
+ * restDelta: 0.01,
14
+ * },
15
+ */
16
+ },
17
+ closed: {
18
+ height: 0,
19
+ },
20
+ },
21
+ };
22
+
23
+ type SlideCardProps = {
24
+ children: React.ReactNode;
25
+ isOpen: boolean;
26
+ className?: string;
27
+ style?: React.CSSProperties;
28
+ };
29
+
30
+ export const SlideCard = ({ children, isOpen, className = '', style = {} }: SlideCardProps) => {
31
+ return (
32
+ <motion.section
33
+ variants={variants.vertical}
34
+ initial={isOpen ? 'open' : 'closed'}
35
+ animate={isOpen ? 'open' : 'closed'}
36
+ className={className}
37
+ style={{ overflow: 'hidden', ...style }}
38
+ >
39
+ {children}
40
+ </motion.section>
41
+ );
42
+ };