@thecb/components 10.12.1 → 10.12.3-beta.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 (215) hide show
  1. package/README.md +4 -0
  2. package/dist/index.cjs.js +1413 -2314
  3. package/dist/index.cjs.js.map +1 -1
  4. package/dist/index.d.ts +6 -4
  5. package/dist/index.esm.js +1413 -2315
  6. package/dist/index.esm.js.map +1 -1
  7. package/package.json +25 -13
  8. package/src/components/atoms/.DS_Store +0 -0
  9. package/src/components/atoms/alert/Alert.mdx +19 -0
  10. package/src/components/atoms/alert/Alert.stories.js +148 -26
  11. package/src/components/atoms/badge/Badge.js +2 -2
  12. package/src/components/atoms/badge/Badge.mdx +27 -0
  13. package/src/components/atoms/badge/Badge.stories.js +143 -29
  14. package/src/components/atoms/breadcrumb/Breadcrumb.mdx +21 -0
  15. package/src/components/atoms/breadcrumb/Breadcrumb.stories.js +38 -29
  16. package/src/components/atoms/button-with-action/ButtonWithAction.stories.js +108 -55
  17. package/src/components/atoms/button-with-link/ButtonWithLink.mdx +21 -0
  18. package/src/components/atoms/button-with-link/ButtonWithLink.stories.js +160 -31
  19. package/src/components/atoms/card/Card.js +13 -1
  20. package/src/components/atoms/card/Card.mdx +41 -0
  21. package/src/components/atoms/card/Card.stories.js +360 -0
  22. package/src/components/atoms/card/Card.theme.js +2 -0
  23. package/src/components/atoms/card/index.d.ts +1 -0
  24. package/src/components/atoms/checkbox/Checkbox.mdx +15 -0
  25. package/src/components/atoms/checkbox/Checkbox.oldstories.js +30 -0
  26. package/src/components/atoms/checkbox/Checkbox.stories.js +148 -29
  27. package/src/components/atoms/country-dropdown/CountryDropdown.mdx +36 -0
  28. package/src/components/atoms/country-dropdown/CountryDropdown.stories.js +61 -27
  29. package/src/components/atoms/detail/Detail.js +0 -26
  30. package/src/components/atoms/detail/Detail.mdx +32 -0
  31. package/src/components/atoms/detail/Detail.stories.js +156 -0
  32. package/src/components/atoms/display-box/DisplayBox.mdx +11 -0
  33. package/src/components/atoms/display-box/DisplayBox.stories.js +65 -21
  34. package/src/components/atoms/display-card/DisplayCard.mdx +13 -0
  35. package/src/components/atoms/display-card/DisplayCard.stories.js +163 -22
  36. package/src/components/atoms/dropdown/Dropdown.mdx +65 -0
  37. package/src/components/atoms/dropdown/Dropdown.stories.js +91 -10
  38. package/src/components/atoms/form-layouts/FormInput.mdx +38 -0
  39. package/src/components/atoms/form-layouts/FormInput.stories.js +212 -26
  40. package/src/components/atoms/form-select/FormSelect.mdx +42 -0
  41. package/src/components/atoms/form-select/FormSelect.stories.js +55 -29
  42. package/src/components/atoms/formatted-address/FormattedAddress.mdx +13 -0
  43. package/src/components/atoms/formatted-address/FormattedAddress.stories.js +133 -27
  44. package/src/components/atoms/formatted-bank-account/FormattedBankAccount.mdx +17 -0
  45. package/src/components/atoms/formatted-bank-account/FormattedBankAccount.stories.js +57 -0
  46. package/src/components/atoms/formatted-credit-card/FormattedCreditCard.mdx +40 -0
  47. package/src/components/atoms/formatted-credit-card/FormattedCreditCard.stories.js +74 -0
  48. package/src/components/atoms/icons/Icons.mdx +40 -0
  49. package/src/components/atoms/icons/Icons.stories.js +325 -0
  50. package/src/components/atoms/labeled-amount/LabeledAmount.mdx +23 -0
  51. package/src/components/atoms/labeled-amount/LabeledAmount.stories.js +110 -34
  52. package/src/components/atoms/line-item/LineItem.mdx +28 -0
  53. package/src/components/atoms/line-item/LineItem.stories.js +89 -22
  54. package/src/components/atoms/link/Link.mdx +19 -0
  55. package/src/components/atoms/link/Link.stories.js +155 -49
  56. package/src/components/atoms/loading/Loading.mdx +13 -0
  57. package/src/components/atoms/loading/Loading.stories.js +22 -0
  58. package/src/components/atoms/loading-line/LoadingLine.js +14 -10
  59. package/src/components/atoms/loading-line/LoadingLine.mdx +15 -0
  60. package/src/components/atoms/loading-line/LoadingLine.stories.js +132 -28
  61. package/src/components/atoms/nav-footer/NavFooter.mdx +15 -0
  62. package/src/components/atoms/nav-footer/NavFooter.stories.js +235 -22
  63. package/src/components/atoms/nav-header/NavHeader.mdx +13 -0
  64. package/src/components/atoms/nav-header/NavHeader.stories.js +122 -21
  65. package/src/components/atoms/nav-tabs/NavTabs.mdx +30 -0
  66. package/src/components/atoms/nav-tabs/NavTabs.stories.js +49 -0
  67. package/src/components/atoms/password-requirements/PasswordRequirements.mdx +39 -0
  68. package/src/components/atoms/password-requirements/PasswordRequirements.stories.js +108 -44
  69. package/src/components/atoms/placeholder/Placeholder.mdx +19 -0
  70. package/src/components/atoms/placeholder/Placeholder.stories.js +164 -36
  71. package/src/components/atoms/searchable-select/SearchableSelect.mdx +44 -0
  72. package/src/components/atoms/searchable-select/SearchableSelect.stories.js +103 -28
  73. package/src/components/atoms/state-province-dropdown/StateProvinceDropdown.mdx +36 -0
  74. package/src/components/atoms/state-province-dropdown/StateProvinceDropdown.stories.js +65 -40
  75. package/src/components/atoms/table/Table.mdx +71 -0
  76. package/src/components/atoms/table/Table.oldstories.js +84 -0
  77. package/src/components/atoms/table/Table.stories.js +59 -75
  78. package/src/components/atoms/table/TableRow.js +1 -0
  79. package/src/components/atoms/title/Title.js +0 -23
  80. package/src/components/atoms/title/Title.mdx +26 -0
  81. package/src/components/atoms/title/Title.stories.js +144 -0
  82. package/src/components/atoms/toggle-switch/ToggleSwitch.mdx +17 -0
  83. package/src/components/atoms/toggle-switch/ToggleSwitch.stories.js +103 -20
  84. package/src/components/atoms/toggle-switch/ToggleSwitch.theme.js +8 -5
  85. package/src/components/atoms/typeahead-input/TypeaheadInput.mdx +13 -0
  86. package/src/components/atoms/typeahead-input/TypeaheadInput.stories.js +63 -0
  87. package/src/components/molecules/address-form/AddressForm.mdx +18 -0
  88. package/src/components/molecules/address-form/AddressForm.stories.js +223 -20
  89. package/src/components/molecules/banner/Banner.mdx +23 -0
  90. package/src/components/molecules/banner/Banner.stories.js +122 -26
  91. package/src/components/molecules/change-password-form/ChangePasswordForm.mdx +15 -0
  92. package/src/components/molecules/change-password-form/ChangePasswordForm.stories.js +203 -19
  93. package/src/components/molecules/collapsible-section/CollapsibleSection.mdx +15 -0
  94. package/src/components/molecules/collapsible-section/CollapsibleSection.stories.js +210 -61
  95. package/src/components/molecules/edit-name-form/EditNameForm.mdx +13 -0
  96. package/src/components/molecules/edit-name-form/EditNameForm.stories.js +117 -0
  97. package/src/components/molecules/idle-modal/IdleModal.js +101 -0
  98. package/src/components/molecules/idle-modal/IdleModal.mdx +17 -0
  99. package/src/components/molecules/idle-modal/IdleModal.stories.js +180 -0
  100. package/src/components/molecules/idle-modal/index.d.ts +16 -0
  101. package/src/components/molecules/idle-modal/index.js +3 -0
  102. package/src/components/molecules/index.js +1 -0
  103. package/src/components/molecules/link-card/LinkCard.mdx +17 -0
  104. package/src/components/molecules/link-card/LinkCard.stories.js +287 -72
  105. package/src/components/molecules/login-form/LoginForm.mdx +16 -0
  106. package/src/components/molecules/login-form/LoginForm.stories.js +117 -21
  107. package/src/components/molecules/modal/Modal.mdx +17 -0
  108. package/src/components/molecules/modal/Modal.stories.js +342 -128
  109. package/src/components/molecules/module/Module.mdx +17 -0
  110. package/src/components/molecules/module/Module.stories.js +267 -25
  111. package/src/components/molecules/multiple-select-filter/MultipleSelectFilter.js +295 -61
  112. package/src/components/molecules/multiple-select-filter/{MultipleSelectFilter.stories.js → MultipleSelectFilter.oldstories.js} +1 -1
  113. package/src/components/molecules/multiple-select-filter/MultipleSelectFilter.styled.js +4 -4
  114. package/src/components/molecules/obligation/Obligation.mdx +23 -0
  115. package/src/components/molecules/obligation/Obligation.stories.js +460 -0
  116. package/src/components/molecules/obligation/icons/PropertyPersonalIcon.js +1 -1
  117. package/src/components/molecules/pagination/Pagination.mdx +15 -0
  118. package/src/components/molecules/pagination/Pagination.stories.js +177 -28
  119. package/src/components/molecules/popover/Popover.mdx +15 -0
  120. package/src/components/molecules/popover/Popover.stories.js +220 -0
  121. package/src/components/molecules/tabs/Tabs.mdx +17 -0
  122. package/src/components/molecules/tabs/Tabs.stories.js +135 -227
  123. package/src/components/molecules/toast-notification/Toast.mdx +15 -0
  124. package/src/components/molecules/toast-notification/Toast.stories.js +183 -0
  125. package/src/hooks/use-outside-click/index.js +5 -4
  126. package/src/stories/Button.stories.ts +53 -0
  127. package/src/stories/Button.tsx +48 -0
  128. package/src/stories/Configure.mdx +364 -0
  129. package/src/stories/Header.stories.ts +33 -0
  130. package/src/stories/Header.tsx +56 -0
  131. package/src/stories/Page.stories.ts +32 -0
  132. package/src/stories/Page.tsx +73 -0
  133. package/src/stories/assets/accessibility.png +0 -0
  134. package/src/stories/assets/accessibility.svg +5 -0
  135. package/src/stories/assets/addon-library.png +0 -0
  136. package/src/stories/assets/assets.png +0 -0
  137. package/src/stories/assets/avif-test-image.avif +0 -0
  138. package/src/stories/assets/context.png +0 -0
  139. package/src/stories/assets/discord.svg +15 -0
  140. package/src/stories/assets/docs.png +0 -0
  141. package/src/stories/assets/figma-plugin.png +0 -0
  142. package/src/stories/assets/github.svg +3 -0
  143. package/src/stories/assets/share.png +0 -0
  144. package/src/stories/assets/styling.png +0 -0
  145. package/src/stories/assets/testing.png +0 -0
  146. package/src/stories/assets/theming.png +0 -0
  147. package/src/stories/assets/tutorials.svg +12 -0
  148. package/src/stories/assets/youtube.svg +4 -0
  149. package/src/stories/button.css +30 -0
  150. package/src/stories/header.css +32 -0
  151. package/src/stories/page.css +69 -0
  152. package/src/util/idleTimerUtils.js +36 -0
  153. package/src/util/index.js +3 -1
  154. package/src/components/atoms/icons/icons.stories.js +0 -116
  155. package/src/components/molecules/edit-name-form/EdidNameForm.stories.js +0 -24
  156. package/src/components/molecules/multiple-select-filter/__private__/ActionLinkButton.js +0 -24
  157. package/src/components/molecules/multiple-select-filter/__private__/FilterButton.js +0 -85
  158. package/src/components/molecules/multiple-select-filter/__private__/FilterDropdown.js +0 -23
  159. package/src/components/molecules/multiple-select-filter/__private__/FilterableList.js +0 -144
  160. package/src/components/molecules/multiple-select-filter/__private__/FilterableListItem.js +0 -67
  161. package/src/components/molecules/multiple-select-filter/__private__/SearchBox.js +0 -38
  162. package/src/components/molecules/multiple-select-filter/__private__/useKeyboardNavigation.js +0 -84
  163. package/src/components/molecules/multiple-select-filter/__private__/util.js +0 -31
  164. package/src/components/molecules/toast-notification/ToastNotification.stories.js +0 -105
  165. /package/src/components/atoms/add-obligation/{AddObligation.stories.js → AddObligation.oldstories.js} +0 -0
  166. /package/src/components/atoms/amount-callout/{AmountCallout.stories.js → AmountCallout.oldstories.js} +0 -0
  167. /package/src/components/atoms/checkbox-list/{CheckboxList.stories.js → CheckboxList.oldstories.js} +0 -0
  168. /package/src/components/atoms/form-layouts/{FormLayouts.stories.js → FormLayouts.oldstories.js} +0 -0
  169. /package/src/components/atoms/hamburger-button/{HamburgerButton.stories.js → HamburgerButton.oldstories.js} +0 -0
  170. /package/src/components/atoms/heading/{Heading.stories.js → Heading.oldstories.js} +0 -0
  171. /package/src/components/atoms/layouts/examples/box-example/{BoxExample.stories.js → BoxExample.oldstories.js} +0 -0
  172. /package/src/components/atoms/layouts/examples/center-example/{CenterExample.stories.js → CenterExample.oldstories.js} +0 -0
  173. /package/src/components/atoms/layouts/examples/cluster-example/{ClusterExample.stories.js → ClusterExample.oldstories.js} +0 -0
  174. /package/src/components/atoms/layouts/examples/cover-example/{CoverExample.stories.js → CoverExample.oldstories.js} +0 -0
  175. /package/src/components/atoms/layouts/examples/frame-example/{FrameExample.stories.js → FrameExample.oldstories.js} +0 -0
  176. /package/src/components/atoms/layouts/examples/grid-example/{GridExample.stories.js → GridExample.oldstories.js} +0 -0
  177. /package/src/components/atoms/layouts/examples/imposter-example/{ImposterExample.stories.js → ImposterExample.oldstories.js} +0 -0
  178. /package/src/components/atoms/layouts/examples/motion-example/{MotionExample.stories.js → MotionExample.oldstories.js} +0 -0
  179. /package/src/components/atoms/layouts/examples/reel-example/{ReelExample.stories.js → ReelExample.oldstories.js} +0 -0
  180. /package/src/components/atoms/layouts/examples/sidebar-example/{SidebarExample.stories.js → SidebarExample.oldstories.js} +0 -0
  181. /package/src/components/atoms/layouts/examples/stack-example/{StackExample.stories.js → StackExample.oldstories.js} +0 -0
  182. /package/src/components/atoms/layouts/examples/switcher-example/{SwitcherExample.stories.js → SwitcherExample.oldstories.js} +0 -0
  183. /package/src/components/atoms/paragraph/{Paragraph.stories.js → Paragraph.oldstories.js} +0 -0
  184. /package/src/components/atoms/processing-fee/{ProcessingFee.stories.js → ProcessingFee.oldstories.js} +0 -0
  185. /package/src/components/atoms/search/{Search.stories.js → Search.oldstories.js} +0 -0
  186. /package/src/components/atoms/solid-divider/{SolidDivider.stories.js → SolidDivider.oldstories.js} +0 -0
  187. /package/src/components/atoms/sortable-table-heading/{SortableTableHeading.stories.js → SortableTableHeading.oldstories.js} +0 -0
  188. /package/src/components/atoms/spinner/{Spinner.stories.js → Spinner.oldstories.js} +0 -0
  189. /package/src/components/atoms/tab/{Tab.stories.js → Tab.oldstories.js} +0 -0
  190. /package/src/components/atoms/text/{Text.stories.js → Text.oldstories.js} +0 -0
  191. /package/src/components/atoms/typeahead-input/{TypeaheadIinput.stories.js → TypeaheadIinput.oldstories.js} +0 -0
  192. /package/src/components/atoms/wallet-name/{WalletName.stories.js → WalletName.oldstories.js} +0 -0
  193. /package/src/components/molecules/account-and-routing-modal/{AccountAndRoutingModal.stories.js → AccountAndRoutingModal.oldstories.js} +0 -0
  194. /package/src/components/molecules/editable-list/{EditableList.stories.js → EditableList.oldstories.js} +0 -0
  195. /package/src/components/molecules/email-form/{EmailForm.stories.js → EmailForm.oldstories.js} +0 -0
  196. /package/src/components/molecules/forgot-password-form/{ForgotPasswordForm.stories.js → ForgotPasswordForm.oldstories.js} +0 -0
  197. /package/src/components/molecules/highlight-tab-row/{HighlightTabRow.stories.js → HighlightTabRow.oldstories.js} +0 -0
  198. /package/src/components/molecules/obligation/modules/{AmountModule.stories.js → AmountModule.oldstories.js} +0 -0
  199. /package/src/components/molecules/payment-button-bar/{PaymentButtonBar.stories.js → PaymentButtonBar.oldstories.js} +0 -0
  200. /package/src/components/molecules/payment-details/{PaymentDetails.stories.js → PaymentDetails.oldstories.js} +0 -0
  201. /package/src/components/molecules/payment-form-ach/{PaymentFormACH.stories.js → PaymentFormACH.oldstories.js} +0 -0
  202. /package/src/components/molecules/payment-form-card/{PaymentFormCard.stories.js → PaymentFormCard.oldstories.js} +0 -0
  203. /package/src/components/molecules/periscope-dashboard-iframe/{PeriscopeDashBoardIframe.stories.js → PeriscopeDashBoardIframe.oldstories.js} +0 -0
  204. /package/src/components/molecules/phone-form/{PhoneForm.stories.js → PhoneForm.oldstories.js} +0 -0
  205. /package/src/components/molecules/popup-menu/{PopupMenu.stories.js → PopupMenu.oldstories.js} +0 -0
  206. /package/src/components/molecules/radio-group/{RadioGroup.stories.js → RadioGroup.oldstories.js} +0 -0
  207. /package/src/components/molecules/radio-section/{RadioSection.stories.js → RadioSection.oldstories.js} +0 -0
  208. /package/src/components/molecules/registration-form/{RegistrationForm.stories.js → RegistrationForm.oldstories.js} +0 -0
  209. /package/src/components/molecules/reset-confirmation-form/{ResetConfirmationForm.stories.js → ResetConfirmationForm.oldstories.js} +0 -0
  210. /package/src/components/molecules/reset-password-form/{ResetPasswordForm.stories.js → ResetPasswordForm.oldstories.js} +0 -0
  211. /package/src/components/molecules/reset-password-success/{ResetPasswordSuccess.stories.js → ResetPasswordSuccess.oldstories.js} +0 -0
  212. /package/src/components/molecules/tab-sidebar/{TabSidebar.stories.js → TabSidebar.oldstories.js} +0 -0
  213. /package/src/components/molecules/terms-and-conditions/{TermsAndConditions.stories.js → TermsAndConditions.oldstories.js} +0 -0
  214. /package/src/components/molecules/terms-and-conditions-modal/{TermsAndConditionsModal.stories.js → TermsAndConditionsModal.oldstories.js} +0 -0
  215. /package/src/components/molecules/workflow-tile/{WorkflowTile.stories.js → WorkflowTile.oldstories.js} +0 -0
