@thecb/components 2.2.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 (308) hide show
  1. package/.eslintrc.json +29 -0
  2. package/.github/PULL_REQUEST_TEMPLATE.md +18 -0
  3. package/.github/stale.yml +17 -0
  4. package/.prettierignore +3 -0
  5. package/.tool-versions +1 -0
  6. package/README.md +149 -0
  7. package/dist/cb-components.cjs.js +77 -0
  8. package/package.json +96 -0
  9. package/rollup.config.js +35 -0
  10. package/src/components/atoms/alert/Alert.js +67 -0
  11. package/src/components/atoms/alert/Alert.theme.js +71 -0
  12. package/src/components/atoms/alert/index.js +3 -0
  13. package/src/components/atoms/amount-callout/AmountCallout.js +27 -0
  14. package/src/components/atoms/amount-callout/AmountCallout.theme.js +19 -0
  15. package/src/components/atoms/amount-callout/index.js +3 -0
  16. package/src/components/atoms/breadcrumb/Breadcrumb.js +50 -0
  17. package/src/components/atoms/breadcrumb/Breadcrumb.theme.js +25 -0
  18. package/src/components/atoms/breadcrumb/index.js +3 -0
  19. package/src/components/atoms/button-with-action/ButtonWithAction.js +128 -0
  20. package/src/components/atoms/button-with-action/ButtonWithAction.stories.js +125 -0
  21. package/src/components/atoms/button-with-action/ButtonWithAction.theme.js +360 -0
  22. package/src/components/atoms/button-with-action/index.js +3 -0
  23. package/src/components/atoms/button-with-link/ButtonWithLink.js +40 -0
  24. package/src/components/atoms/button-with-link/index.js +3 -0
  25. package/src/components/atoms/checkbox/Checkbox.js +143 -0
  26. package/src/components/atoms/checkbox/Checkbox.theme.js +54 -0
  27. package/src/components/atoms/checkbox/index.js +3 -0
  28. package/src/components/atoms/checkbox-list/CheckboxList.js +129 -0
  29. package/src/components/atoms/checkbox-list/CheckboxList.theme.js +42 -0
  30. package/src/components/atoms/checkbox-list/index.js +3 -0
  31. package/src/components/atoms/country-dropdown/CountryDropdown.js +24 -0
  32. package/src/components/atoms/country-dropdown/index.js +1 -0
  33. package/src/components/atoms/country-dropdown/options.js +249 -0
  34. package/src/components/atoms/display-box/DisplayBox.js +22 -0
  35. package/src/components/atoms/display-box/DisplayBox.theme.js +9 -0
  36. package/src/components/atoms/display-box/index.js +3 -0
  37. package/src/components/atoms/display-card/DisplayCard.js +65 -0
  38. package/src/components/atoms/display-card/index.js +3 -0
  39. package/src/components/atoms/dropdown/Dropdown.js +299 -0
  40. package/src/components/atoms/dropdown/Dropdown.theme.js +9 -0
  41. package/src/components/atoms/dropdown/DropdownIcon.js +31 -0
  42. package/src/components/atoms/dropdown/index.js +3 -0
  43. package/src/components/atoms/form-layouts/FormContainer.js +28 -0
  44. package/src/components/atoms/form-layouts/FormInput.js +218 -0
  45. package/src/components/atoms/form-layouts/FormInputColumn.js +15 -0
  46. package/src/components/atoms/form-layouts/FormInputRow.js +26 -0
  47. package/src/components/atoms/form-layouts/FormLayouts.theme.js +52 -0
  48. package/src/components/atoms/form-layouts/index.js +6 -0
  49. package/src/components/atoms/form-select/FormSelect.js +62 -0
  50. package/src/components/atoms/form-select/FormSelect.styled.js +65 -0
  51. package/src/components/atoms/form-select/index.js +3 -0
  52. package/src/components/atoms/formatted-address/FormattedAddress.js +53 -0
  53. package/src/components/atoms/formatted-address/FormattedAddress.theme.js +11 -0
  54. package/src/components/atoms/formatted-address/index.js +3 -0
  55. package/src/components/atoms/hamburger-button/HamburgerButton.js +113 -0
  56. package/src/components/atoms/hamburger-button/index.js +3 -0
  57. package/src/components/atoms/heading/Heading.js +37 -0
  58. package/src/components/atoms/heading/Heading.styled.js +14 -0
  59. package/src/components/atoms/heading/Heading.theme.js +18 -0
  60. package/src/components/atoms/heading/index.js +3 -0
  61. package/src/components/atoms/icons/AccountsAddIcon.js +42 -0
  62. package/src/components/atoms/icons/AccountsIcon.js +37 -0
  63. package/src/components/atoms/icons/AccountsIconSmall.js +63 -0
  64. package/src/components/atoms/icons/ChevronIcon.js +51 -0
  65. package/src/components/atoms/icons/ForgotPasswordIcon.js +46 -0
  66. package/src/components/atoms/icons/GoToEmailIcon.js +31 -0
  67. package/src/components/atoms/icons/Icons.theme.js +38 -0
  68. package/src/components/atoms/icons/PaymentMethodIcon.js +42 -0
  69. package/src/components/atoms/icons/PaymentsIconSmall.js +63 -0
  70. package/src/components/atoms/icons/ProfileIconSmall.js +44 -0
  71. package/src/components/atoms/icons/PropertiesAddIcon.js +70 -0
  72. package/src/components/atoms/icons/PropertiesIconSmall.js +32 -0
  73. package/src/components/atoms/icons/SettingsIconSmall.js +63 -0
  74. package/src/components/atoms/icons/VerifiedEmailIcon.js +53 -0
  75. package/src/components/atoms/icons/index.js +28 -0
  76. package/src/components/atoms/index.js +33 -0
  77. package/src/components/atoms/labeled-amount/LabeledAmount.js +35 -0
  78. package/src/components/atoms/labeled-amount/LabeledAmount.theme.js +10 -0
  79. package/src/components/atoms/labeled-amount/index.js +3 -0
  80. package/src/components/atoms/layouts/Box.js +83 -0
  81. package/src/components/atoms/layouts/Box.styled.js +131 -0
  82. package/src/components/atoms/layouts/Center.js +28 -0
  83. package/src/components/atoms/layouts/Center.styled.js +18 -0
  84. package/src/components/atoms/layouts/Cluster.js +37 -0
  85. package/src/components/atoms/layouts/Cluster.styled.js +21 -0
  86. package/src/components/atoms/layouts/Cover.js +49 -0
  87. package/src/components/atoms/layouts/Cover.styled.js +29 -0
  88. package/src/components/atoms/layouts/Frame.js +28 -0
  89. package/src/components/atoms/layouts/Frame.styled.js +27 -0
  90. package/src/components/atoms/layouts/Grid.js +38 -0
  91. package/src/components/atoms/layouts/Grid.styled.js +22 -0
  92. package/src/components/atoms/layouts/Imposter.js +52 -0
  93. package/src/components/atoms/layouts/Imposter.styled.js +19 -0
  94. package/src/components/atoms/layouts/Motion.js +51 -0
  95. package/src/components/atoms/layouts/Motion.styled.js +41 -0
  96. package/src/components/atoms/layouts/Reel.js +28 -0
  97. package/src/components/atoms/layouts/Reel.styled.js +17 -0
  98. package/src/components/atoms/layouts/Sidebar.js +42 -0
  99. package/src/components/atoms/layouts/Sidebar.styled.js +38 -0
  100. package/src/components/atoms/layouts/Stack.js +36 -0
  101. package/src/components/atoms/layouts/Stack.styled.js +30 -0
  102. package/src/components/atoms/layouts/Switcher.js +64 -0
  103. package/src/components/atoms/layouts/Switcher.styled.js +44 -0
  104. package/src/components/atoms/layouts/examples/FixedSizeContainer.js +22 -0
  105. package/src/components/atoms/layouts/examples/FixedSizeContainer.styled.js +20 -0
  106. package/src/components/atoms/layouts/examples/LayoutContentBlock.js +27 -0
  107. package/src/components/atoms/layouts/examples/LayoutContentBlock.styled.js +15 -0
  108. package/src/components/atoms/layouts/examples/ResizingContainer.js +49 -0
  109. package/src/components/atoms/layouts/examples/ResizingContainer.styled.js +39 -0
  110. package/src/components/atoms/layouts/examples/cluster-example/ClusterExample.js +10 -0
  111. package/src/components/atoms/layouts/examples/cluster-example/ClusterExample.stories.js +97 -0
  112. package/src/components/atoms/layouts/examples/grid-example/GridExample.js +49 -0
  113. package/src/components/atoms/layouts/examples/grid-example/GridExample.stories.js +44 -0
  114. package/src/components/atoms/layouts/examples/sidebar-example/SidebarExample.js +11 -0
  115. package/src/components/atoms/layouts/examples/sidebar-example/SidebarExample.stories.js +87 -0
  116. package/src/components/atoms/layouts/examples/stack-example/StackExample.js +27 -0
  117. package/src/components/atoms/layouts/examples/stack-example/StackExample.stories.js +69 -0
  118. package/src/components/atoms/layouts/examples/switcher-example/SwitcherExample.js +38 -0
  119. package/src/components/atoms/layouts/examples/switcher-example/SwitcherExample.stories.js +65 -0
  120. package/src/components/atoms/layouts/index.js +27 -0
  121. package/src/components/atoms/line-item/LineItem.js +30 -0
  122. package/src/components/atoms/line-item/LineItem.theme.js +7 -0
  123. package/src/components/atoms/line-item/index.js +3 -0
  124. package/src/components/atoms/link/ExternalLink.js +50 -0
  125. package/src/components/atoms/link/ExternalLink.styled.js +26 -0
  126. package/src/components/atoms/link/InternalLink.js +51 -0
  127. package/src/components/atoms/link/InternalLink.styled.js +39 -0
  128. package/src/components/atoms/link/Link.theme.js +8 -0
  129. package/src/components/atoms/link/index.js +4 -0
  130. package/src/components/atoms/nav-footer/NavFooter.js +57 -0
  131. package/src/components/atoms/nav-footer/index.js +3 -0
  132. package/src/components/atoms/nav-header/NavHeader.js +36 -0
  133. package/src/components/atoms/nav-header/index.js +3 -0
  134. package/src/components/atoms/paragraph/Paragraph.js +31 -0
  135. package/src/components/atoms/paragraph/Paragraph.styled.js +13 -0
  136. package/src/components/atoms/paragraph/Paragraph.theme.js +18 -0
  137. package/src/components/atoms/paragraph/index.js +3 -0
  138. package/src/components/atoms/password-requirements/PasswordRequirements.js +116 -0
  139. package/src/components/atoms/password-requirements/index.js +3 -0
  140. package/src/components/atoms/placeholder/Placeholder.js +122 -0
  141. package/src/components/atoms/placeholder/Placeholder.theme.js +9 -0
  142. package/src/components/atoms/placeholder/index.js +3 -0
  143. package/src/components/atoms/processing-fee/ProcessingFee.js +43 -0
  144. package/src/components/atoms/processing-fee/ProcessingFee.theme.js +7 -0
  145. package/src/components/atoms/processing-fee/index.js +3 -0
  146. package/src/components/atoms/radio-button/RadioButton.js +101 -0
  147. package/src/components/atoms/radio-button/RadioButton.theme.js +9 -0
  148. package/src/components/atoms/radio-button/index.js +3 -0
  149. package/src/components/atoms/solid-divider/SolidDivider.js +22 -0
  150. package/src/components/atoms/solid-divider/SolidDivider.theme.js +8 -0
  151. package/src/components/atoms/solid-divider/index.js +3 -0
  152. package/src/components/atoms/spinner/Spinner.js +61 -0
  153. package/src/components/atoms/spinner/Spinner.theme.js +5 -0
  154. package/src/components/atoms/spinner/index.js +3 -0
  155. package/src/components/atoms/state-province-dropdown/StateProvinceDropdown.js +28 -0
  156. package/src/components/atoms/state-province-dropdown/index.js +3 -0
  157. package/src/components/atoms/state-province-dropdown/options.js +3837 -0
  158. package/src/components/atoms/text/Text.js +37 -0
  159. package/src/components/atoms/text/Text.styled.js +32 -0
  160. package/src/components/atoms/text/Text.theme.js +22 -0
  161. package/src/components/atoms/text/index.js +3 -0
  162. package/src/components/atoms/toggle-switch/ToggleSwitch.js +212 -0
  163. package/src/components/atoms/toggle-switch/ToggleSwitch.theme.js +36 -0
  164. package/src/components/atoms/toggle-switch/index.js +3 -0
  165. package/src/components/index.js +3 -0
  166. package/src/components/molecules/address-form/AddressForm.js +110 -0
  167. package/src/components/molecules/address-form/AddressForm.state.js +52 -0
  168. package/src/components/molecules/address-form/index.js +11 -0
  169. package/src/components/molecules/change-password-form/ChangePasswordForm.js +92 -0
  170. package/src/components/molecules/change-password-form/ChangePasswordForm.state.js +33 -0
  171. package/src/components/molecules/change-password-form/index.js +11 -0
  172. package/src/components/molecules/collapsible-section/CollapsibleSection.js +126 -0
  173. package/src/components/molecules/collapsible-section/CollapsibleSection.theme.js +11 -0
  174. package/src/components/molecules/collapsible-section/index.js +3 -0
  175. package/src/components/molecules/edit-name-form/EditNameForm.js +51 -0
  176. package/src/components/molecules/edit-name-form/EditNameForm.state.js +14 -0
  177. package/src/components/molecules/edit-name-form/index.js +11 -0
  178. package/src/components/molecules/email-form/EmailForm.js +55 -0
  179. package/src/components/molecules/email-form/EmailForm.state.js +19 -0
  180. package/src/components/molecules/email-form/index.js +11 -0
  181. package/src/components/molecules/forgot-password-form/ForgotPasswordForm.js +32 -0
  182. package/src/components/molecules/forgot-password-form/ForgotPasswordForm.state.js +11 -0
  183. package/src/components/molecules/forgot-password-form/index.js +11 -0
  184. package/src/components/molecules/highlight-tab-row/HighlightTabRow.js +62 -0
  185. package/src/components/molecules/highlight-tab-row/HighlightTabRow.theme.js +7 -0
  186. package/src/components/molecules/highlight-tab-row/index.js +8 -0
  187. package/src/components/molecules/index.js +24 -0
  188. package/src/components/molecules/login-form/LoginForm.js +46 -0
  189. package/src/components/molecules/login-form/LoginForm.state.js +14 -0
  190. package/src/components/molecules/login-form/index.js +11 -0
  191. package/src/components/molecules/modal/Modal.js +138 -0
  192. package/src/components/molecules/modal/index.js +3 -0
  193. package/src/components/molecules/module/Module.js +42 -0
  194. package/src/components/molecules/module/Module.theme.js +30 -0
  195. package/src/components/molecules/module/index.js +8 -0
  196. package/src/components/molecules/nav-menu/NavMenu.theme.js +5 -0
  197. package/src/components/molecules/nav-menu/NavMenuDesktop.js +39 -0
  198. package/src/components/molecules/nav-menu/NavMenuMobile.js +63 -0
  199. package/src/components/molecules/nav-menu/index.js +4 -0
  200. package/src/components/molecules/obligation/Obligation.js +69 -0
  201. package/src/components/molecules/obligation/icons/AccountBillIcon.js +89 -0
  202. package/src/components/molecules/obligation/icons/AccountConstructionIcon.js +99 -0
  203. package/src/components/molecules/obligation/icons/AccountDentalIcon.js +94 -0
  204. package/src/components/molecules/obligation/icons/AccountElectricIcon.js +99 -0
  205. package/src/components/molecules/obligation/icons/AccountGarbageIcon.js +94 -0
  206. package/src/components/molecules/obligation/icons/AccountGasIcon.js +94 -0
  207. package/src/components/molecules/obligation/icons/AccountGenericIcon.js +89 -0
  208. package/src/components/molecules/obligation/icons/AccountMedicalIcon.js +94 -0
  209. package/src/components/molecules/obligation/icons/AccountWaterIcon.js +94 -0
  210. package/src/components/molecules/obligation/icons/PropertyApartmentIcon.js +99 -0
  211. package/src/components/molecules/obligation/icons/PropertyBusinessIcon.js +94 -0
  212. package/src/components/molecules/obligation/icons/PropertyCarIcon.js +99 -0
  213. package/src/components/molecules/obligation/icons/PropertyCommercialVehicleIcon.js +100 -0
  214. package/src/components/molecules/obligation/icons/PropertyGarageIcon.js +96 -0
  215. package/src/components/molecules/obligation/icons/PropertyLandIcon.js +99 -0
  216. package/src/components/molecules/obligation/icons/PropertyMotorcycleIcon.js +99 -0
  217. package/src/components/molecules/obligation/icons/PropertyPersonalIcon.js +94 -0
  218. package/src/components/molecules/obligation/icons/PropertyStorefrontIcon.js +100 -0
  219. package/src/components/molecules/obligation/icons/index.js +60 -0
  220. package/src/components/molecules/obligation/index.js +3 -0
  221. package/src/components/molecules/obligation/modules/AmountModule.js +36 -0
  222. package/src/components/molecules/obligation/modules/IconModule.js +29 -0
  223. package/src/components/molecules/obligation/modules/PaymentDetailsActions.js +67 -0
  224. package/src/components/molecules/obligation/modules/TitleModule.js +25 -0
  225. package/src/components/molecules/obligation/modules/index.js +6 -0
  226. package/src/components/molecules/payment-button-bar/PaymentButtonBar.js +80 -0
  227. package/src/components/molecules/payment-button-bar/index.js +3 -0
  228. package/src/components/molecules/payment-details/PaymentDetails.js +158 -0
  229. package/src/components/molecules/payment-details/PaymentDetails.theme.js +11 -0
  230. package/src/components/molecules/payment-details/index.js +1 -0
  231. package/src/components/molecules/phone-form/PhoneForm.js +44 -0
  232. package/src/components/molecules/phone-form/PhoneForm.state.js +17 -0
  233. package/src/components/molecules/phone-form/index.js +11 -0
  234. package/src/components/molecules/radio-section/RadioSection.js +205 -0
  235. package/src/components/molecules/radio-section/RadioSection.theme.js +15 -0
  236. package/src/components/molecules/radio-section/index.js +3 -0
  237. package/src/components/molecules/registration-form/RegistrationForm.js +104 -0
  238. package/src/components/molecules/registration-form/RegistrationForm.state.js +40 -0
  239. package/src/components/molecules/registration-form/index.js +11 -0
  240. package/src/components/molecules/reset-confirmation-form/ResetConfirmationForm.js +56 -0
  241. package/src/components/molecules/reset-confirmation-form/index.js +3 -0
  242. package/src/components/molecules/reset-password-form/ResetPasswordForm.js +67 -0
  243. package/src/components/molecules/reset-password-form/ResetPasswordForm.state.js +30 -0
  244. package/src/components/molecules/reset-password-form/index.js +11 -0
  245. package/src/components/molecules/reset-password-success/ResetPasswordSuccess.js +55 -0
  246. package/src/components/molecules/reset-password-success/index.js +3 -0
  247. package/src/components/molecules/tab-sidebar/TabSidebar.js +92 -0
  248. package/src/components/molecules/tab-sidebar/TabSidebar.theme.js +9 -0
  249. package/src/components/molecules/tab-sidebar/index.js +3 -0
  250. package/src/components/molecules/terms-and-conditions/TermsAndConditions.js +73 -0
  251. package/src/components/molecules/terms-and-conditions/index.js +3 -0
  252. package/src/components/molecules/terms-and-conditions-modal/TermsAndConditionsModal.js +64 -0
  253. package/src/components/molecules/terms-and-conditions-modal/TermsAndConditionsModal.theme.js +28 -0
  254. package/src/components/molecules/terms-and-conditions-modal/index.js +3 -0
  255. package/src/components/molecules/workflow-tile/WorkflowTile.js +58 -0
  256. package/src/components/molecules/workflow-tile/index.js +3 -0
  257. package/src/components/templates/center-single/CenterSingle.js +61 -0
  258. package/src/components/templates/center-single/index.js +3 -0
  259. package/src/components/templates/center-stack/CenterStack.js +49 -0
  260. package/src/components/templates/center-stack/index.js +3 -0
  261. package/src/components/templates/default-page-template/DefaultPageTemplate.js +49 -0
  262. package/src/components/templates/default-page-template/index.js +3 -0
  263. package/src/components/templates/index.js +5 -0
  264. package/src/components/templates/sidebar-single-content/SidebarSingleContent.js +60 -0
  265. package/src/components/templates/sidebar-single-content/index.js +3 -0
  266. package/src/components/templates/sidebar-stack-content/SidebarStackContent.js +81 -0
  267. package/src/components/templates/sidebar-stack-content/index.js +3 -0
  268. package/src/components/templates/templates.theme.js +5 -0
  269. package/src/components/withWindowSize.js +50 -0
  270. package/src/constants/colors.js +178 -0
  271. package/src/constants/regex_constants.js +1 -0
  272. package/src/constants/style_constants.js +21 -0
  273. package/src/deprecated/colors.js +154 -0
  274. package/src/deprecated/components/radio-button/index.js +3 -0
  275. package/src/deprecated/components/radio-button/radio-button.js +44 -0
  276. package/src/deprecated/icons/AlertErrorIcon.js +42 -0
  277. package/src/deprecated/icons/AlertInfoIcon.js +42 -0
  278. package/src/deprecated/icons/AlertSuccessIcon.js +42 -0
  279. package/src/deprecated/icons/AlertWarningIcon.js +36 -0
  280. package/src/deprecated/icons/BankIcon.js +82 -0
  281. package/src/deprecated/icons/GenericCard.js +39 -0
  282. package/src/deprecated/icons/IconAdd.js +44 -0
  283. package/src/deprecated/icons/IconCheck.js +23 -0
  284. package/src/deprecated/icons/IconCheckEmail.js +46 -0
  285. package/src/deprecated/icons/IconChevron.js +35 -0
  286. package/src/deprecated/icons/IconEmailVerified.js +62 -0
  287. package/src/deprecated/icons/IconEye.js +32 -0
  288. package/src/deprecated/icons/IconEyeSlash.js +48 -0
  289. package/src/deprecated/icons/IconInvalid.js +69 -0
  290. package/src/deprecated/icons/IconNeutral.js +27 -0
  291. package/src/deprecated/icons/IconQuit.js +32 -0
  292. package/src/deprecated/icons/IconValid.js +72 -0
  293. package/src/deprecated/icons/IconWarn.js +28 -0
  294. package/src/deprecated/icons/index.js +40 -0
  295. package/src/deprecated/index.js +1 -0
  296. package/src/deprecated/spinner/Spinner.js +68 -0
  297. package/src/deprecated/spinner/index.js +1 -0
  298. package/src/deprecated/utility/__tests__/safeConcat.spec.js +59 -0
  299. package/src/deprecated/utility/__tests__/validateKeyType.spec.js +116 -0
  300. package/src/deprecated/utility/index.js +2 -0
  301. package/src/deprecated/utility/safeConcat.js +10 -0
  302. package/src/deprecated/utility/validateKeyType.js +19 -0
  303. package/src/index.js +2 -0
  304. package/src/util/formats.js +30 -0
  305. package/src/util/general.js +15 -0
  306. package/src/util/inputValidationUtils.js +257 -0
  307. package/src/util/router-utils.js +23 -0
  308. package/src/util/themeUtils.js +144 -0
