@thecb/components 10.12.3-beta.0 → 10.12.3

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 (211) hide show
  1. package/README.md +0 -4
  2. package/dist/index.cjs.js +2526 -1617
  3. package/dist/index.cjs.js.map +1 -1
  4. package/dist/index.d.ts +4 -5
  5. package/dist/index.esm.js +2527 -1617
  6. package/dist/index.esm.js.map +1 -1
  7. package/package.json +13 -25
  8. package/src/components/atoms/alert/Alert.stories.js +26 -148
  9. package/src/components/atoms/badge/Badge.js +2 -2
  10. package/src/components/atoms/badge/Badge.stories.js +29 -143
  11. package/src/components/atoms/breadcrumb/Breadcrumb.stories.js +29 -38
  12. package/src/components/atoms/button-with-action/ButtonWithAction.stories.js +55 -108
  13. package/src/components/atoms/button-with-link/ButtonWithLink.stories.js +31 -160
  14. package/src/components/atoms/checkbox/Checkbox.stories.js +29 -148
  15. package/src/components/atoms/country-dropdown/CountryDropdown.stories.js +27 -61
  16. package/src/components/atoms/detail/Detail.js +26 -0
  17. package/src/components/atoms/display-box/DisplayBox.stories.js +21 -65
  18. package/src/components/atoms/display-card/DisplayCard.stories.js +22 -163
  19. package/src/components/atoms/dropdown/Dropdown.stories.js +10 -91
  20. package/src/components/atoms/form-layouts/FormInput.stories.js +26 -212
  21. package/src/components/atoms/form-select/FormSelect.stories.js +29 -55
  22. package/src/components/atoms/formatted-address/FormattedAddress.stories.js +27 -133
  23. package/src/components/atoms/icons/icons.stories.js +116 -0
  24. package/src/components/atoms/labeled-amount/LabeledAmount.stories.js +34 -110
  25. package/src/components/atoms/line-item/LineItem.stories.js +22 -89
  26. package/src/components/atoms/link/Link.stories.js +49 -155
  27. package/src/components/atoms/loading-line/LoadingLine.js +10 -14
  28. package/src/components/atoms/loading-line/LoadingLine.stories.js +28 -132
  29. package/src/components/atoms/nav-footer/NavFooter.stories.js +22 -235
  30. package/src/components/atoms/nav-header/NavHeader.stories.js +21 -122
  31. package/src/components/atoms/password-requirements/PasswordRequirements.stories.js +44 -108
  32. package/src/components/atoms/placeholder/Placeholder.stories.js +36 -164
  33. package/src/components/atoms/searchable-select/SearchableSelect.stories.js +28 -103
  34. package/src/components/atoms/state-province-dropdown/StateProvinceDropdown.stories.js +40 -65
  35. package/src/components/atoms/table/Table.stories.js +75 -59
  36. package/src/components/atoms/table/TableRow.js +0 -1
  37. package/src/components/atoms/title/Title.js +23 -0
  38. package/src/components/atoms/toggle-switch/ToggleSwitch.stories.js +20 -103
  39. package/src/components/atoms/toggle-switch/ToggleSwitch.theme.js +5 -8
  40. package/src/components/molecules/address-form/AddressForm.stories.js +20 -223
  41. package/src/components/molecules/banner/Banner.stories.js +26 -122
  42. package/src/components/molecules/change-password-form/ChangePasswordForm.stories.js +19 -203
  43. package/src/components/molecules/collapsible-section/CollapsibleSection.stories.js +61 -210
  44. package/src/components/molecules/edit-name-form/EdidNameForm.stories.js +24 -0
  45. package/src/components/molecules/index.js +0 -1
  46. package/src/components/molecules/link-card/LinkCard.stories.js +72 -287
  47. package/src/components/molecules/login-form/LoginForm.stories.js +21 -117
  48. package/src/components/molecules/modal/Modal.stories.js +128 -342
  49. package/src/components/molecules/module/Module.stories.js +25 -267
  50. package/src/components/molecules/multiple-select-filter/MultipleSelectFilter.js +61 -295
  51. package/src/components/molecules/multiple-select-filter/{MultipleSelectFilter.oldstories.js → MultipleSelectFilter.stories.js} +1 -1
  52. package/src/components/molecules/multiple-select-filter/MultipleSelectFilter.styled.js +4 -4
  53. package/src/components/molecules/multiple-select-filter/__private__/ActionLinkButton.js +24 -0
  54. package/src/components/molecules/multiple-select-filter/__private__/FilterButton.js +85 -0
  55. package/src/components/molecules/multiple-select-filter/__private__/FilterDropdown.js +23 -0
  56. package/src/components/molecules/multiple-select-filter/__private__/FilterableList.js +144 -0
  57. package/src/components/molecules/multiple-select-filter/__private__/FilterableListItem.js +67 -0
  58. package/src/components/molecules/multiple-select-filter/__private__/SearchBox.js +38 -0
  59. package/src/components/molecules/multiple-select-filter/__private__/useKeyboardNavigation.js +84 -0
  60. package/src/components/molecules/multiple-select-filter/__private__/util.js +31 -0
  61. package/src/components/molecules/obligation/icons/PropertyPersonalIcon.js +1 -1
  62. package/src/components/molecules/pagination/Pagination.stories.js +28 -177
  63. package/src/components/molecules/tabs/Tabs.stories.js +227 -135
  64. package/src/components/molecules/toast-notification/ToastNotification.stories.js +105 -0
  65. package/src/hooks/use-outside-click/index.js +4 -5
  66. package/src/util/index.js +1 -3
  67. package/src/components/atoms/alert/Alert.mdx +0 -19
  68. package/src/components/atoms/badge/Badge.mdx +0 -27
  69. package/src/components/atoms/breadcrumb/Breadcrumb.mdx +0 -21
  70. package/src/components/atoms/button-with-link/ButtonWithLink.mdx +0 -21
  71. package/src/components/atoms/card/Card.mdx +0 -41
  72. package/src/components/atoms/card/Card.stories.js +0 -360
  73. package/src/components/atoms/checkbox/Checkbox.mdx +0 -15
  74. package/src/components/atoms/checkbox/Checkbox.oldstories.js +0 -30
  75. package/src/components/atoms/country-dropdown/CountryDropdown.mdx +0 -36
  76. package/src/components/atoms/detail/Detail.mdx +0 -32
  77. package/src/components/atoms/detail/Detail.stories.js +0 -156
  78. package/src/components/atoms/display-box/DisplayBox.mdx +0 -11
  79. package/src/components/atoms/display-card/DisplayCard.mdx +0 -13
  80. package/src/components/atoms/dropdown/Dropdown.mdx +0 -65
  81. package/src/components/atoms/form-layouts/FormInput.mdx +0 -38
  82. package/src/components/atoms/form-select/FormSelect.mdx +0 -42
  83. package/src/components/atoms/formatted-address/FormattedAddress.mdx +0 -13
  84. package/src/components/atoms/formatted-bank-account/FormattedBankAccount.mdx +0 -17
  85. package/src/components/atoms/formatted-bank-account/FormattedBankAccount.stories.js +0 -57
  86. package/src/components/atoms/formatted-credit-card/FormattedCreditCard.mdx +0 -40
  87. package/src/components/atoms/formatted-credit-card/FormattedCreditCard.stories.js +0 -74
  88. package/src/components/atoms/icons/Icons.mdx +0 -40
  89. package/src/components/atoms/icons/Icons.stories.js +0 -325
  90. package/src/components/atoms/labeled-amount/LabeledAmount.mdx +0 -23
  91. package/src/components/atoms/line-item/LineItem.mdx +0 -28
  92. package/src/components/atoms/link/Link.mdx +0 -19
  93. package/src/components/atoms/loading/Loading.mdx +0 -13
  94. package/src/components/atoms/loading/Loading.stories.js +0 -22
  95. package/src/components/atoms/loading-line/LoadingLine.mdx +0 -15
  96. package/src/components/atoms/nav-footer/NavFooter.mdx +0 -15
  97. package/src/components/atoms/nav-header/NavHeader.mdx +0 -13
  98. package/src/components/atoms/nav-tabs/NavTabs.mdx +0 -30
  99. package/src/components/atoms/nav-tabs/NavTabs.stories.js +0 -49
  100. package/src/components/atoms/password-requirements/PasswordRequirements.mdx +0 -39
  101. package/src/components/atoms/placeholder/Placeholder.mdx +0 -19
  102. package/src/components/atoms/searchable-select/SearchableSelect.mdx +0 -44
  103. package/src/components/atoms/state-province-dropdown/StateProvinceDropdown.mdx +0 -36
  104. package/src/components/atoms/table/Table.mdx +0 -71
  105. package/src/components/atoms/table/Table.oldstories.js +0 -84
  106. package/src/components/atoms/title/Title.mdx +0 -26
  107. package/src/components/atoms/title/Title.stories.js +0 -144
  108. package/src/components/atoms/toggle-switch/ToggleSwitch.mdx +0 -17
  109. package/src/components/atoms/typeahead-input/TypeaheadInput.mdx +0 -13
  110. package/src/components/atoms/typeahead-input/TypeaheadInput.stories.js +0 -63
  111. package/src/components/molecules/address-form/AddressForm.mdx +0 -18
  112. package/src/components/molecules/banner/Banner.mdx +0 -23
  113. package/src/components/molecules/change-password-form/ChangePasswordForm.mdx +0 -15
  114. package/src/components/molecules/collapsible-section/CollapsibleSection.mdx +0 -15
  115. package/src/components/molecules/edit-name-form/EditNameForm.mdx +0 -13
  116. package/src/components/molecules/edit-name-form/EditNameForm.stories.js +0 -117
  117. package/src/components/molecules/idle-modal/IdleModal.js +0 -101
  118. package/src/components/molecules/idle-modal/IdleModal.mdx +0 -17
  119. package/src/components/molecules/idle-modal/IdleModal.stories.js +0 -180
  120. package/src/components/molecules/idle-modal/index.d.ts +0 -16
  121. package/src/components/molecules/idle-modal/index.js +0 -3
  122. package/src/components/molecules/link-card/LinkCard.mdx +0 -17
  123. package/src/components/molecules/login-form/LoginForm.mdx +0 -16
  124. package/src/components/molecules/modal/Modal.mdx +0 -17
  125. package/src/components/molecules/module/Module.mdx +0 -17
  126. package/src/components/molecules/obligation/Obligation.mdx +0 -23
  127. package/src/components/molecules/obligation/Obligation.stories.js +0 -460
  128. package/src/components/molecules/pagination/Pagination.mdx +0 -15
  129. package/src/components/molecules/popover/Popover.mdx +0 -15
  130. package/src/components/molecules/popover/Popover.stories.js +0 -220
  131. package/src/components/molecules/tabs/Tabs.mdx +0 -17
  132. package/src/components/molecules/toast-notification/Toast.mdx +0 -15
  133. package/src/components/molecules/toast-notification/Toast.stories.js +0 -183
  134. package/src/stories/Button.stories.ts +0 -53
  135. package/src/stories/Button.tsx +0 -48
  136. package/src/stories/Configure.mdx +0 -364
  137. package/src/stories/Header.stories.ts +0 -33
  138. package/src/stories/Header.tsx +0 -56
  139. package/src/stories/Page.stories.ts +0 -32
  140. package/src/stories/Page.tsx +0 -73
  141. package/src/stories/assets/accessibility.png +0 -0
  142. package/src/stories/assets/accessibility.svg +0 -5
  143. package/src/stories/assets/addon-library.png +0 -0
  144. package/src/stories/assets/assets.png +0 -0
  145. package/src/stories/assets/avif-test-image.avif +0 -0
  146. package/src/stories/assets/context.png +0 -0
  147. package/src/stories/assets/discord.svg +0 -15
  148. package/src/stories/assets/docs.png +0 -0
  149. package/src/stories/assets/figma-plugin.png +0 -0
  150. package/src/stories/assets/github.svg +0 -3
  151. package/src/stories/assets/share.png +0 -0
  152. package/src/stories/assets/styling.png +0 -0
  153. package/src/stories/assets/testing.png +0 -0
  154. package/src/stories/assets/theming.png +0 -0
  155. package/src/stories/assets/tutorials.svg +0 -12
  156. package/src/stories/assets/youtube.svg +0 -4
  157. package/src/stories/button.css +0 -30
  158. package/src/stories/header.css +0 -32
  159. package/src/stories/page.css +0 -69
  160. package/src/util/idleTimerUtils.js +0 -36
  161. /package/src/components/atoms/add-obligation/{AddObligation.oldstories.js → AddObligation.stories.js} +0 -0
  162. /package/src/components/atoms/amount-callout/{AmountCallout.oldstories.js → AmountCallout.stories.js} +0 -0
  163. /package/src/components/atoms/checkbox-list/{CheckboxList.oldstories.js → CheckboxList.stories.js} +0 -0
  164. /package/src/components/atoms/form-layouts/{FormLayouts.oldstories.js → FormLayouts.stories.js} +0 -0
  165. /package/src/components/atoms/hamburger-button/{HamburgerButton.oldstories.js → HamburgerButton.stories.js} +0 -0
  166. /package/src/components/atoms/heading/{Heading.oldstories.js → Heading.stories.js} +0 -0
  167. /package/src/components/atoms/layouts/examples/box-example/{BoxExample.oldstories.js → BoxExample.stories.js} +0 -0
  168. /package/src/components/atoms/layouts/examples/center-example/{CenterExample.oldstories.js → CenterExample.stories.js} +0 -0
  169. /package/src/components/atoms/layouts/examples/cluster-example/{ClusterExample.oldstories.js → ClusterExample.stories.js} +0 -0
  170. /package/src/components/atoms/layouts/examples/cover-example/{CoverExample.oldstories.js → CoverExample.stories.js} +0 -0
  171. /package/src/components/atoms/layouts/examples/frame-example/{FrameExample.oldstories.js → FrameExample.stories.js} +0 -0
  172. /package/src/components/atoms/layouts/examples/grid-example/{GridExample.oldstories.js → GridExample.stories.js} +0 -0
  173. /package/src/components/atoms/layouts/examples/imposter-example/{ImposterExample.oldstories.js → ImposterExample.stories.js} +0 -0
  174. /package/src/components/atoms/layouts/examples/motion-example/{MotionExample.oldstories.js → MotionExample.stories.js} +0 -0
  175. /package/src/components/atoms/layouts/examples/reel-example/{ReelExample.oldstories.js → ReelExample.stories.js} +0 -0
  176. /package/src/components/atoms/layouts/examples/sidebar-example/{SidebarExample.oldstories.js → SidebarExample.stories.js} +0 -0
  177. /package/src/components/atoms/layouts/examples/stack-example/{StackExample.oldstories.js → StackExample.stories.js} +0 -0
  178. /package/src/components/atoms/layouts/examples/switcher-example/{SwitcherExample.oldstories.js → SwitcherExample.stories.js} +0 -0
  179. /package/src/components/atoms/paragraph/{Paragraph.oldstories.js → Paragraph.stories.js} +0 -0
  180. /package/src/components/atoms/processing-fee/{ProcessingFee.oldstories.js → ProcessingFee.stories.js} +0 -0
  181. /package/src/components/atoms/search/{Search.oldstories.js → Search.stories.js} +0 -0
  182. /package/src/components/atoms/solid-divider/{SolidDivider.oldstories.js → SolidDivider.stories.js} +0 -0
  183. /package/src/components/atoms/sortable-table-heading/{SortableTableHeading.oldstories.js → SortableTableHeading.stories.js} +0 -0
  184. /package/src/components/atoms/spinner/{Spinner.oldstories.js → Spinner.stories.js} +0 -0
  185. /package/src/components/atoms/tab/{Tab.oldstories.js → Tab.stories.js} +0 -0
  186. /package/src/components/atoms/text/{Text.oldstories.js → Text.stories.js} +0 -0
  187. /package/src/components/atoms/typeahead-input/{TypeaheadIinput.oldstories.js → TypeaheadIinput.stories.js} +0 -0
  188. /package/src/components/atoms/wallet-name/{WalletName.oldstories.js → WalletName.stories.js} +0 -0
  189. /package/src/components/molecules/account-and-routing-modal/{AccountAndRoutingModal.oldstories.js → AccountAndRoutingModal.stories.js} +0 -0
  190. /package/src/components/molecules/editable-list/{EditableList.oldstories.js → EditableList.stories.js} +0 -0
  191. /package/src/components/molecules/email-form/{EmailForm.oldstories.js → EmailForm.stories.js} +0 -0
  192. /package/src/components/molecules/forgot-password-form/{ForgotPasswordForm.oldstories.js → ForgotPasswordForm.stories.js} +0 -0
  193. /package/src/components/molecules/highlight-tab-row/{HighlightTabRow.oldstories.js → HighlightTabRow.stories.js} +0 -0
  194. /package/src/components/molecules/obligation/modules/{AmountModule.oldstories.js → AmountModule.stories.js} +0 -0
  195. /package/src/components/molecules/payment-button-bar/{PaymentButtonBar.oldstories.js → PaymentButtonBar.stories.js} +0 -0
  196. /package/src/components/molecules/payment-details/{PaymentDetails.oldstories.js → PaymentDetails.stories.js} +0 -0
  197. /package/src/components/molecules/payment-form-ach/{PaymentFormACH.oldstories.js → PaymentFormACH.stories.js} +0 -0
  198. /package/src/components/molecules/payment-form-card/{PaymentFormCard.oldstories.js → PaymentFormCard.stories.js} +0 -0
  199. /package/src/components/molecules/periscope-dashboard-iframe/{PeriscopeDashBoardIframe.oldstories.js → PeriscopeDashBoardIframe.stories.js} +0 -0
  200. /package/src/components/molecules/phone-form/{PhoneForm.oldstories.js → PhoneForm.stories.js} +0 -0
  201. /package/src/components/molecules/popup-menu/{PopupMenu.oldstories.js → PopupMenu.stories.js} +0 -0
  202. /package/src/components/molecules/radio-group/{RadioGroup.oldstories.js → RadioGroup.stories.js} +0 -0
  203. /package/src/components/molecules/radio-section/{RadioSection.oldstories.js → RadioSection.stories.js} +0 -0
  204. /package/src/components/molecules/registration-form/{RegistrationForm.oldstories.js → RegistrationForm.stories.js} +0 -0
  205. /package/src/components/molecules/reset-confirmation-form/{ResetConfirmationForm.oldstories.js → ResetConfirmationForm.stories.js} +0 -0
  206. /package/src/components/molecules/reset-password-form/{ResetPasswordForm.oldstories.js → ResetPasswordForm.stories.js} +0 -0
  207. /package/src/components/molecules/reset-password-success/{ResetPasswordSuccess.oldstories.js → ResetPasswordSuccess.stories.js} +0 -0
  208. /package/src/components/molecules/tab-sidebar/{TabSidebar.oldstories.js → TabSidebar.stories.js} +0 -0
  209. /package/src/components/molecules/terms-and-conditions/{TermsAndConditions.oldstories.js → TermsAndConditions.stories.js} +0 -0
  210. /package/src/components/molecules/terms-and-conditions-modal/{TermsAndConditionsModal.oldstories.js → TermsAndConditionsModal.stories.js} +0 -0
  211. /package/src/components/molecules/workflow-tile/{WorkflowTile.oldstories.js → WorkflowTile.stories.js} +0 -0