@@ -0,0 +1,183 @@
1
+ import React, { useState } from "react";
2
+ import ToastNotification from "./ToastNotification";
3
+ import { fn } from "@storybook/test";
4
+ import { ButtonWithAction } from "../../atoms";
5
+ import { Box, Stack } from "../../atoms/layouts";
6
+ import { ONAHAU_BLUE } from "../../../constants/colors";
7
+
8
+ export default {
9
+ title: "Molecules/Toast",
10
+ component: ToastNotification,
11
+ tags: ["!autodocs"],
12
+ parameters: {
13
+ layout: "centered",
14
+ controls: { expanded: true }
15
+ },
16
+ args: {
17
+ variant: "success",
18
+ message: "",
19
+ toastOpen: false,
20
+ closeToastNotification: fn(),
21
+ extraStyles: undefined,
22
+ minWidth: "112px",
23
+ maxWidth: "350px",
24
+ height: "56px",
25
+ childGap: "1rem",
26
+ backgroundColor: undefined,
27
+ role: "status",
28
+ ariaLive: "polite",
29
+ screenReaderMessage: undefined,
30
+ showScreenReaderMessage: true
31
+ },
32
+ argTypes: {
33
+ variant: {
34
+ description: "Type of toast notification, one of success/error.",
35
+ table: {
36
+ type: { summary: "string" },
37
+ defaultValue: { summary: "" }
38
+ }
39
+ },
40
+ message: {
41
+ description: "Content of the toast notification",
42
+ table: {
43
+ type: { summary: "string" },
44
+ defaultValue: { summary: "" }
45
+ }
46
+ },
47
+ toastOpen: {
48
+ description: "Whether the toast is visible",
49
+ table: {
50
+ type: { summary: "boolean" },
51
+ defaultValue: { summary: false }
52
+ }
53
+ },
54
+ closeToastNotification: {
55
+ description: "Function to run when user closes the toast",
56
+ table: {
57
+ type: { summary: "function" },
58
+ defaultValue: { summary: undefined }
59
+ }
60
+ },
61
+ extraStyles: {
62
+ description: "Additional styles for toast notification",
63
+ table: {
64
+ type: { summary: "string" },
65
+ defaultValue: { summary: undefined }
66
+ }
67
+ },
68
+ minWidth: {
69
+ description: "Minimum width of toast notification",
70
+ table: {
71
+ type: { summary: "string" },
72
+ defaultValue: { summary: "112px" }
73
+ }
74
+ },
75
+ maxWidth: {
76
+ description: "Maximum width of toast notification",
77
+ table: {
78
+ type: { summary: "string" },
79
+ defaultValue: { summary: "350px" }
80
+ }
81
+ },
82
+ height: {
83
+ description: "Height of toast notification",
84
+ table: {
85
+ type: { summary: "string" },
86
+ defaultValue: { summary: "56px" }
87
+ }
88
+ },
89
+ childGap: {
90
+ description: "Gap between toast icon, content, and close button",
91
+ table: {
92
+ type: { summary: "string" },
93
+ defaultValue: { summary: "1rem" }
94
+ }
95
+ },
96
+ backgroundColor: {
97
+ description: "Override for background color",
98
+ table: {
99
+ type: { summary: "string" },
100
+ defaultValue: { summary: undefined }
101
+ }
102
+ },
103
+ role: {
104
+ description: "aria-role for screen reader message",
105
+ table: {
106
+ type: { summary: "string" },
107
+ defaultValue: { summary: "status" }
108
+ }
109
+ },
110
+ ariaLive: {
111
+ description: "aria-live behavior for screen reader message",
112
+ table: {
113
+ type: { summary: "string" },
114
+ defaultValue: { summary: "polite" }
115
+ }
116
+ },
117
+ screenReaderMessage: {
118
+ description: "Content of message to be read to users of screen readers",
119
+ table: {
120
+ type: { summary: "string" },
121
+ defaultValue: { summary: undefined }
122
+ }
123
+ },
124
+ showScreenReaderMessage: {
125
+ description:
126
+ "Whether a message for screen reader users should appear when toast is displayed",
127
+ table: {
128
+ type: { summary: "boolean" },
129
+ defaultValue: { summary: true }
130
+ }
131
+ }
132
+ }
133
+ };
134
+
135
+ export const SuccessToast = {
136
+ args: {
137
+ message: "Account added to profile",
138
+ screenReaderMessage: "Account added to profile",
139
+ toastOpen: true
140
+ }
141
+ };
142
+
143
+ export const ErrorToast = {
144
+ args: {
145
+ variant: "error",
146
+ message:
147
+ "Error: payment unsuccessful. Please check your credit card details.",
148
+ screenReaderMessage:
149
+ "Payment unsuccessful. Please check your credit card details.",
150
+ toastOpen: true
151
+ }
152
+ };
153
+
154
+ export const CustomToast = {
155
+ args: {
156
+ message: "A toast notification can be used for any type of message",
157
+ screenReaderMessage: "Use toasts for any purpose",
158
+ backgroundColor: `${ONAHAU_BLUE}`
159
+ },
160
+ render: args => {
161
+ const [toastOpen, setToastOpen] = useState(false);
162
+
163
+ return (
164
+ <Box>
165
+ <Stack childGap="3rem">
166
+ <Box>
167
+ <ButtonWithAction
168
+ action={() => setToastOpen(!toastOpen)}
169
+ text="Trigger Toast"
170
+ />
171
+ </Box>
172
+ <Box>
173
+ <ToastNotification
174
+ {...args}
175
+ toastOpen={toastOpen}
176
+ closeToastNotification={() => setToastOpen(false)}
177
+ />
178
+ </Box>
179
+ </Stack>
180
+ </Box>
181
+ );
182
+ }
183
+ };
@@ -18,11 +18,12 @@ const useOutsideClickHook = handler => {
18
18
  if (ref.current && !ref.current.contains(e.target)) {
19
19
  handler();
20
20
  }
21
- };
22
21
 