@@ -0,0 +1,51 @@
1
+ import React, { Fragment } from "react";
2
+ import { MotionWrapper } from "./Motion.styled";
3
+ import { safeChildren } from "../../../util/general";
4
+
5
+ /*
6
+ Catch-all component for creating animations with Framer Motion library
7
+ Wraps the framer motion "motion.div" with styled components and allows for passing
8
+ of style props, like with all the other layout primitives.
9
+
10
+ Compatible with other layout primitives, you can wrap non-animating primitives in a Motion
11
+ to animate items. See the construction of the Collapsible Section and Radio Section for examples.
12
+
13
+ Motion is intentionally more flexible than our other layout primitives - this was done to avoid
14
+ creating motion versions of each primitive. Usually, the correct approach will be to wrap
15
+ other layout primitives with a Motion in order to animate:
16
+
17
+ <Motion>
18
+ <Cluster>
19
+ stuff...
20
+ </Cluster>
21
+ </Motion>
22
+
23
+ Motion components can be nested in order to animate both a primitive container as well as its
24
+ children:
25
+
26
+ <Motion>
27
+ <Stack>
28
+ <Motion>
29
+ <Box>cool stuff</Box>
30
+ </Motion>
31
+ <Motion>
32
+ <Box>other stuff</Box>
33
+ </Motion>
34
+ </Stack>
35
+ </Motion>
36
+
37
+ This should be sufficient for most scenarios, but if you need to, you have the ability to make Motion act like all of the other primitives using the props provided.
38
+ */
39
+
40
+ export const Motion = ({
41
+ position = "relative",
42
+ padding = "0",
43
+ children,
44
+ ...rest
45
+ }) => (
46
+ <MotionWrapper position={position} padding={padding} {...rest}>
47
+ {safeChildren(children, <Fragment />)}
48
+ </MotionWrapper>
49
+ );
50
+
51
+ export default Motion;
@@ -0,0 +1,41 @@
1
+ import styled from "styled-components";
2
+ import { motion } from "framer-motion";
3
+
4
+ export const MotionWrapper = styled(motion.div)`
5
+ position: ${({ position }) => position};
6
+ display: ${({ display }) => display};
7
+ box-sizing: border-box;
8
+ padding: ${({ padding }) => padding};
9
+ border: ${({ borderShorthand }) => borderShorthand};
10
+ border-color: ${({ borderColor }) => borderColor};
11
+ border-size: ${({ borderSize }) => borderSize};
12
+ border-style: ${({ borderStyle }) => borderStyle};
13
+ border-width: ${({ borderWidth }) => borderWidth};
14
+ border-radius: ${({ borderRadius }) => borderRadius};
15
+ background-color: ${({ backgroundColor }) => backgroundColor};
16
+ box-shadow: ${({ boxShadow }) => boxShadow};
17
+ min-height: ${({ minHeight }) => minHeight};
18
+ min-width: ${({ minWidth }) => minWidth};
19
+ height: ${({ height }) => height};
20
+ width: ${({ width }) => width};
21
+ text-align: ${({ textAlign }) => textAlign};
22
+ margin: ${({ margin }) => margin};
23
+
24
+ &:hover {
25
+ ${({ hoverStyles }) => hoverStyles};
26
+ }
27
+
28
+ &:active {
29
+ ${({ activeStyles }) => activeStyles};
30
+ }
31
+
32
+ &:focus {
33
+ ${({ focusStyles }) => focusStyles};
34
+ }
35
+
36
+ &:disabled {
37
+ ${({ disabledStyles }) => disabledStyles};
38
+ }
39
+
40
+ ${({ extraStyles }) => extraStyles};
41
+ `;
@@ -0,0 +1,28 @@
1
+ import React, { Fragment } from "react";
2
+ import { safeChildren } from "../../../util/general";
3
+ import { ReelStyled } from "./Reel.styled";
4
+
5
+ const Reel = ({
6
+ childGap = "1rem",
7
+ height = "auto",
8
+ childWidth = "auto",
9
+ padding = "1rem",
10
+ justifyContent = "flex-start",
11
+ disableScroll = false,
12
+ children,
13
+ ...rest
14
+ }) => (
15
+ <ReelStyled
16
+ childGap={childGap}
17
+ height={height}
18
+ childWidth={childWidth}
19
+ padding={padding}
20
+ justifyContent={justifyContent}
21
+ disableScroll={disableScroll}
22
+ {...rest}
23
+ >
24
+ {safeChildren(children, <Fragment />)}
25
+ </ReelStyled>
26
+ );
27
+
28
+ export default Reel;
@@ -0,0 +1,17 @@
1
+ import styled from "styled-components";
2
+
3
+ export const ReelStyled = styled.div`
4
+ display: flex;
5
+ overflow-x: ${({ disableScroll }) => (disableScroll ? "hidden" : "auto")};
6
+ padding: ${({ padding }) => padding};
7
+ height: ${({ height }) => height};
8
+ justify-content: ${({ justifyContent }) => justifyContent};
9
+
10
+ > * + * {
11
+ margin-left: ${({ childGap }) => childGap};
12
+ }
13
+
14
+ > * {
15
+ flex: 0 0 ${({ childWidth }) => childWidth};
16
+ }
17
+ `;
@@ -0,0 +1,42 @@
1
+ import React, { Fragment } from "react";
2
+ import { SidebarWrapper, SidebarInnerWrapper } from "./Sidebar.styled";
3
+ import { safeChildren } from "../../../util/general";
4
+
5
+ /*
6
+ Component to assist in creating layouts with some element and a sidebar next to it
7
+ Sidebar takes a width value, this is the ideal target with, and what the sidebar
8
+ will be sized to on larger/medium screens
9
+
10
+ The component also takes a content minimum width, this should be a percentage
11
+ it represents the narrowest the content piece can get before the sidebar wraps to
12
+ the top of the layout. If not supplied, the sidebar will size to the width of its content.
13
+
14
+ This can be used for many use cases beyond the typical content/sidebar layout
15
+ Such as for pinning a button/icon next to a form input
16
+ */
17
+
18
+ const Sidebar = ({
19
+ childGap = "1rem",
20
+ width,
21
+ onRight = false,
22
+ contentMinWidth = "50%",
23
+ fullHeight = false,
24
+ minHeight,
25
+ children,
26
+ ...rest
27
+ }) => (
28
+ <SidebarWrapper fullHeight={fullHeight} minHeight={minHeight} {...rest}>
29
+ <SidebarInnerWrapper
30
+ childGap={childGap}
31
+ width={width}
32
+ onRight={onRight}
33
+ contentMinWidth={contentMinWidth}
34
+ fullHeight={fullHeight}
35
+ minHeight={minHeight}
36
+ >
37
+ {safeChildren(children, <Fragment />)}
38
+ </SidebarInnerWrapper>
39
+ </SidebarWrapper>
40
+ );
41
+
42
+ export default Sidebar;
@@ -0,0 +1,38 @@
1
+ import styled from "styled-components";
2
+
3
+ export const SidebarWrapper = styled.div`
4
+ overflow: visible;
5
+ box-sizing: border-box;
6
+
7
+ ${({ fullHeight }) => (fullHeight ? `height: 100%;` : ``)}
8
+ `;
9
+
10
+ export const SidebarInnerWrapper = styled.div`
11
+ display: flex;
12
+ flex-wrap: wrap;
13
+ box-sizing: border-box;
14
+ margin: calc(${({ childGap }) => childGap} / 2 * -1);
15
+
16
+ > * {
17
+ margin: calc(${({ childGap }) => childGap} / 2);
18
+ flex-grow: 1;
19
+ ${({ width }) => (width ? `flex-basis: ${width}` : ``)};
20
+ ${({ minHeight }) => (minHeight ? `margin-top: 0; margin-bottom: 0;` : ``)}
21
+ }
22
+
23
+ ${({ onRight, contentMinWidth, childGap }) =>
24
+ onRight
25
+ ? `> :first-child {
26
+ flex-basis: 0;
27
+ flex-grow: 999;
28
+ min-width: calc(${contentMinWidth} - ${childGap});
29
+ }
30
+ `
31
+ : `> :last-child {
32
+ flex-basis: 0;
33
+ flex-grow: 999;
34
+ min-width: calc(${contentMinWidth} - ${childGap});
35
+ }`}
36
+
37
+ ${({ fullHeight }) => (fullHeight ? `min-height: 100%;` : ``)}
38
+ `;
@@ -0,0 +1,36 @@
1
+ import React, { Fragment } from "react";
2
+ import { StackWrapper } from "./Stack.styled";
3
+ import { safeChildren } from "../../../util/general";
4
+
5
+ /*
6
+ Component to impose margin-top between a list of child elements
7
+ Useful for things like sidebars and button lists
8
+ Avoids common pitfalls like having to manually adjust the margin
9
+ on first/last children
10
+
11
+ For more information and diagrams:
12
+ https://every-layout.dev/layouts/stack/
13
+ */
14
+
15
+ const Stack = ({
16
+ childGap = "1rem",
17
+ bottomItem,
18
+ fullHeight = false,
19
+ children,
20
+ direction = "column",
21
+ justify,
22
+ ...rest
23
+ }) => (
24
+ <StackWrapper
25
+ childGap={childGap}
26
+ bottomItem={bottomItem}
27
+ fullHeight={fullHeight}
28
+ direction={direction}
29
+ justify={justify}
30
+ {...rest}
31
+ >
32
+ {safeChildren(children, <Fragment />)}
33
+ </StackWrapper>
34
+ );
35
+
36
+ export default Stack;
@@ -0,0 +1,30 @@
1
+ import styled from "styled-components";
2
+
3
+ export const StackWrapper = styled.div`
4
+ box-sizing: border-box;
5
+ display: flex;
6
+ flex-direction: ${({ direction }) => direction};
7
+ justify-content: ${({ justify }) => (justify ? justify : "flex-start")};
8
+ height: ${({ fullHeight }) => (fullHeight ? "100%" : "auto")};
9
+
10
+ > * {
11
+ margin-top: 0;
12
+ margin-bottom: 0;
13
+ }
14
+
15
+ > * + * {
16
+ ${({ direction, childGap }) =>
17
+ direction === "row"
18
+ ? `margin-left: ${childGap};`
19
+ : `margin-top: ${childGap};`}
20
+ }
21
+
22
+ ${({ bottomItem, direction }) =>
23
+ bottomItem
24
+ ? `
25
+ > :nth-child(${bottomItem}) {
26
+ ${direction === "row" ? "margin-left: auto;" : "margin-top: auto;"}
27
+ }
28
+ `
29
+ : ``};
30
+ `;
@@ -0,0 +1,64 @@
1
+ import React, { Fragment } from "react";
2
+ import { safeChildren } from "../../../util/general";
3
+ import {
4
+ SwitcherOuterContainer,
5
+ SwitcherInnerContainer
6
+ } from "./Switcher.styled";
7
+
8
+ /*
9
+ The Switcher is a component that is used to toggle between wide and narrow
10
+ layouts based on the size of the surrounding container. In the wide layout,
11
+ the children of the Switcher will be sized to the value specified by childSize.
12
+ The point at which the layout switches is specified by the breakpoint prop.
13
+ The space between child elements is specified with
14
+
15
+ In the wide layout, it is possible to specify that a particular child take up
16
+ more space than its siblings. The largeChild prop takes a child number and
17
+ applies the largeChildSize to its flex-grow property.
18
+
19
+ This component also accepts an optional maxChildren prop. This prop specifies the max
20
+ number of children allowed before the component toggles to a vertical list
21
+ layout.
22
+
23
+ In the narrow layout, the children of the Switcher will render as a vertical list
24
+ of width: 100%. This component is best used for scenarios when you want to bypass
25
+ intermediate layouts where children may size differently depending on the number of
26
+ children present in a given row.
27
+
28
+ Use cases for this component include any situation "in which each child element
29
+ should be considered equal, or part of a continuum. E.g., card components listing
30
+ products/services should share the same width no matter the orientation, otherwise
31
+ one or more cards could be perceived as highlighted or featured in some way. Or
32
+ a set of numbered steps in, for example, a list of items to complete or tasks to do."
33
+ */
34
+
35
+ const Switcher = ({
36
+ breakpoint = "30rem",
37
+ childGap = "1rem",
38
+ largeChild,
39
+ largeChildSize,
40
+ maxChildren,
41
+ maxChildrenOnly = false,
42
+ padding = "0",
43
+ children,
44
+ extraStyles,
45
+ ...rest
46
+ }) => (
47
+ <SwitcherOuterContainer>
48
+ <SwitcherInnerContainer
49
+ breakpoint={breakpoint}
50
+ childGap={childGap}
51
+ largeChild={largeChild}
52
+ largeChildSize={largeChildSize}
53
+ maxChildren={maxChildren}
54
+ maxChildrenOnly={maxChildrenOnly}
55
+ padding={padding}
56
+ extraStyles={extraStyles}
57
+ {...rest}
58
+ >
59
+ {safeChildren(children, <Fragment />)}
60
+ </SwitcherInnerContainer>
61
+ </SwitcherOuterContainer>
62
+ );
63
+
64
+ export default Switcher;
@@ -0,0 +1,44 @@
1
+ import styled, { css } from "styled-components";
2
+
3
+ export const SwitcherOuterContainer = styled.div`
4
+ box-sizing: border-box;
5
+ display: block;
6
+ `;
7
+
8
+ export const SwitcherInnerContainer = styled.div`
9
+ box-sizing: border-box;
10
+ display: flex;
11
+ flex-wrap: wrap;
12
+ overflow: hidden;
13
+ padding: ${({ padding }) => padding};
14
+ margin: ${({ childGap }) => `calc((${childGap} / 2) * -1)`};
15
+
16
+ > * {
17
+ flex-grow: 1;
18
+ ${({ maxChildrenOnly, breakpoint, childGap }) =>
19
+ !maxChildrenOnly
20
+ ? `flex-basis: calc((${breakpoint} - (100% - ${childGap})) * 999);`
21
+ : ``};
22
+ ${({ childGap }) => `margin: calc(${childGap} / 2);`}
23
+ }
24
+
25
+ ${({ largeChild, largeChildSize }) =>
26
+ largeChild && largeChildSize
27
+ ? `> :nth-child(${largeChild}) {
28
+ flex-grow: ${largeChildSize};
29
+ }`
30
+ : ``}
31
+
32
+ ${({ maxChildren }) =>
33
+ maxChildren
34
+ ? `> :nth-last-child(${maxChildren +
35
+ 1}), > :nth-last-child(${maxChildren + 1}) ~ * {
36
+ flex-basis: 100%;
37
+ }`
38
+ : ``}
39
+
40
+ ${({ extraStyles }) =>
41
+ css`
42
+ ${extraStyles}
43
+ `}
44
+ `;
@@ -0,0 +1,22 @@
1
+ import React, { Fragment } from "react";
2
+ import { FixedSize, FloatingLabel } from "./FixedSizeContainer.styled";
3
+ import { safeChildren } from "../../../../util/general";
4
+ import { TROUT_GREY } from "../../../../constants/colors";
5
+
6
+ const FixedSizeContainer = ({
7
+ width,
8
+ height = "auto",
9
+ border = `2px solid ${TROUT_GREY}`,
10
+ floatingLabel,
11
+ margin,
12
+ children
13
+ }) => (
14
+ <FixedSize width={width} height={height} border={border} margin={margin}>
15
+ {safeChildren(children)}
16
+ <Fragment>
17
+ <FloatingLabel>{floatingLabel}</FloatingLabel>
18
+ </Fragment>
19
+ </FixedSize>
20
+ );
21
+
22
+ export default FixedSizeContainer;
@@ -0,0 +1,20 @@
1
+ import styled from "styled-components";
2
+ import { TROUT_GREY } from "../../../../constants/colors";
3
+
4
+ export const FixedSize = styled.div`
5
+ box-sizing: border-box;
6
+ width: ${({ width }) => width};
7
+ height: ${({ height }) => height};
8
+ padding: 0.5rem;
9
+ border: ${({ border }) => border};
10
+ border-radius: 4px;
11
+ position: relative;
12
+ margin: ${({ margin }) => margin};
13
+ `;
14
+
15
+ export const FloatingLabel = styled.p`
16
+ position: absolute;
17
+ left: 0.5rem;
18
+ font-size: 1rem;
19
+ color: ${TROUT_GREY};
20
+ `;
@@ -0,0 +1,27 @@
1
+ import React from "react";
2
+ import { LayoutBlock } from "./LayoutContentBlock.styled";
3
+ import Text from "../../text";
4
+
5
+ const LayoutContentBlock = ({
6
+ layoutName,
7
+ bgColor = "#AAA",
8
+ textColor = "#111",
9
+ borderColor = "#666",
10
+ width = "100%",
11
+ height = "auto",
12
+ padding = "1rem",
13
+ margin
14
+ }) => (
15
+ <LayoutBlock
16
+ width={width}
17
+ height={height}
18
+ bgColor={bgColor}
19
+ borderColor={borderColor}
20
+ padding={padding}
21
+ margin={margin}
22
+ >
23
+ <Text color={textColor}>{layoutName}</Text>
24
+ </LayoutBlock>
25
+ );
26
+
27
+ export default LayoutContentBlock;
@@ -0,0 +1,15 @@
1
+ import styled from "styled-components";
2
+
3
+ export const LayoutBlock = styled.div`
4
+ box-sizing: border-box;
5
+ width: ${({ width }) => width};
6
+ height: ${({ height }) => height};
7
+ background-color: ${({ bgColor }) => bgColor};
8
+ border: 2px solid ${({ borderColor }) => borderColor};
9
+ display: flex;
10
+ justify-content: center;
11
+ align-items: center;
12
+ padding: ${({ padding }) => padding};
13
+ max-width: 100%;
14
+ margin: ${({ margin }) => margin};
15
+ `;
@@ -0,0 +1,49 @@
1
+ import React, { useState, useRef, useEffect, Fragment } from "react";
2
+ import {
3
+ ResizeOuterContainer,
4
+ ResizeInnerContainer
5
+ } from "./ResizingContainer.styled";
6
+ import { safeChildren } from "../../../../util/general";
7
+
8
+ const ResizeContainer = ({
9
+ children,
10
+ animate = "pause",
11
+ containerMax = "500px",
12
+ containerMin = "100%",
13
+ padding = "0.5rem"
14
+ }) => {
15
+ const ref = useRef();
16
+ const [width, setWidth] = useState(0);
17
+ useEffect(() => {
18
+ const resizeObserver = new ResizeObserver(entries => {
19
+ if (!Array.isArray(entries)) {
20
+ return;
21
+ }
22
+ if (!entries.length) {
23
+ return;
24
+ }
25
+ const entry = entries[0];
26
+ setWidth(entry.contentRect.width);
27
+ });
28
+
29
+ resizeObserver.observe(ref.current);
30
+
31
+ return () => resizeObserver.unobserve(ref.current);
32
+ }, []);
33
+ console.warn("width is", width);
34
+ return (
35
+ <ResizeOuterContainer>
36
+ <ResizeInnerContainer
37
+ ref={ref}
38
+ animate={animate}
39
+ containerMax={containerMax}
40
+ containerMin={containerMin}
41
+ padding={padding}
42
+ >
43
+ {safeChildren(children, <Fragment />)}
44
+ </ResizeInnerContainer>
45
+ </ResizeOuterContainer>
46
+ );
47
+ };
48
+
49
+ export default ResizeContainer;
@@ -0,0 +1,39 @@
1
+ import styled, { keyframes, css } from "styled-components";
2
+ import { TROUT_GREY } from "../../../../constants/colors";
3
+
4
+ const squeeze = (containerMin, containerMax) => keyframes`
5
+ 0% {
6
+ width: ${containerMax};
7
+ }
8
+ 100% {
9
+ width: ${containerMin};
10
+ }
11
+ `;
12
+
13
+ export const ResizeOuterContainer = styled.div`
14
+ display: flex;
15
+ flex-direction: column;
16
+ width: 100%;
17
+ box-sizing: border-box;
18
+ `;
19
+
20
+ export const ResizeInnerContainer = styled.div`
21
+ border: 2px solid ${TROUT_GREY};
22
+ padding: ${({ padding }) => padding};
23
+ box-sizing: border-box;
24
+ margin-left: auto;
25
+ margin-right: auto;
26
+ height: auto;
27
+ overflow-y: auto;
28
+ display: flex;
29
+ flex-direction: column;
30
+ justify-content: center;
31
+ width: ${({ containerMax }) => containerMax};
32
+ ${({ animate, containerMin, containerMax }) =>
33
+ animate === "play"
34
+ ? css`
35
+ animation: 5s linear infinite alternate
36
+ ${squeeze(containerMin, containerMax)};
37
+ `
38
+ : ``};
39
+ `;
@@ -0,0 +1,10 @@
1
+ import React from "react";
2
+ import Cluster from "../../Cluster";
3
+
4
+ const ClusterExample = ({ justify, align, children }) => (
5
+ <Cluster justify={justify} align={align} childGap="1rem">
6
+ {children}
7
+ </Cluster>
8
+ );
9
+
10
+ export default ClusterExample;
@@ -0,0 +1,97 @@
1
+ import React from "react";
2
+ import { withKnobs, text, radios } from "@storybook/addon-knobs";
3
+ import ClusterExample from "./ClusterExample";
4
+ import Cover from "../../Cover";
5
+ import Center from "../../Center";
6
+ import FixedSizeContainer from "../FixedSizeContainer";
7
+ import ResizingContainer from "../ResizingContainer";
8
+ import LayoutContentBlock from "../LayoutContentBlock";
9
+
10
+ export default {
11
+ title: "Layouts|Basic Layouts/Cluster",
12
+ component: ClusterExample,
13
+ decorators: [
14
+ withKnobs,
15
+ storyFn => (
16
+ <Cover>
17
+ <div />
18
+ <Center>{storyFn()}</Center>
19
+ <div />
20
+ </Cover>
21
+ )
22
+ ]
23
+ };
24
+
25
+ const label = "Animate";
26
+ const options = {
27
+ play: "play",
28
+ pause: "pause"
29
+ };
30
+ const defaultValue = "pause";
31
+ const groupID = "RADIO-GROUP-1";
32
+
33
+ export const basicCluster = () => (
34
+ <ResizingContainer
35
+ animate={radios(label, options, defaultValue, groupID)}
36
+ containerMax={text("Container Max", "60rem")}
37
+ containerMin={text("Container Min", "20rem")}
38
+ >
39
+ <ClusterExample justify="space-between" align="center">
40
+ <LayoutContentBlock height="3.5rem" width="8rem" layoutName="City Logo" />
41
+ <ClusterExample justify="flex-start" align="center">
42
+ <LayoutContentBlock
43
+ height="2.5rem"
44
+ width="4.5rem"
45
+ layoutName="Profile"
46
+ />
47
+ <LayoutContentBlock
48
+ height="2.5rem"
49
+ width="4.5rem"
50
+ layoutName="Settings"
51
+ />
52
+ <LayoutContentBlock
53
+ height="2.5rem"
54
+ width="4.5rem"
55
+ layoutName="Accounts"
56
+ />
57
+ </ClusterExample>
58
+ </ClusterExample>
59
+ </ResizingContainer>
60
+ );
61
+
62
+ basicCluster.story = {
63
+ name: "Resizing Nav Cluster"
64
+ };
65
+
66
+ export const formButtonCluster = () => (
67
+ <FixedSizeContainer
68
+ width={text("Container Width", "40rem")}
69
+ floatingLabel="Cluster"
70
+ >
71
+ <ClusterExample justify="flex-end" align="center">
72
+ <LayoutContentBlock height="3rem" width="6rem" layoutName="Back" />
73
+ <LayoutContentBlock height="3rem" width="6rem" layoutName="Submit" />
74
+ </ClusterExample>
75
+ </FixedSizeContainer>
76
+ );
77
+
78
+ formButtonCluster.story = {
79
+ name: "Form Button Cluster"
80
+ };
81
+
82
+ export const formInputCluster = () => (
83
+ <ResizingContainer
84
+ animate={radios(label, options, defaultValue, groupID)}
85
+ containerMax={text("Container Max", "40rem")}
86
+ containerMin={text("Container Min", "20rem")}
87
+ >
88
+ <ClusterExample justify="flex-start" align="center">
89
+ <LayoutContentBlock height="1.5rem" width="3rem" layoutName="Label" />
90
+ <LayoutContentBlock height="3rem" width="20rem" layoutName="Form Input" />
91
+ </ClusterExample>
92
+ </ResizingContainer>
93
+ );
94
+
95
+ formInputCluster.story = {
96
+ name: "Form Input Cluster"
97
+ };