@@ -1,130 +1,29 @@
1
- import NavHeader from "./NavHeader";
2
- import { Box, Cover } from "../layouts";
3
- import HamburgerButton from "../hamburger-button";
4
1
  import React from "react";
5
- import { fn } from "@storybook/test";
6
- import ImageBox from "../image-box/ImageBox";
7
- import {
8
- CATSKILL_WHITE,
9
- DUSTY_GREY,
10
- ROYAL_BLUE_VIVID,
11
- SEASHELL_WHITE
12
- } from "../../../constants/colors";
2
+ import { text, number, select } from "@storybook/addon-knobs";
13
3
 
14
- const meta = {
15
- title: "Atoms/NavHeader",
16
- component: NavHeader,
17
- parameters: {
18
- layout: "centered",
19
- controls: { expanded: true }
20
- },
21
- tags: ["!autodocs"],
22
- args: {
23
- leftContent: undefined,
24
- rightContent: undefined,
25
- headerHeight: "105px",
26
- isMobile: false,
27
- backgroundColor: undefined,
28
- headerWidth: undefined
29
- },
30
- argTypes: {
31
- leftContent: {
32
- description: "Content that appears on the left side of the header",
33
- table: {
34
- type: { summary: "React Component" },
35
- defaultValue: { summary: undefined }
36
- }
37
- },
38
- rightContent: {
39
- description: "Content that appears on the right side of the header",
40
- table: {
41
- type: { summary: "React Component" },
42
- defaultValue: { summary: undefined }
43
- }
44
- },
45
- headerHeight: {
46
- description: "Height of the header container in pixels",
47
- table: {
48
- type: { summary: "string" },
49
- defaultValue: { summary: "105px" }
50
- }
51
- },
52
- isMobile: {
53
- description:
54
- "Whether the page is currently displaying on a mobile device",
55
- table: {
56
- type: { summary: "boolean" },
57
- defaultValue: { summary: false }
58
- }
59
- },
60
- backgroundColor: {
61
- description: "Background color of the header",
62
- table: {
63
- type: { summary: "string" },
64
- defaultValue: { summary: undefined }
65
- }
66
- },
67
- headerWidth: {
68
- description:
69
- "Optional value for maximum width of inner container. Component uses 76.5rem or 1224px if not specified. If page is larger than max width, container will be centered within.",
70
- table: {
71
- type: { summary: "string" },
72
- defaultValue: { summary: undefined }
73
- }
74
- }
75
- }
76
- };
4
+ import NavHeader from "./NavHeader";
5
+ import page from "../../../../.storybook/page";
6
+ import * as colors from "../../../constants/colors";
77
7
 
