@hellobetterdigitalnz/betterui 0.0.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 (230) hide show
  1. package/.editorconfig +17 -0
  2. package/.eslintrc.cjs +14 -0
  3. package/.storybook/main.ts +23 -0
  4. package/.storybook/preview.ts +17 -0
  5. package/README.md +30 -0
  6. package/index.html +13 -0
  7. package/package.json +45 -0
  8. package/public/image/table-image.png +0 -0
  9. package/public/vite.svg +1 -0
  10. package/src/App.tsx +30 -0
  11. package/src/Components/DataDisplay/Accordion/Accordion.stories.tsx +57 -0
  12. package/src/Components/DataDisplay/Accordion/Accordion.tsx +14 -0
  13. package/src/Components/DataDisplay/Accordion/AccordionContext.tsx +11 -0
  14. package/src/Components/DataDisplay/Accordion/AccordionContextInterface.tsx +8 -0
  15. package/src/Components/DataDisplay/Accordion/AccordionItem.tsx +62 -0
  16. package/src/Components/DataDisplay/Accordion/AccordionItemProps.tsx +12 -0
  17. package/src/Components/DataDisplay/Accordion/AccordionProps.tsx +8 -0
  18. package/src/Components/DataDisplay/Accordion/AccordionProvider.tsx +65 -0
  19. package/src/Components/DataDisplay/Accordion/AccordionProviderInterface.tsx +8 -0
  20. package/src/Components/DataDisplay/Accordion/accordion.module.scss +56 -0
  21. package/src/Components/DataDisplay/Badge/Badge.stories.tsx +44 -0
  22. package/src/Components/DataDisplay/Badge/Badge.tsx +32 -0
  23. package/src/Components/DataDisplay/Badge/BadgeProps.tsx +6 -0
  24. package/src/Components/DataDisplay/Badge/badge.module.scss +42 -0
  25. package/src/Components/DataDisplay/Cards/BannerCard/BannerCard.stories.tsx +26 -0
  26. package/src/Components/DataDisplay/Cards/BannerCard/BannerCard.tsx +47 -0
  27. package/src/Components/DataDisplay/Cards/BannerCard/BannerCardInterface.tsx +15 -0
  28. package/src/Components/DataDisplay/Cards/BannerCard/banner-card.scss +54 -0
  29. package/src/Components/DataDisplay/Cards/PathwayCard/PathwayCard.stories.tsx +31 -0
  30. package/src/Components/DataDisplay/Cards/PathwayCard/PathwayCard.tsx +53 -0
  31. package/src/Components/DataDisplay/Cards/PathwayCard/PathwayCardInterface.tsx +17 -0
  32. package/src/Components/DataDisplay/Cards/PathwayCard/pathway-card-stories.scss +3 -0
  33. package/src/Components/DataDisplay/Cards/PathwayCard/pathway-card.scss +62 -0
  34. package/src/Components/DataDisplay/Media/Media.tsx +26 -0
  35. package/src/Components/DataDisplay/Media/MediaProps.tsx +9 -0
  36. package/src/Components/DataDisplay/Media/media.scss +0 -0
  37. package/src/Components/DataDisplay/Modal/Modal.tsx +5 -0
  38. package/src/Components/DataDisplay/Modal/ModalActions.tsx +5 -0
  39. package/src/Components/DataDisplay/Modal/ModalActionsLeft.tsx +5 -0
  40. package/src/Components/DataDisplay/Modal/ModalActionsRight.tsx +5 -0
  41. package/src/Components/DataDisplay/Modal/ModalBody.tsx +5 -0
  42. package/src/Components/DataDisplay/Modal/ModalCurtain.tsx +5 -0
  43. package/src/Components/DataDisplay/Modal/ModalHeader.tsx +5 -0
  44. package/src/Components/DataDisplay/NotificationsBell/NotificationBell.stories.tsx +27 -0
  45. package/src/Components/DataDisplay/NotificationsBell/NotificationsBell.tsx +51 -0
  46. package/src/Components/DataDisplay/NotificationsBell/NotificationsBellProps.tsx +9 -0
  47. package/src/Components/DataDisplay/NotificationsBell/notificationBell.module.scss +48 -0
  48. package/src/Components/DataDisplay/NotificationsPanel/Notification.stories.tsx +128 -0
  49. package/src/Components/DataDisplay/NotificationsPanel/Notification.tsx +59 -0
  50. package/src/Components/DataDisplay/NotificationsPanel/NotificationProps.tsx +11 -0
  51. package/src/Components/DataDisplay/NotificationsPanel/NotificationsGroup.tsx +17 -0
  52. package/src/Components/DataDisplay/NotificationsPanel/NotificationsGroupProps.tsx +8 -0
  53. package/src/Components/DataDisplay/NotificationsPanel/NotificationsGroups.tsx +42 -0
  54. package/src/Components/DataDisplay/NotificationsPanel/NotificationsGroupsProps.tsx +7 -0
  55. package/src/Components/DataDisplay/NotificationsPanel/NotificationsHeader.tsx +27 -0
  56. package/src/Components/DataDisplay/NotificationsPanel/NotificationsHeaderProps.tsx +9 -0
  57. package/src/Components/DataDisplay/NotificationsPanel/NotificationsNone.tsx +11 -0
  58. package/src/Components/DataDisplay/NotificationsPanel/NotificationsPanel.tsx +8 -0
  59. package/src/Components/DataDisplay/NotificationsPanel/NotificationsPanelProps.tsx +7 -0
  60. package/src/Components/DataDisplay/NotificationsPanel/notificationPanel.module.scss +196 -0
  61. package/src/Components/DataDisplay/Tab/Tab.stories.tsx +72 -0
  62. package/src/Components/DataDisplay/Tab/Tab.tsx +20 -0
  63. package/src/Components/DataDisplay/Tab/TabBody.tsx +6 -0
  64. package/src/Components/DataDisplay/Tab/TabBodyContent.tsx +15 -0
  65. package/src/Components/DataDisplay/Tab/TabBodyContentProps.tsx +9 -0
  66. package/src/Components/DataDisplay/Tab/TabBodyProps.tsx +8 -0
  67. package/src/Components/DataDisplay/Tab/TabContext.tsx +9 -0
  68. package/src/Components/DataDisplay/Tab/TabContextProps.tsx +6 -0
  69. package/src/Components/DataDisplay/Tab/TabNav.tsx +6 -0
  70. package/src/Components/DataDisplay/Tab/TabNavItem.tsx +49 -0
  71. package/src/Components/DataDisplay/Tab/TabNavItemProps.tsx +9 -0
  72. package/src/Components/DataDisplay/Tab/TabNavProps.tsx +8 -0
  73. package/src/Components/DataDisplay/Tab/TabProps.tsx +8 -0
  74. package/src/Components/DataDisplay/Tab/tab.module.scss +35 -0
  75. package/src/Components/DataDisplay/Tab/tab.stories.scss +3 -0
  76. package/src/Components/DataDisplay/Table/Table.stories.tsx +64 -0
  77. package/src/Components/DataDisplay/Table/Table.tsx +10 -0
  78. package/src/Components/DataDisplay/Table/TableBody.tsx +13 -0
  79. package/src/Components/DataDisplay/Table/TableBodyProps.tsx +8 -0
  80. package/src/Components/DataDisplay/Table/TableCell.tsx +30 -0
  81. package/src/Components/DataDisplay/Table/TableCellAction.tsx +27 -0
  82. package/src/Components/DataDisplay/Table/TableCellActionProps.tsx +11 -0
  83. package/src/Components/DataDisplay/Table/TableCellProps.tsx +11 -0
  84. package/src/Components/DataDisplay/Table/TableCellWithDesc.tsx +21 -0
  85. package/src/Components/DataDisplay/Table/TableCellWithDescProps.tsx +9 -0
  86. package/src/Components/DataDisplay/Table/TableCellWithImage.tsx +39 -0
  87. package/src/Components/DataDisplay/Table/TableCellWithImageProps.tsx +10 -0
  88. package/src/Components/DataDisplay/Table/TableFooter.tsx +5 -0
  89. package/src/Components/DataDisplay/Table/TableHead.tsx +11 -0
  90. package/src/Components/DataDisplay/Table/TableHeadProps.tsx +8 -0
  91. package/src/Components/DataDisplay/Table/TableHeaderCell.tsx +17 -0
  92. package/src/Components/DataDisplay/Table/TableHeaderCellProps.tsx +10 -0
  93. package/src/Components/DataDisplay/Table/TableProps.tsx +8 -0
  94. package/src/Components/DataDisplay/Table/TableRow.tsx +9 -0
  95. package/src/Components/DataDisplay/Table/TableRowProps.tsx +8 -0
  96. package/src/Components/DataDisplay/Table/table.module.scss +103 -0
  97. package/src/Components/Form/Button/Button.stories.tsx +66 -0
  98. package/src/Components/Form/Button/Button.tsx +64 -0
  99. package/src/Components/Form/Button/ButtonProps.tsx +18 -0
  100. package/src/Components/Form/Button/button.module.scss +142 -0
  101. package/src/Components/Form/Checkbox/Checkbox.stories.tsx +49 -0
  102. package/src/Components/Form/Checkbox/Checkbox.tsx +85 -0
  103. package/src/Components/Form/Checkbox/CheckboxProps.tsx +22 -0
  104. package/src/Components/Form/Checkbox/checkbox.module.scss +63 -0
  105. package/src/Components/Form/CheckboxSelect/CheckboxSelect.tsx +5 -0
  106. package/src/Components/Form/CheckboxSelect/CheckboxSelectItem.tsx +5 -0
  107. package/src/Components/Form/CheckboxSet/CheckboxSet.stories.tsx +93 -0
  108. package/src/Components/Form/CheckboxSet/CheckboxSet.tsx +14 -0
  109. package/src/Components/Form/CheckboxSet/CheckboxSetItem.tsx +88 -0
  110. package/src/Components/Form/CheckboxSet/CheckboxSetProps.tsx +9 -0
  111. package/src/Components/Form/CheckboxSet/checkboxSet.module.scss +13 -0
  112. package/src/Components/Form/CurrencyField/CurrenctField.stories.tsx +22 -0
  113. package/src/Components/Form/CurrencyField/CurrencyField.tsx +59 -0
  114. package/src/Components/Form/CurrencyField/CurrencyFieldProps.tsx +8 -0
  115. package/src/Components/Form/DateField/DateField.stories.tsx +22 -0
  116. package/src/Components/Form/DateField/DateField.tsx +58 -0
  117. package/src/Components/Form/DropdownBadge/DropdownBadge.stories.tsx +49 -0
  118. package/src/Components/Form/DropdownBadge/DropdownBadge.tsx +160 -0
  119. package/src/Components/Form/DropdownBadge/DropdownBadgeItem.tsx +40 -0
  120. package/src/Components/Form/DropdownBadge/DropdownBadgeItemProps.tsx +10 -0
  121. package/src/Components/Form/DropdownBadge/DropdownBadgeProps.tsx +31 -0
  122. package/src/Components/Form/DropdownBadge/DropdownBadgeSelector.tsx +11 -0
  123. package/src/Components/Form/DropdownBadge/DropdownBadgeSelectorProps.tsx +7 -0
  124. package/src/Components/Form/DropdownBadge/dropdownBadge.module.scss +105 -0
  125. package/src/Components/Form/DropdownField/DropdownField.stories.tsx +50 -0
  126. package/src/Components/Form/DropdownField/DropdownField.tsx +118 -0
  127. package/src/Components/Form/DropdownField/DropdownFieldItem.tsx +26 -0
  128. package/src/Components/Form/DropdownField/DropdownFieldItemProps.tsx +9 -0
  129. package/src/Components/Form/DropdownField/DropdownFieldProps.tsx +33 -0
  130. package/src/Components/Form/DropdownField/DropdownFieldSelector.tsx +15 -0
  131. package/src/Components/Form/DropdownField/DropdownFieldSelectorProps.tsx +7 -0
  132. package/src/Components/Form/DropdownField/dropdown.module.scss +79 -0
  133. package/src/Components/Form/EmailField/EmailField.stories.ts +23 -0
  134. package/src/Components/Form/EmailField/EmailField.tsx +51 -0
  135. package/src/Components/Form/ErrorMessage/ErrorMessage.tsx +5 -0
  136. package/src/Components/Form/FormFieldHolder/FormFieldHolder.tsx +5 -0
  137. package/src/Components/Form/IconButton/IconButton.stories.tsx +45 -0
  138. package/src/Components/Form/IconButton/IconButton.tsx +58 -0
  139. package/src/Components/Form/IconButton/IconButtonProps.tsx +15 -0
  140. package/src/Components/Form/IconButton/iconButton.module.scss +111 -0
  141. package/src/Components/Form/InputProps.tsx +25 -0
  142. package/src/Components/Form/MultiSelectField/MultiSelectField.tsx +5 -0
  143. package/src/Components/Form/MultiSelectField/MultiSelectFieldItem.tsx +5 -0
  144. package/src/Components/Form/MultiSelectField/MultiSelectFieldTag.tsx +5 -0
  145. package/src/Components/Form/PasswordField/PasswordField.stories.tsx +22 -0
  146. package/src/Components/Form/PasswordField/PasswordField.tsx +70 -0
  147. package/src/Components/Form/RadioButtons/RadioButton.tsx +70 -0
  148. package/src/Components/Form/RadioButtons/RadioButtonProps.tsx +22 -0
  149. package/src/Components/Form/RadioButtons/RadioButtons.stories.tsx +64 -0
  150. package/src/Components/Form/RadioButtons/RadioButtons.tsx +18 -0
  151. package/src/Components/Form/RadioButtons/RadioButtonsProps.tsx +10 -0
  152. package/src/Components/Form/RadioButtons/radioButton.stories.scss +3 -0
  153. package/src/Components/Form/RadioButtons/radiobutton.module.scss +63 -0
  154. package/src/Components/Form/TextField/TextField.stories.ts +23 -0
  155. package/src/Components/Form/TextField/TextField.tsx +52 -0
  156. package/src/Components/Form/Textarea/Textarea.stories.ts +31 -0
  157. package/src/Components/Form/Textarea/Textarea.tsx +71 -0
  158. package/src/Components/Form/Textarea/TextareaProps.tsx +27 -0
  159. package/src/Components/Form/Textarea/textarea.module.scss +49 -0
  160. package/src/Components/Form/TimeField/TimeField.stories.tsx +22 -0
  161. package/src/Components/Form/TimeField/TimeField.tsx +58 -0
  162. package/src/Components/Form/ToggleSwitch/ToggleSwitch.stories.tsx +49 -0
  163. package/src/Components/Form/ToggleSwitch/ToggleSwitch.tsx +87 -0
  164. package/src/Components/Form/ToggleSwitch/ToggleSwitchProps.tsx +22 -0
  165. package/src/Components/Form/ToggleSwitch/toggleSwitch.module.scss +82 -0
  166. package/src/Components/Form/inputs.module.scss +121 -0
  167. package/src/Components/Icons/Arrows/CaretDown/CaretDown.tsx +49 -0
  168. package/src/Components/Icons/Arrows/CaretUp/CaretUp.tsx +49 -0
  169. package/src/Components/Icons/Commerce/CurrencyDollarSimple/CurrencyDollarSimple.tsx +105 -0
  170. package/src/Components/Icons/Communication/AddressBook/AddressBook.stories.ts +28 -0
  171. package/src/Components/Icons/Communication/AddressBook/AddressBook.tsx +50 -0
  172. package/src/Components/Icons/Communication/Asterick/Asterisk.stories.ts +28 -0
  173. package/src/Components/Icons/Communication/Asterick/Asterisk.tsx +50 -0
  174. package/src/Components/Icons/Communication/AsterickSimple/AsteriskSimple.stories.ts +28 -0
  175. package/src/Components/Icons/Communication/AsterickSimple/AsteriskSimple.tsx +49 -0
  176. package/src/Components/Icons/Communication/At/At.stories.ts +28 -0
  177. package/src/Components/Icons/Communication/At/At.tsx +49 -0
  178. package/src/Components/Icons/Communication/Broadcast/Broadcast.stories.ts +27 -0
  179. package/src/Components/Icons/Communication/Broadcast/Broadcast.tsx +49 -0
  180. package/src/Components/Icons/Communication/Chat/Chat.stories.ts +28 -0
  181. package/src/Components/Icons/Communication/Chat/Chat.tsx +49 -0
  182. package/src/Components/Icons/Design/Eye/Eye.tsx +105 -0
  183. package/src/Components/Icons/Design/EyeSlash/EyeSlash.tsx +105 -0
  184. package/src/Components/Icons/IconProps.tsx +5 -0
  185. package/src/Components/Icons/MathAndFinance/XIcon/XIcon.tsx +107 -0
  186. package/src/Components/Icons/SystemAndDevice/Bell/Bell.tsx +49 -0
  187. package/src/Components/Icons/Time/CalendarBank/CalendarBank.tsx +105 -0
  188. package/src/Components/Icons/Time/Clock/Clock.tsx +105 -0
  189. package/src/Components/Layout/CalloutPopup/CalloutPopup.tsx +5 -0
  190. package/src/Components/Layout/Header/Header.tsx +5 -0
  191. package/src/Components/Layout/Header/HeaderLeft.tsx +5 -0
  192. package/src/Components/Layout/Header/HeaderRight.tsx +5 -0
  193. package/src/Components/Layout/Pagination/Pagination.tsx +5 -0
  194. package/src/Components/Layout/Pagination/PaginationFirst.tsx +5 -0
  195. package/src/Components/Layout/Pagination/PaginationLast.tsx +5 -0
  196. package/src/Components/Layout/Pagination/PaginationNext.tsx +5 -0
  197. package/src/Components/Layout/Pagination/PaginationNumber.tsx +5 -0
  198. package/src/Components/Layout/Pagination/PaginationPrevious.tsx +5 -0
  199. package/src/Components/Layout/ProfileAvatar/ProfileAvatar.tsx +5 -0
  200. package/src/Components/Layout/ProfileAvatar/ProfileAvatarProps.tsx +4 -0
  201. package/src/Components/Layout/ProfileDropdown/ProfileDropdown.tsx +5 -0
  202. package/src/Components/Layout/ProfileDropdown/ProfileHeader.tsx +5 -0
  203. package/src/Components/Layout/ProfileDropdown/ProfileLink.tsx +5 -0
  204. package/src/Components/Layout/ProfileDropdown/ProfileLinks.tsx +5 -0
  205. package/src/Components/Layout/ProfileDropdown/ProfileNavigationItem.tsx +5 -0
  206. package/src/Components/Layout/ProfileDropdown/ProfileSwitchPanel.tsx +5 -0
  207. package/src/Components/Layout/ProfileDropdown/ProfileSwitchUser.tsx +5 -0
  208. package/src/Components/Layout/Sidebar/Sidebar.tsx +5 -0
  209. package/src/Components/Layout/Sidebar/SidebarChevron.tsx +5 -0
  210. package/src/Components/Layout/Sidebar/SidebarNavigation.tsx +5 -0
  211. package/src/Components/Layout/Sidebar/SidebarNavigationItem.tsx +5 -0
  212. package/src/Components/Layout/Sidebar/SidebarSubNavigation.tsx +5 -0
  213. package/src/Notification/Notification.tsx +83 -0
  214. package/src/Notification/NotificationInterface.tsx +9 -0
  215. package/src/Notification/NotificationList.tsx +29 -0
  216. package/src/Notification/NotificationListHolder.tsx +14 -0
  217. package/src/Notification/NotificationListHolderInterface.tsx +8 -0
  218. package/src/Notification/NotificationListInterface.tsx +11 -0
  219. package/src/Notification/notification.scss +225 -0
  220. package/src/global.scss +231 -0
  221. package/src/main.tsx +9 -0
  222. package/src/variables.scss +2 -0
  223. package/src/vite-env.d.ts +1 -0
  224. package/tokens/color/color.mdx +82 -0
  225. package/tokens/shadow/shadow-panel.scss +12 -0
  226. package/tokens/shadow/shadow.mdx +34 -0
  227. package/tokens/typography/typography.mdx +31 -0
  228. package/tsconfig.json +25 -0
  229. package/tsconfig.node.json +10 -0
  230. package/vite.config.ts +7 -0