23
- document.addEventListener("click", handleOutsideClick, true);
24
- return () => {
25
- document.removeEventListener("click", handleOutsideClick, true);
22
+ document.addEventListener("click", handleOutsideClick, true);
23
+
24
+ return () => {
25
+ document.removeEventListener("click", handleOutsideClick, true);
26
+ };
26
27
  };
27
28
  }, [ref]);
28
29
 
@@ -0,0 +1,53 @@
1
+ import type { Meta, StoryObj } from '@storybook/react';
2
+ import { fn } from '@storybook/test';
3
+
4
+ import { Button } from './Button';
5
+
6
+ // More on how to set up stories at: https://storybook.js.org/docs/writing-stories#default-export
7
+ const meta: Meta<typeof Button> = {
8
+ title: 'Example/Button',
9
+ component: Button,
10
+ parameters: {
11
+ // Optional parameter to center the component in the Canvas. More info: https://storybook.js.org/docs/configure/story-layout
12
+ layout: 'centered',
13
+ },
14
+ // This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs
15
+ tags: ['autodocs'],
16
+ // More on argTypes: https://storybook.js.org/docs/api/argtypes
17
+ argTypes: {
18
+ backgroundColor: { control: 'color' },
19
+ },
20
+ // Use `fn` to spy on the onClick arg, which will appear in the actions panel once invoked: https://storybook.js.org/docs/essentials/actions#action-args
21
+ args: { onClick: fn() },
22
+ };
23
+
24
+ export default meta;
25
+ type Story = StoryObj<typeof Button>;
26
+
27
+ // More on writing stories with args: https://storybook.js.org/docs/writing-stories/args
28
+ export const Primary: Story = {
29
+ args: {
30
+ primary: true,
31
+ label: 'Button',
32
+ },
33
+ };
34
+
35
+ export const Secondary: Story = {
36
+ args: {
37
+ label: 'Button',
38
+ },
39
+ };
40
+
41
+ export const Large: Story = {
42
+ args: {
43
+ size: 'large',
44
+ label: 'Button',
45
+ },
46
+ };
47
+
48
+ export const Small: Story = {
49
+ args: {
50
+ size: 'small',
51
+ label: 'Button',
52
+ },
53
+ };
@@ -0,0 +1,48 @@
1
+ import React from 'react';
2
+ import './button.css';
3
+
4
+ interface ButtonProps {
5
+ /**
6
+ * Is this the principal call to action on the page?
7
+ */
8
+ primary?: boolean;
9
+ /**
10
+ * What background color to use
11
+ */
12
+ backgroundColor?: string;
13
+ /**
14
+ * How large should the button be?
15
+ */
16
+ size?: 'small' | 'medium' | 'large';
17
+ /**
18
+ * Button contents
19
+ */
20
+ label: string;
21
+ /**
22
+ * Optional click handler
23
+ */
24
+ onClick?: () => void;
25
+ }
26
+
27
+ /**
28
+ * Primary UI component for user interaction
29
+ */
30
+ export const Button = ({
31
+ primary = false,
32
+ size = 'medium',
33
+ backgroundColor,
34
+ label,
35
+ ...props
36
+ }: ButtonProps) => {
37
+ const mode = primary ? 'storybook-button--primary' : 'storybook-button--secondary';
38
+ return (
39
+ <button
40
+ type="button"
41
+ className={['storybook-button', `storybook-button--${size}`, mode].join(' ')}
42
+ style={{ backgroundColor }}
43
+ {...props}
44
+ >
45
+ {label}
46
+ </button>
47
+ );
48
+ };
@@ -0,0 +1,364 @@
1
+ import { Meta } from "@storybook/blocks";
2
+
3
+ import Github from "./assets/github.svg";
4
+ import Discord from "./assets/discord.svg";
5
+ import Youtube from "./assets/youtube.svg";
6
+ import Tutorials from "./assets/tutorials.svg";
7
+ import Styling from "./assets/styling.png";
8
+ import Context from "./assets/context.png";
9
+ import Assets from "./assets/assets.png";
10
+ import Docs from "./assets/docs.png";
11
+ import Share from "./assets/share.png";
12
+ import FigmaPlugin from "./assets/figma-plugin.png";
13
+ import Testing from "./assets/testing.png";
14
+ import Accessibility from "./assets/accessibility.png";
15
+ import Theming from "./assets/theming.png";
16
+ import AddonLibrary from "./assets/addon-library.png";
17
+
18
+ export const RightArrow = () => <svg
19
+ viewBox="0 0 14 14"
20
+ width="8px"
21
+ height="14px"
22
+ style={{
23
+ marginLeft: '4px',
24
+ display: 'inline-block',
25
+ shapeRendering: 'inherit',
26
+ verticalAlign: 'middle',
27
+ fill: 'currentColor',
28
+ 'path fill': 'currentColor'
29
+ }}
30
+ >
31
+ <path d="m11.1 7.35-5.5 5.5a.5.5 0 0 1-.7-.7L10.04 7 4.9 1.85a.5.5 0 1 1 .7-.7l5.5 5.5c.2.2.2.5 0 .7Z" />
32
+ </svg>
33
+
34
+ <Meta title="Configure your project" />
35
+
36
+ <div className="sb-container">
37
+ <div className='sb-section-title'>
38
+ # Configure your project
39
+
40
+ Because Storybook works separately from your app, you'll need to configure it for your specific stack and setup. Below, explore guides for configuring Storybook with popular frameworks and tools. If you get stuck, learn how you can ask for help from our community.
41
+ </div>
42
+ <div className="sb-section">
43
+ <div className="sb-section-item">
44
+ <img
45
+ src={Styling}
46
+ alt="A wall of logos representing different styling technologies"
47
+ />
48
+ <h4 className="sb-section-item-heading">Add styling and CSS</h4>
49
+ <p className="sb-section-item-paragraph">Like with web applications, there are many ways to include CSS within Storybook. Learn more about setting up styling within Storybook.</p>
50
+ <a
51
+ href="https://storybook.js.org/docs/react/configure/styling-and-css"
52
+ target="_blank"
53
+ >Learn more<RightArrow /></a>
54
+ </div>
55
+ <div className="sb-section-item">
56
+ <img
57
+ src={Context}
58
+ alt="An abstraction representing the composition of data for a component"
59
+ />
60
+ <h4 className="sb-section-item-heading">Provide context and mocking</h4>
61
+ <p className="sb-section-item-paragraph">Often when a story doesn't render, it's because your component is expecting a specific environment or context (like a theme provider) to be available.</p>
62
+ <a
63
+ href="https://storybook.js.org/docs/react/writing-stories/decorators#context-for-mocking"
64
+ target="_blank"
65
+ >Learn more<RightArrow /></a>
66
+ </div>
67
+ <div className="sb-section-item">
68
+ <img src={Assets} alt="A representation of typography and image assets" />
69
+ <div>
70
+ <h4 className="sb-section-item-heading">Load assets and resources</h4>
71
+ <p className="sb-section-item-paragraph">To link static files (like fonts) to your projects and stories, use the
72
+ `staticDirs` configuration option to specify folders to load when
73
+ starting Storybook.</p>
74
+ <a
75
+ href="https://storybook.js.org/docs/react/configure/images-and-assets"
76
+ target="_blank"
77
+ >Learn more<RightArrow /></a>
78
+ </div>
79
+ </div>
80
+ </div>
81
+ </div>
82
+ <div className="sb-container">
83
+ <div className='sb-section-title'>
84
+ # Do more with Storybook
85
+
86
+ Now that you know the basics, let's explore other parts of Storybook that will improve your experience. This list is just to get you started. You can customise Storybook in many ways to fit your needs.
87
+ </div>
88
+
89
+ <div className="sb-section">
90
+ <div className="sb-features-grid">
91
+ <div className="sb-grid-item">
92
+ <img src={Docs} alt="A screenshot showing the autodocs tag being set, pointing a docs page being generated" />
93
+ <h4 className="sb-section-item-heading">Autodocs</h4>
94
+ <p className="sb-section-item-paragraph">Auto-generate living,
95
+ interactive reference documentation from your components and stories.</p>
96
+ <a
97
+ href="https://storybook.js.org/docs/react/writing-docs/autodocs"
98
+ target="_blank"
99
+ >Learn more<RightArrow /></a>
100
+ </div>
101
+ <div className="sb-grid-item">
102
+ <img src={Share} alt="A browser window showing a Storybook being published to a chromatic.com URL" />
103
+ <h4 className="sb-section-item-heading">Publish to Chromatic</h4>
104
+ <p className="sb-section-item-paragraph">Publish your Storybook to review and collaborate with your entire team.</p>
105
+ <a
106
+ href="https://storybook.js.org/docs/react/sharing/publish-storybook#publish-storybook-with-chromatic"
107
+ target="_blank"
108
+ >Learn more<RightArrow /></a>
109
+ </div>
110
+ <div className="sb-grid-item">
111
+ <img src={FigmaPlugin} alt="Windows showing the Storybook plugin in Figma" />
112
+ <h4 className="sb-section-item-heading">Figma Plugin</h4>
113
+ <p className="sb-section-item-paragraph">Embed your stories into Figma to cross-reference the design and live
114
+ implementation in one place.</p>
115
+ <a
116
+ href="https://storybook.js.org/docs/react/sharing/design-integrations#embed-storybook-in-figma-with-the-plugin"
117
+ target="_blank"
118
+ >Learn more<RightArrow /></a>
119
+ </div>
120
+ <div className="sb-grid-item">
121
+ <img src={Testing} alt="Screenshot of tests passing and failing" />
122
+ <h4 className="sb-section-item-heading">Testing</h4>
123
+ <p className="sb-section-item-paragraph">Use stories to test a component in all its variations, no matter how
124
+ complex.</p>
125
+ <a
126
+ href="https://storybook.js.org/docs/react/writing-tests"
127
+ target="_blank"
128
+ >Learn more<RightArrow /></a>
129
+ </div>
130
+ <div className="sb-grid-item">
131
+ <img src={Accessibility} alt="Screenshot of accessibility tests passing and failing" />
132
+ <h4 className="sb-section-item-heading">Accessibility</h4>
133
+ <p className="sb-section-item-paragraph">Automatically test your components for a11y issues as you develop.</p>
134
+ <a
135
+ href="https://storybook.js.org/docs/react/writing-tests/accessibility-testing"
136
+ target="_blank"
137
+ >Learn more<RightArrow /></a>
138
+ </div>
139
+ <div className="sb-grid-item">
140
+ <img src={Theming} alt="Screenshot of Storybook in light and dark mode" />
141
+ <h4 className="sb-section-item-heading">Theming</h4>
142
+ <p className="sb-section-item-paragraph">Theme Storybook's UI to personalize it to your project.</p>
143
+ <a
144
+ href="https://storybook.js.org/docs/react/configure/theming"
145
+ target="_blank"
146
+ >Learn more<RightArrow /></a>
147
+ </div>
148
+ </div>
149
+ </div>
150
+ </div>
151
+ <div className='sb-addon'>
152
+ <div className='sb-addon-text'>
153
+ <h4>Addons</h4>
154
+ <p className="sb-section-item-paragraph">Integrate your tools with Storybook to connect workflows.</p>
155
+ <a
156
+ href="https://storybook.js.org/integrations/"
157
+ target="_blank"
158
+ >Discover all addons<RightArrow /></a>
159
+ </div>
160
+ <div className='sb-addon-img'>
161
+ <img src={AddonLibrary} alt="Integrate your tools with Storybook to connect workflows." />
162
+ </div>
163
+ </div>
164
+
165
+ <div className="sb-section sb-socials">
166
+ <div className="sb-section-item">
167
+ <img src={Github} alt="Github logo" className="sb-explore-image"/>
168
+ Join our contributors building the future of UI development.
169
+
170
+ <a
171
+ href="https://github.com/storybookjs/storybook"
172
+ target="_blank"
173
+ >Star on GitHub<RightArrow /></a>
174
+ </div>
175
+ <div className="sb-section-item">
176
+ <img src={Discord} alt="Discord logo" className="sb-explore-image"/>
177
+ <div>
178
+ Get support and chat with frontend developers.
179
+
180
+ <a
181
+ href="https://discord.gg/storybook"
182
+ target="_blank"
183
+ >Join Discord server<RightArrow /></a>
184
+ </div>
185
+ </div>
186
+ <div className="sb-section-item">
187
+ <img src={Youtube} alt="Youtube logo" className="sb-explore-image"/>
188
+ <div>
189
+ Watch tutorials, feature previews and interviews.
190
+
191
+ <a
192
+ href="https://www.youtube.com/@chromaticui"
193
+ target="_blank"
194
+ >Watch on YouTube<RightArrow /></a>
195
+ </div>
196
+ </div>
197
+ <div className="sb-section-item">
198
+ <img src={Tutorials} alt="A book" className="sb-explore-image"/>
199
+ <p>Follow guided walkthroughs on for key workflows.</p>
200
+
201
+ <a
202
+ href="https://storybook.js.org/tutorials/"
203
+ target="_blank"
204
+ >Discover tutorials<RightArrow /></a>
205
+ </div>
206
+ </div>
207
+
208
+ <style>
209
+ {`
210
+ .sb-container {
211
+ margin-bottom: 48px;
212
+ }
213
+
214
+ .sb-section {
215
+ width: 100%;
216
+ display: flex;
217
+ flex-direction: row;
218
+ gap: 20px;
219
+ }
220
+
221
+ img {
222
+ object-fit: cover;
223
+ }
224
+
225
+ .sb-section-title {
226
+ margin-bottom: 32px;
227
+ }
228
+
229
+ .sb-section a:not(h1 a, h2 a, h3 a) {
230
+ font-size: 14px;
231
+ }
232
+
233
+ .sb-section-item, .sb-grid-item {
234
+ flex: 1;
235
+ display: flex;
236
+ flex-direction: column;
237
+ }
238
+
239
+ .sb-section-item-heading {
240
+ padding-top: 20px !important;
241
+ padding-bottom: 5px !important;
242
+ margin: 0 !important;
243
+ }
244
+ .sb-section-item-paragraph {
245
+ margin: 0;
246
+ padding-bottom: 10px;
247
+ }
248
+
249
+ .sb-chevron {
250
+ margin-left: 5px;
251
+ }
252
+
253
+ .sb-features-grid {
254
+ display: grid;
255
+ grid-template-columns: repeat(2, 1fr);
256
+ grid-gap: 32px 20px;
257
+ }
258
+
259
+ .sb-socials {
260
+ display: grid;
261
+ grid-template-columns: repeat(4, 1fr);
262
+ }
263
+
264
+ .sb-socials p {
265
+ margin-bottom: 10px;
266
+ }
267
+
268
+ .sb-explore-image {
269
+ max-height: 32px;
270
+ align-self: flex-start;
271
+ }
272
+
273
+ .sb-addon {
274
+ width: 100%;
275
+ display: flex;
276
+ align-items: center;
277
+ position: relative;
278
+ background-color: #EEF3F8;
279
+ border-radius: 5px;
280
+ border: 1px solid rgba(0, 0, 0, 0.05);
281
+ background: #EEF3F8;
282
+ height: 180px;
283
+ margin-bottom: 48px;
284
+ overflow: hidden;
285
+ }
286
+
287
+ .sb-addon-text {
288
+ padding-left: 48px;
289
+ max-width: 240px;
290
+ }
291
+
292
+ .sb-addon-text h4 {
293
+ padding-top: 0px;
294
+ }
295
+
296
+ .sb-addon-img {
297
+ position: absolute;
298
+ left: 345px;
299
+ top: 0;
300
+ height: 100%;
301
+ width: 200%;
302
+ overflow: hidden;
303
+ }
304
+
305
+ .sb-addon-img img {
306
+ width: 650px;
307
+ transform: rotate(-15deg);
308
+ margin-left: 40px;
309
+ margin-top: -72px;
310
+ box-shadow: 0 0 1px rgba(255, 255, 255, 0);
311
+ backface-visibility: hidden;
312
+ }
313
+
314
+ @media screen and (max-width: 800px) {
315
+ .sb-addon-img {
316
+ left: 300px;
317
+ }
318
+ }
319
+
320
+ @media screen and (max-width: 600px) {
321
+ .sb-section {
322
+ flex-direction: column;
323
+ }
324
+
325
+ .sb-features-grid {
326
+ grid-template-columns: repeat(1, 1fr);
327
+ }
328
+
329
+ .sb-socials {
330
+ grid-template-columns: repeat(2, 1fr);
331
+ }
332
+
333
+ .sb-addon {
334
+ height: 280px;
335
+ align-items: flex-start;
336
+ padding-top: 32px;
337
+ overflow: hidden;
338
+ }
339
+
340
+ .sb-addon-text {
341
+ padding-left: 24px;
342
+ }
343
+
344
+ .sb-addon-img {
345
+ right: 0;
346
+ left: 0;
347
+ top: 130px;
348
+ bottom: 0;
349
+ overflow: hidden;
350
+ height: auto;
351
+ width: 124%;
352
+ }
353
+
354
+ .sb-addon-img img {
355
+ width: 1200px;
356
+ transform: rotate(-12deg);
357
+ margin-left: 0;
358
+ margin-top: 48px;
359
+ margin-bottom: -40px;
360
+ margin-left: -24px;
361
+ }
362
+ }
363
+ `}
364
+ </style>
@@ -0,0 +1,33 @@
1
+ import type { Meta, StoryObj } from '@storybook/react';
2
+ import { fn } from '@storybook/test';
3
+
4
+ import { Header } from './Header';
5
+
6
+ const meta: Meta<typeof Header> = {
7
+ title: 'Example/Header',
8
+ component: Header,
9
+ // This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs
10
+ tags: ['autodocs'],
11
+ parameters: {
12
+ // More on Story layout: https://storybook.js.org/docs/configure/story-layout
13
+ layout: 'fullscreen',
14
+ },
15
+ args: {
16
+ onLogin: fn(),
17
+ onLogout: fn(),
18
+ onCreateAccount: fn(),
19
+ },
20
+ };
21
+
22
+ export default meta;
23
+ type Story = StoryObj<typeof Header>;
24
+
25
+ export const LoggedIn: Story = {
26
+ args: {
27
+ user: {
28
+ name: 'Jane Doe',
29
+ },
30
+ },
31
+ };
32
+
33
+ export const LoggedOut: Story = {};