78
- export default meta;
8
+ const story = page({
9
+ title: "Components|Atoms/NavHeader",
10
+ Component: NavHeader
11
+ });
12
+ export default story;
79
13
 
80
- const logo = (
81
- <ImageBox
82
- maxWidth="150px"
83
- minHeight="50px"
84
- image={{
85
- url:
86
- "https://cb-public-assets.s3-us-west-2.amazonaws.com/cityville/logo-blue.svg",
87
- altText: "Cityville Payment Portal Logo"
88
- }}
89
- />
14
+ const Left = () => (
15
+ <div style={{ border: "2px solid black", width: "50px" }}>Left Content</div>
90
16
  );
91
17
 
92
- const hamburger = (
93
- <Box padding="0">
94
- <Cover singleChild fillCenter>
95
- <HamburgerButton
96
- isActive={false}
97
- onClick={() => fn()}
98
- activeColor={ROYAL_BLUE_VIVID}
99
- inactiveColor={ROYAL_BLUE_VIVID}
100
- />
101
- </Cover>
102
- </Box>
18
+ const Right = () => (
19
+ <div style={{ border: "2px solid black", width: "50px" }}>Right Content</div>
103
20
  );
104
21
 
105
- export const BasicHeader = {
106
- render: args => (
107
- <Box minWidth="1200px">
108
- <NavHeader
109
- {...args}
110
- leftContent={logo}
111
- rightContent={hamburger}
112
- backgroundColor={SEASHELL_WHITE}
113
- />
114
- </Box>
115
- )
116
- };
117
-
118
- export const HeaderSmallerThanPage = {
119
- render: args => (
120
- <Box minWidth="1200px" backgroundColor={DUSTY_GREY}>
121
- <NavHeader
122
- {...args}
123
- leftContent={logo}
124
- rightContent={hamburger}
125
- backgroundColor={CATSKILL_WHITE}
126
- headerWidth="800px"
127
- />
128
- </Box>
129
- )
130
- };
22
+ export const navHeader = () => (
23
+ <NavHeader
24
+ leftContent={<Left />}
25
+ rightContent={<Right />}
26
+ headerHeight={text("headerHeight", "105px", "props")}
27
+ backgroundColor={select("activeColor", colors, "white", "props")}
28
+ />
29
+ );
@@ -1,9 +1,10 @@
1
1
  import React from "react";
2
- import { Box, Cluster } from "../layouts";
3
- import { FormInput, FormContainer, FormInputColumn } from "../form-layouts";
2
+ import { boolean } from "@storybook/addon-knobs";
4
3
  import PasswordRequirements from "./PasswordRequirements";
5
- import { connect, Provider } from "react-redux";
6
- import { createStore } from "redux";
4
+ import { FormInput } from "../form-layouts";
5
+ import { Box } from "../layouts";
6
+ import page from "../../../../.storybook/page";
7
+ import { connect } from "react-redux";
7
8
  import {
8
9
  createFormState,
9
10
  required,
@@ -11,11 +12,10 @@ import {
11
12
  hasNumber,
12
13
  hasLowercaseLetter,
13
14
  hasUppercaseLetter,
14
- hasSpecialCharacter,
15
- matchesField
15
+ hasSpecialCharacter
16
16
  } from "redux-freeform";
17
17
 
18
- const { mapStateToProps, mapDispatchToProps, reducer } = createFormState({
18
+ const formConfig = {
19
19
  password: {
20
20
  validators: [
21
21
  required(),
@@ -25,115 +25,51 @@ const { mapStateToProps, mapDispatchToProps, reducer } = createFormState({
25
25
  hasUppercaseLetter(),
26
26
  hasSpecialCharacter()
27
27
  ]
28
- },
29
- confirmPassword: {
30
- validators: [required(), matchesField("password")]
31
28
  }
32
- });
33
-
34
- const store = createStore(
35
- reducer,
36
- window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__()
37
- );
38
-
39
- const passwordErrorMessages = {
40
- [required.error]: "Password field is required.",
41
- [hasLength.error]: "Your password must have at least 8 characters",
42
- [hasNumber.error]: "Your password must contain at least one number",
43
- [hasLowercaseLetter.error]:
44
- "Your password must contain at least one lowercase letter",
45
- [hasUppercaseLetter.error]:
46
- "Your password must contain at least one uppercase letter",
47
- [hasSpecialCharacter.error]:
48
- "Your password must contain at least one special character (!@#$%^&*.?)"
49
- };
50
- const confirmPasswordErrorMessages = {
51
- [matchesField.error]: "Confirm password must match your password"
52
29
  };
53
30
 
54
- const FormWrapper = props => (
55
- <FormContainer
56
- role="form"
57
- aria-label="Change password"
58
- extraStyles={`padding: 0;`}
59
- >
60
- <FormInputColumn>
31
+ const passwordForm = createFormState(formConfig);
32
+
33
+ const passwordRequirementsWrapper = ({ fields, actions, showErrors }) => {
34
+ const passwordErrorMessages = {
35
+ [required.error]: "Password is required",
36
+ [hasLength.error]: "Password must have at least 8 characters",
37
+ [hasNumber.error]: "Password must contain at least one number",
38
+ [hasLowercaseLetter.error]:
39
+ "Password must contain at least one lowercase letter",
40
+ [hasUppercaseLetter.error]:
41
+ "Password must contain at least one uppercase letter",
42
+ [hasSpecialCharacter.error]:
43
+ "Password must contain at least one special character (!@#$%^&*.?)"
44
+ };
45
+ return (
46
+ <Box>
61
47
  <FormInput
62
- labelTextWhenNoError="Password"
48
+ labelTextWhenNoError="Type in password"
63
49
  errorMessages={passwordErrorMessages}
64
- type="password"
65
- field={props.fields.password}
66
- fieldActions={props.actions.fields.password}
67
- />
68
- <FormInput
69
- labelTextWhenNoError="Confirm Password"
70
- errorMessages={confirmPasswordErrorMessages}
71
- type="password"
72
- field={props.fields.confirmPassword}
73
- fieldActions={props.actions.fields.confirmPassword}
50
+ field={fields.password}
51
+ fieldActions={actions.fields.password}
52
+ showErrors={showErrors}
74
53
  />
75
- </FormInputColumn>
76
- <Box padding={props.isMobile ? "1rem 0 0" : "1.5rem 0 0"}>
77
- <Cluster justify="center" align="center">
78
- <PasswordRequirements
79
- isMobile={props.isMobile}
80
- password={props.fields.password}
81
- />
82
- </Cluster>
54
+ <PasswordRequirements password={fields.password} />
83
55
  </Box>
84
- </FormContainer>
85
- );
56
+ );
57
+ };
86
58
 
87
- const ConnectedPasswordRequirements = connect(
88
- mapStateToProps,
89
- mapDispatchToProps
90
- )(FormWrapper);
59
+ const story = page({
60
+ title: "Components|Atoms/PasswordRequirements",
61
+ Component: PasswordRequirements,
62
+ reducer: passwordForm.reducer,
63
+ mapStateToProps: passwordForm.mapStateToProps,
64
+ mapDispatchToProps: passwordForm.mapDispatchToProps
65
+ });
66
+ export default story;
91
67
 
92
- export default {
93
- title: "Atoms/PasswordRequirements",
94
- component: ConnectedPasswordRequirements,
95
- tags: ["!autodocs"],
96
- parameters: {
97
- layout: "centered",
98
- controls: { expanded: true }
99
- },
100
- args: {
101
- password: undefined,
102
- isMobile: false
103
- },
104
- argTypes: {
105
- password: {
106
- description: "A Redux Freeform field for a password",
107
- table: {
108
- type: { summary: "Redux Freeform field object" },
109
- defaultValue: { summary: undefined }
110
- }
111
- },
112
- isMobile: {
113
- description:
114
- "Whether user is on a mobile device (typically screen size <768px)",
115
- table: {
116
- type: { summary: "boolean" },
117
- defaultValue: { summary: false }
118
- }
119
- }
120
- },
121
- decorators: [
122
- Story => (
123
- <Provider store={store}>
124
- <Story />
125
- </Provider>
126
- )
127
- ]
128
- };
68
+ const ConnectedForm = connect(
69
+ passwordForm.mapStateToProps,
70
+ passwordForm.mapDispatchToProps
71
+ )(passwordRequirementsWrapper);
129
72
 
130
- export const BasicPasswordRequirements = args => (
131
- <ConnectedPasswordRequirements {...args} />
73
+ export const passwordRequirements = () => (
74
+ <ConnectedForm showErrors={boolean("showErrors", false, "props")} />
132
75
  );
133
-
134
- export const MobilePasswordRequirements = {
135
- args: {
136
- isMobile: true
137
- },
138
- render: args => <ConnectedPasswordRequirements {...args} />
139
- };
@@ -1,170 +1,42 @@
1
+ import React from "react";
2
+ import { boolean, text, select } from "@storybook/addon-knobs";
1
3
  import Placeholder from "./Placeholder";
2
- import { Box } from "../layouts";
4
+ import page from "../../../../.storybook/page";
3
5
 
4
- const meta = {
5
- title: "Atoms/Placeholder",
6
- component: Placeholder,
7
- parameters: {
8
- layout: "centered"
9
- },
10
- tags: ["!autodocs"],
11
- args: {
12
- text: "Add an Account",
13
- action: undefined,
14
- visible: true,
15
- isLink: false,
16
- destination: "/",
17
- variant: undefined,
18
- largeIcon: undefined,
19
- isDisabled: false
20
- },
21
- argTypes: {
22
- text: {
23
- description: "Text to be displayed inside the Placeholder",
24
- table: {
25
- type: { summary: "string" },
26
- defaultValue: { summary: undefined }
27
- }
28
- },
29
- action: {
30
- description:
31
- "Function to execute when clicking on Placeholder. Only used if isLink is false.",
32
- table: {
33
- type: { summary: "function" },
34
- defaultValue: { summary: undefined }
35
- }
36
- },
37
- visible: {
38
- description: "Whether the Placeholder is visible",
39
- table: {
40
- type: { summary: "boolean" },
41
- defaultValue: { summary: true }
42
- }
43
- },
44
- isLink: {
45
- description:
46
- "Whether the Placeholder links to a destination, instead of using an action",
47
- table: {
48
- type: { summary: "boolean" },
49
- defaultValue: { summary: false }
50
- }
51
- },
52
- variant: {
53
- description: "Variant of the Placeholder either `default` or `large`.",
54
- table: {
55
- type: { summary: "string" },
56
- defaultValue: { summary: "default" }
57
- }
58
- },
59
- largeIcon: {
60
- description:
61
- "Name of icon to use with 'large' Placeholder variant. One of 'accounts', 'properties', or 'payments'. If not provided and Placeholder variant is set to large, will default to 'accounts'."
62
- },
63
- table: {
64
- type: { summary: "string" },
65
- defaultValue: { summary: "accounts" }
66
- },
67
- destination: {
68
- description:
69
- "URL for Placeholder to navigate to if it is a link. Only used if isLink is true.",
70
- table: {
71
- type: { summary: "string" },
72
- defaultValue: { summary: undefined }
73
- }
74
- },
75
- isDisabled: {
76
- description: "Whether the Placeholder is disabled",
77
- table: {
78
- type: { summary: "boolean" },
79
- defaultValue: { summary: false }
80
- }
81
- }
82
- }
6
+ const variantsLabel = "variant";
7
+ const variants = {
8
+ default: "default",
9
+ large: "large"
83
10
  };
11
+ const defaultValue = "default";
12
+ const groupId = "props";
84
13
 
85
- export default meta;
86
-
87
- export const DefaultPlaceholder = {
88
- args: {
89
- action: () => {},
90
- variant: "default"
91
- },
92
- render: args => (
93
- <Box minWidth="400px">
94
- <Placeholder {...args} />
95
- </Box>
96
- )
97
- };
98
-
99
- export const LinkPlaceholder = {
100
- args: {
101
- text: "Add an Email Address",
102
- variant: "default",
103
- isLink: true,
104
- destination: "/"
105
- },
106
- render: args => (
107
- <Box minWidth="400px">
108
- <Placeholder {...args} />
109
- </Box>
110
- )
111
- };
112
-
113
- export const LargePlaceholder = {
114
- args: {
115
- text: "Add or Edit Your Payment Methods",
116
- variant: "large",
117
- largeIcon: "payments",
118
- action: () => {}
119
- },
120
- render: args => (
121
- <Box minWidth="650px">
122
- <Placeholder {...args} />
123
- </Box>
124
- )
14
+ const icons = {
15
+ accounts: "accounts",
16
+ properties: "properties",
17
+ payments: "payments"
125
18
  };
126
19
 
127
- export const LargeLinkPlaceholder = {
128
- args: {
129
- text: "Add New Property",
130
- variant: "large",
131
- largeIcon: "properties",
132
- isLink: true,
133
- destination: "/"
134
- },
135
- render: args => (
136
- <Box minWidth="650px">
137
- <Placeholder {...args} />
138
- </Box>
139
- )
140
- };
141
-
142
- export const DisabledPlaceholder = {
143
- args: {
144
- text: "Edit Payment Information",
145
- action: () => {},
146
- variant: "default",
147
- isDisabled: true,
148
- destination: "/"
149
- },
150
- render: args => (
151
- <Box minWidth="400px">
152
- <Placeholder {...args} />
153
- </Box>
154
- )
155
- };
156
-
157
- export const DisabledLargePlaceholder = {
158
- args: {
159
- text: "Add More to Cart",
160
- variant: "large",
161
- isLink: true,
162
- isDisabled: true,
163
- destination: "/"
164
- },
165
- render: args => (
166
- <Box minWidth="650px">
167
- <Placeholder {...args} />
168
- </Box>
169
- )
170
- };
20
+ const iconLabel = "largeIcon";
21
+
22
+ const defaultIcon = "accounts";
23
+
24
+ export const placeholder = () => (
25
+ <Placeholder
26
+ variant={select(variantsLabel, variants, defaultValue, groupId)}
27
+ isLink={boolean("isLink", true, "props")}
28
+ destination={text("destination", "add-account", "props")}
29
+ text={text("text", "Add an Account", "props")}
30
+ largeIcon={select(iconLabel, icons, defaultIcon, groupId)}
31
+ key="placeholder"
32
+ isDisabled={boolean("isDisabled", false, "props")}
33
+ action={() => console.log("placeholder action")}
34
+ />
35
+ );
36
+
37
+ const story = page({
38
+ title: "Components|Atoms/Placeholder",
39
+ Component: Placeholder
40
+ });
41
+
42
+ export default story;