@@ -0,0 +1,142 @@
1
+ @import "../../../variables";
2
+
3
+ .button {
4
+ display: inline-flex;
5
+ align-items: center;
6
+ justify-content: center;
7
+ border-width: 1px;
8
+ border-style: solid;
9
+ border-radius: 4px;
10
+ font-size: var(--font-size-button);
11
+ font-weight: var(--font-weight-button);
12
+ line-height: var(--line-height-button);
13
+ cursor: pointer;
14
+ transition: linear all 300ms;
15
+ font-family: var(--font);
16
+
17
+ svg {
18
+ width: 20px;
19
+ height: 20px;
20
+ }
21
+
22
+ &:disabled {
23
+ cursor: not-allowed;
24
+ }
25
+
26
+ &.disabled {
27
+ opacity: 0.3;
28
+ cursor: not-allowed;
29
+ }
30
+
31
+ .primaryIcon,
32
+ .secondaryIcon {
33
+ width: 20px;
34
+ height: 20px;
35
+ }
36
+
37
+ .primaryIcon {
38
+ margin-right: calc(var(--space-unit) * 2);
39
+ }
40
+
41
+ .secondaryIcon {
42
+ margin-left: calc(var(--space-unit) * 2);
43
+ }
44
+
45
+ &.solid {
46
+ }
47
+
48
+ &.hollow {
49
+ }
50
+
51
+ &.noBorder {
52
+ border-color: transparent;
53
+ text-decoration-line: underline;
54
+ --font-weight-button: 400;
55
+ }
56
+
57
+ &.default {
58
+ padding: var(--spacing-1\/2) var(--spacing-1-1\/4);
59
+ min-height: 40px;
60
+
61
+ &.noBorder {
62
+ padding: var(--spacing-1\/2) var(--spacing-3\/4);
63
+ }
64
+ }
65
+
66
+ &.large {
67
+ padding: var(--spacing-1\/2) var(--spacing-2);
68
+ min-height: 48px;
69
+
70
+ &.noBorder {
71
+ padding: var(--spacing-1\/2) var(--spacing-1);
72
+ }
73
+ }
74
+
75
+ &.small {
76
+ padding: var(--spacing-1\/4) var(--spacing-3\/4);
77
+ min-height: 32px;
78
+
79
+ &.noBorder {
80
+ padding: var(--spacing-1\/2) var(--spacing-1\/2);
81
+ }
82
+ }
83
+
84
+ @each $color in $colors {
85
+ &.solid-#{$color} {
86
+ color: var(--color-lite);
87
+ background-color: var(--color-#{$color}-500);
88
+ border-color: var(--color-#{$color}-500);
89
+
90
+ &:hover:enabled {
91
+ background-color: var(--color-#{$color}-300);
92
+ border-color: var(--color-#{$color}-300);
93
+ }
94
+
95
+ &:active:enabled {
96
+ background-color: var(--color-#{$color}-600);
97
+ border-color: var(--color-#{$color}-600);
98
+ }
99
+ }
100
+ }
101
+
102
+ @each $color in $colors {
103
+ &.hollow-#{$color} {
104
+ background: transparent;
105
+ color: var(--color-#{$color}-800);
106
+ border-color: var(--color-#{$color}-600);
107
+
108
+ &:hover:enabled {
109
+ background: var(--color-#{$color}-100);
110
+ }
111
+
112
+ &:active:enabled {
113
+ background: var(--color-#{$color}-100);
114
+ border-width: 2px;
115
+ }
116
+ }
117
+ }
118
+
119
+ @each $color in $colors {
120
+ &.no-border-#{$color} {
121
+ background: transparent;
122
+ color: var(--color-#{$color}-800);
123
+ border-color: transparent;
124
+
125
+ &:hover:enabled {
126
+ background-color: var(--color-#{$color}-100);
127
+ color: var(--color-#{$color}-800);
128
+ }
129
+
130
+ &:active:enabled {
131
+ background-color: var(--color-#{$color}-100);
132
+ color: var(--color-#{$color}-800);
133
+ }
134
+ }
135
+ }
136
+
137
+ .button-icon {
138
+ display: flex;
139
+ align-items: center;
140
+ margin-right: calc(var(--spacing) * 2);
141
+ }
142
+ }
@@ -0,0 +1,49 @@
1
+ import type { Meta, StoryObj } from '@storybook/react';
2
+ import Checkbox from "./Checkbox";
3
+
4
+ // More on how to set up stories at: https://storybook.js.org/docs/writing-stories#default-export
5
+ const meta = {
6
+ title: 'Form / Checkbox',
7
+ component: Checkbox,
8
+ parameters: {
9
+ layout: 'centered',
10
+ },
11
+ tags: ['autodocs'],
12
+ } satisfies Meta<typeof Checkbox>;
13
+
14
+ export default meta;
15
+ type Story = StoryObj<typeof Checkbox>;
16
+
17
+ // More on writing stories with args: https://storybook.js.org/docs/writing-stories/args
18
+ export const Default: Story = {
19
+ args: {
20
+ checked: false
21
+ },
22
+ };
23
+
24
+ export const Checked: Story = {
25
+ args: {
26
+ checked: true
27
+ },
28
+ };
29
+
30
+ export const Disabled: Story = {
31
+ args: {
32
+ checked: true,
33
+ disabled: true
34
+ },
35
+ };
36
+
37
+ export const CheckedDisabled: Story = {
38
+ args: {
39
+ checked: true,
40
+ disabled: true
41
+ },
42
+ };
43
+
44
+ export const Error: Story = {
45
+ args: {
46
+ checked: true,
47
+ error: true
48
+ },
49
+ };
@@ -0,0 +1,85 @@
1
+ import cx from "classnames";
2
+ import CheckboxProps from "./CheckboxProps";
3
+ import styles from "./checkbox.module.scss";
4
+ import { useEffect, useState, MouseEvent } from "react";
5
+
6
+ const Checkbox = (props: CheckboxProps) => {
7
+ const {
8
+ name,
9
+ checked,
10
+ id,
11
+ value,
12
+ placeholder,
13
+ extraClass,
14
+ disabled,
15
+ error,
16
+ ariaLabel,
17
+ required,
18
+ readonly,
19
+ onChange,
20
+ ...args
21
+ } = props;
22
+
23
+ const [isChecked, setIsChecked] = useState(false);
24
+
25
+ const classes = ["checkbox", styles.checkbox];
26
+
27
+ if (extraClass) {
28
+ classes.push(extraClass);
29
+ }
30
+ if (error) {
31
+ classes.push(styles.error);
32
+ }
33
+
34
+ useEffect(() => {
35
+ setIsChecked(checked ? checked : false);
36
+ }, [checked]);
37
+
38
+ const handleClick = (e: MouseEvent) => {
39
+ setIsChecked(!isChecked);
40
+ if (onChange) {
41
+ onChange(e, isChecked);
42
+ }
43
+ };
44
+
45
+ return (
46
+ <div className={cx(classes)}>
47
+ <input
48
+ id={id}
49
+ name={name}
50
+ checked={isChecked}
51
+ type={"checkbox"}
52
+ value={value}
53
+ placeholder={placeholder}
54
+ disabled={disabled}
55
+ readOnly={readonly}
56
+ required={required}
57
+ aria-label={ariaLabel ? ariaLabel : name}
58
+ aria-required={required ? "true" : "false"}
59
+ aria-invalid={error ? "true" : "false"}
60
+ aria-disabled={disabled ? "true" : "false"}
61
+ aria-readonly={readonly ? "true" : "false"}
62
+ onClick={handleClick}
63
+ {...args}
64
+ />
65
+ {!!isChecked && (
66
+ <svg
67
+ width="11"
68
+ height="10"
69
+ viewBox="0 0 11 10"
70
+ fill="none"
71
+ xmlns="http://www.w3.org/2000/svg"
72
+ >
73
+ <path
74
+ d="M10.8425 2.10473C11.0378 2.29999 11.0378 2.61658 10.8425 2.81184L4.47856 9.1758C4.2833 9.37106 3.96672 9.37106 3.77146 9.1758L0.353775 5.75812C0.158513 5.56286 0.158513 5.24627 0.353775 5.05101L1.41443 3.99035C1.6097 3.79509 1.92628 3.79509 2.12154 3.99035L4.12501 5.99382L9.07476 1.04407C9.27002 0.84881 9.5866 0.84881 9.78187 1.04407L10.8425 2.10473Z"
75
+ fillRule="evenodd"
76
+ clipRule="evenodd"
77
+ fill="currentColor"
78
+ />
79
+ </svg>
80
+ )}
81
+ </div>
82
+ );
83
+ };
84
+
85
+ export default Checkbox;
@@ -0,0 +1,22 @@
1
+ import {FocusEvent, MouseEvent} from "react";
2
+
3
+ interface CheckboxProps {
4
+ name?: string;
5
+ id?: string;
6
+ value?: string;
7
+ extraClass?: string;
8
+ placeholder?: string;
9
+ error?: boolean;
10
+ disabled?:boolean;
11
+ readonly?: boolean;
12
+ checked?: boolean;
13
+ required?: boolean;
14
+ ariaLabel?: string;
15
+ ariaLabeledby?: string;
16
+ ariaDescribedby?: string;
17
+ onChange?: (e: MouseEvent, checked?: boolean) => void;
18
+ onFocus?: (e: FocusEvent) => void;
19
+ onBlur?: (e: FocusEvent) => void;
20
+ }
21
+
22
+ export default CheckboxProps;
@@ -0,0 +1,63 @@
1
+ .checkbox {
2
+ position: relative;
3
+ display: inline-flex;
4
+ justify-content: center;
5
+ flex-shrink: 0;
6
+ flex-grow: 0;
7
+
8
+ input[type="checkbox"] {
9
+ -webkit-appearance: none;
10
+ width: 20px;
11
+ height: 20px;
12
+ border-radius: 4px;
13
+ background-color: var(--color-white);
14
+ border: 1px solid var(--color-gray-300);
15
+ outline: 2px solid transparent;
16
+ outline-offset: 2px;
17
+ cursor: pointer;
18
+
19
+ &:checked {
20
+ background-color: var(--color-gray-800);
21
+ border-color: var(--color-gray-800);
22
+ }
23
+
24
+ &:hover {
25
+ border-color: var(--color-gray-600);
26
+ }
27
+
28
+ &:focus {
29
+ outline: 2px solid var(--color-gray-800);
30
+ }
31
+
32
+ &:disabled {
33
+ background-color: var(--color-gray-200);
34
+
35
+ &:checked {
36
+ border-color: var(--color-gray-200);
37
+ }
38
+ }
39
+ }
40
+
41
+ svg {
42
+ position: absolute;
43
+ top: 50%;
44
+ left: 50%;
45
+ transform: translate(-50%, -50%);
46
+ pointer-events: none;
47
+ }
48
+
49
+ input[type="checkbox"] ~ svg {
50
+ color: var(--color-white);
51
+ }
52
+
53
+ &.error {
54
+ input[type="checkbox"] {
55
+ border-color: var(--color-error);
56
+ color: var(--color-white);
57
+
58
+ &:checked {
59
+ background-color: var(--color-error);
60
+ }
61
+ }
62
+ }
63
+ }
@@ -0,0 +1,5 @@
1
+ const CheckboxSelect = () => {
2
+
3
+ }
4
+
5
+ export default CheckboxSelect;
@@ -0,0 +1,5 @@
1
+ const CheckboxSelectItem = () => {
2
+
3
+ }
4
+
5
+ export default CheckboxSelectItem;
@@ -0,0 +1,93 @@
1
+ import type { Meta, StoryObj } from "@storybook/react";
2
+ import CheckboxSet from "./CheckboxSet";
3
+ import CheckboxSetItem from "./CheckboxSetItem";
4
+
5
+ const meta: Meta = {
6
+ title: "Form / CheckboxSet",
7
+ component: CheckboxSet,
8
+ parameters: {
9
+ layout: "centered",
10
+ },
11
+ tags: ["autodocs"],
12
+ };
13
+
14
+ export default meta;
15
+
16
+ type Story = StoryObj<typeof meta>;
17
+
18
+ const CheckboxSetTemplate: Story = {
19
+ render: ({ items, ...args }) => {
20
+ return (
21
+ <CheckboxSet {...args}>
22
+ {items.map((item: any) => (
23
+ <CheckboxSetItem name={item.name} id={item.id} />
24
+ ))}
25
+ </CheckboxSet>
26
+ );
27
+ },
28
+ };
29
+
30
+ export const Default = {
31
+ ...CheckboxSetTemplate,
32
+ args: {
33
+ items: [
34
+ {
35
+ id: "c-1",
36
+ name: "check-one",
37
+ },
38
+ {
39
+ id: "c-1",
40
+ name: "check-one",
41
+ },
42
+ {
43
+ id: "c-1",
44
+ name: "check-one",
45
+ },
46
+ {
47
+ id: "c-1",
48
+ name: "check-one",
49
+ },
50
+ {
51
+ id: "c-1",
52
+ name: "check-one",
53
+ },
54
+ {
55
+ id: "c-1",
56
+ name: "check-one",
57
+ },
58
+ ],
59
+ },
60
+ };
61
+
62
+ export const Horizontal = {
63
+ ...CheckboxSetTemplate,
64
+ args: {
65
+ columns: true,
66
+ items: [
67
+ {
68
+ id: "c-1",
69
+ name: "check-one",
70
+ },
71
+ {
72
+ id: "c-1",
73
+ name: "check-one",
74
+ },
75
+ {
76
+ id: "c-1",
77
+ name: "check-one",
78
+ },
79
+ {
80
+ id: "c-1",
81
+ name: "check-one",
82
+ },
83
+ {
84
+ id: "c-1",
85
+ name: "check-one",
86
+ },
87
+ {
88
+ id: "c-1",
89
+ name: "check-one",
90
+ },
91
+ ],
92
+ },
93
+ };
@@ -0,0 +1,14 @@
1
+ import CheckboxSetProps from "./CheckboxSetProps";
2
+ import styles from "./checkboxSet.module.scss";
3
+
4
+ const CheckboxSet = (props: CheckboxSetProps) => {
5
+ const { children, error, columns } = props;
6
+
7
+ return (
8
+ <div className={`${styles.checkboxSet} ${columns ? styles.container : ""}`}>
9
+ {children}
10
+ </div>
11
+ );
12
+ };
13
+
14
+ export default CheckboxSet;
@@ -0,0 +1,88 @@
1
+ import cx from "classnames";
2
+ import CheckboxProps from "../Checkbox/CheckboxProps";
3
+ import styles from "../Checkbox/checkbox.module.scss";
4
+ import checkboxSetStyle from "./checkboxSet.module.scss";
5
+ import { useEffect, useState, MouseEvent } from "react";
6
+
7
+ const CheckboxSetItem = (props: CheckboxProps) => {
8
+ const {
9
+ name,
10
+ checked,
11
+ id,
12
+ value,
13
+ placeholder,
14
+ extraClass,
15
+ disabled,
16
+ error,
17
+ ariaLabel,
18
+ required,
19
+ readonly,
20
+ onChange,
21
+ ...args
22
+ } = props;
23
+
24
+ const [isChecked, setIsChecked] = useState(false);
25
+
26
+ const classes = ["checkbox", styles.checkbox];
27
+
28
+ if (extraClass) {
29
+ classes.push(extraClass);
30
+ }
31
+ if (error) {
32
+ classes.push(styles.error);
33
+ }
34
+
35
+ useEffect(() => {
36
+ setIsChecked(checked ? checked : false);
37
+ }, [checked]);
38
+
39
+ const handleClick = (e: MouseEvent) => {
40
+ setIsChecked(!isChecked);
41
+ if (onChange) {
42
+ onChange(e, isChecked);
43
+ }
44
+ };
45
+
46
+ return (
47
+ <div className={checkboxSetStyle.checkboxSetItemCon}>
48
+ <div className={cx(classes)}>
49
+ <input
50
+ id={id}
51
+ name={name}
52
+ checked={isChecked}
53
+ type={"checkbox"}
54
+ value={value}
55
+ placeholder={placeholder}
56
+ disabled={disabled}
57
+ readOnly={readonly}
58
+ required={required}
59
+ aria-label={ariaLabel ? ariaLabel : name}
60
+ aria-required={required ? "true" : "false"}
61
+ aria-invalid={error ? "true" : "false"}
62
+ aria-disabled={disabled ? "true" : "false"}
63
+ aria-readonly={readonly ? "true" : "false"}
64
+ onClick={handleClick}
65
+ {...args}
66
+ />
67
+ {!!isChecked && (
68
+ <svg
69
+ width="11"
70
+ height="10"
71
+ viewBox="0 0 11 10"
72
+ fill="none"
73
+ xmlns="http://www.w3.org/2000/svg"
74
+ >
75
+ <path
76
+ d="M10.8425 2.10473C11.0378 2.29999 11.0378 2.61658 10.8425 2.81184L4.47856 9.1758C4.2833 9.37106 3.96672 9.37106 3.77146 9.1758L0.353775 5.75812C0.158513 5.56286 0.158513 5.24627 0.353775 5.05101L1.41443 3.99035C1.6097 3.79509 1.92628 3.79509 2.12154 3.99035L4.12501 5.99382L9.07476 1.04407C9.27002 0.84881 9.5866 0.84881 9.78187 1.04407L10.8425 2.10473Z"
77
+ fillRule="evenodd"
78
+ clipRule="evenodd"
79
+ fill="currentColor"
80
+ />
81
+ </svg>
82
+ )}
83
+ </div>
84
+ </div>
85
+ );
86
+ };
87
+
88
+ export default CheckboxSetItem;
@@ -0,0 +1,9 @@
1
+ import { ReactNode } from "react";
2
+
3
+ interface CheckboxSetProps {
4
+ children: ReactNode;
5
+ error?: boolean;
6
+ columns?: boolean;
7
+ }
8
+
9
+ export default CheckboxSetProps;
@@ -0,0 +1,13 @@
1
+ .checkboxSet {
2
+ display: flex;
3
+ margin: calc(-1 * var(--space-unit));
4
+
5
+ &.container {
6
+ flex-direction: column;
7
+ }
8
+ }
9
+
10
+ .checkboxSetItemCon {
11
+ flex-shrink: 0;
12
+ padding: calc(1 * var(--space-unit));
13
+ }
@@ -0,0 +1,22 @@
1
+ import type { Meta, StoryObj } from "@storybook/react";
2
+
3
+ import CurrencyField from "./CurrencyField";
4
+
5
+ // More on how to set up stories at: https://storybook.js.org/docs/writing-stories#default-export
6
+ const meta = {
7
+ title: "Form / CurrencyField",
8
+ component: CurrencyField,
9
+ parameters: {
10
+ layout: "centered",
11
+ },
12
+ tags: ["autodocs"],
13
+ } satisfies Meta<typeof CurrencyField>;
14
+
15
+ export default meta;
16
+ type Story = StoryObj<typeof CurrencyField>;
17
+
18
+ export const Example: Story = {
19
+ args: {
20
+ placeholder: "0.00",
21
+ },
22
+ };
@@ -0,0 +1,59 @@
1
+ import cx from "classnames";
2
+ import styles from "../inputs.module.scss";
3
+ import CurrencyFieldProps from "./CurrencyFieldProps";
4
+ import CurrencyDollarSimple from "../../Icons/Commerce/CurrencyDollarSimple/CurrencyDollarSimple";
5
+
6
+ const CurrencyField = (props: CurrencyFieldProps) => {
7
+ const {
8
+ name,
9
+ id,
10
+ value,
11
+ placeholder,
12
+ extraClass,
13
+ disabled,
14
+ error,
15
+ ariaLabel,
16
+ required,
17
+ readonly,
18
+ autoComplete,
19
+ currencyIcon,
20
+ ...args
21
+ } = props;
22
+
23
+ const classes = [styles.input];
24
+ if (error) {
25
+ classes.push(styles.error);
26
+ }
27
+ if (extraClass) {
28
+ classes.push(extraClass);
29
+ }
30
+
31
+ return (
32
+ <div className={styles.currency}>
33
+ <input
34
+ className={cx(classes)}
35
+ id={id}
36
+ name={name}
37
+ type="number"
38
+ value={value}
39
+ placeholder={placeholder}
40
+ disabled={disabled}
41
+ readOnly={readonly}
42
+ required={required}
43
+ autoComplete={autoComplete ? "on" : "off"}
44
+ aria-label={ariaLabel ? ariaLabel : name}
45
+ aria-required={required ? "true" : "false"}
46
+ aria-invalid={error ? "true" : "false"}
47
+ aria-disabled={disabled ? "true" : "false"}
48
+ aria-readonly={readonly ? "true" : "false"}
49
+ aria-autocomplete={autoComplete ? "list" : "none"}
50
+ {...args}
51
+ />
52
+ <div className={styles.currencyIcon}>
53
+ {currencyIcon ? currencyIcon : <CurrencyDollarSimple />}
54
+ </div>
55
+ </div>
56
+ );
57
+ };
58
+
59
+ export default CurrencyField;
@@ -0,0 +1,8 @@
1
+ import { ReactNode } from "react";
2
+ import InputProps from "../InputProps";
3
+
4
+ interface CurrencyFieldProps extends InputProps {
5
+ currencyIcon?: ReactNode;
6
+ }
7
+
8
+ export default CurrencyFieldProps;