@thecb/components 10.12.6 → 11.0.0-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 (179) hide show
  1. package/README.md +14 -6
  2. package/dist/index.cjs.js +1309 -1481
  3. package/dist/index.cjs.js.map +1 -1
  4. package/dist/index.esm.js +1309 -1482
  5. package/dist/index.esm.js.map +1 -1
  6. package/package.json +25 -13
  7. package/src/.DS_Store +0 -0
  8. package/src/components/.DS_Store +0 -0
  9. package/src/components/atoms/.DS_Store +0 -0
  10. package/src/components/atoms/alert/Alert.mdx +19 -0
  11. package/src/components/atoms/alert/Alert.stories.js +148 -26
  12. package/src/components/atoms/badge/Badge.js +2 -2
  13. package/src/components/atoms/badge/Badge.mdx +27 -0
  14. package/src/components/atoms/badge/Badge.stories.js +143 -29
  15. package/src/components/atoms/breadcrumb/Breadcrumb.mdx +21 -0
  16. package/src/components/atoms/breadcrumb/Breadcrumb.stories.js +38 -29
  17. package/src/components/atoms/button-with-action/ButtonWithAction.stories.js +108 -55
  18. package/src/components/atoms/button-with-link/ButtonWithLink.mdx +21 -0
  19. package/src/components/atoms/button-with-link/ButtonWithLink.stories.js +160 -31
  20. package/src/components/atoms/card/Card.mdx +41 -0
  21. package/src/components/atoms/card/Card.stories.js +351 -0
  22. package/src/components/atoms/checkbox/Checkbox.mdx +15 -0
  23. package/src/components/atoms/checkbox/Checkbox.oldstories.js +34 -0
  24. package/src/components/atoms/checkbox/Checkbox.stories.js +140 -25
  25. package/src/components/atoms/country-dropdown/CountryDropdown.mdx +36 -0
  26. package/src/components/atoms/country-dropdown/CountryDropdown.stories.js +61 -27
  27. package/src/components/atoms/detail/Detail.js +0 -26
  28. package/src/components/atoms/detail/Detail.mdx +32 -0
  29. package/src/components/atoms/detail/Detail.stories.js +156 -0
  30. package/src/components/atoms/display-box/DisplayBox.mdx +11 -0
  31. package/src/components/atoms/display-box/DisplayBox.stories.js +65 -21
  32. package/src/components/atoms/display-card/DisplayCard.mdx +13 -0
  33. package/src/components/atoms/display-card/DisplayCard.stories.js +163 -22
  34. package/src/components/atoms/dropdown/Dropdown.mdx +65 -0
  35. package/src/components/atoms/dropdown/Dropdown.stories.js +91 -10
  36. package/src/components/atoms/form-layouts/FormInput.mdx +38 -0
  37. package/src/components/atoms/form-layouts/FormInput.stories.js +212 -26
  38. package/src/components/atoms/form-select/FormSelect.mdx +42 -0
  39. package/src/components/atoms/form-select/FormSelect.stories.js +55 -29
  40. package/src/components/atoms/formatted-address/FormattedAddress.mdx +13 -0
  41. package/src/components/atoms/formatted-address/FormattedAddress.stories.js +133 -27
  42. package/src/components/atoms/formatted-bank-account/FormattedBankAccount.mdx +17 -0
  43. package/src/components/atoms/formatted-bank-account/FormattedBankAccount.stories.js +57 -0
  44. package/src/components/atoms/formatted-credit-card/FormattedCreditCard.mdx +40 -0
  45. package/src/components/atoms/formatted-credit-card/FormattedCreditCard.stories.js +74 -0
  46. package/src/components/atoms/icons/Icons.mdx +40 -0
  47. package/src/components/atoms/icons/Icons.stories.js +325 -0
  48. package/src/components/atoms/labeled-amount/LabeledAmount.mdx +23 -0
  49. package/src/components/atoms/labeled-amount/LabeledAmount.stories.js +110 -34
  50. package/src/components/atoms/line-item/LineItem.mdx +28 -0
  51. package/src/components/atoms/line-item/LineItem.stories.js +89 -22
  52. package/src/components/atoms/link/Link.mdx +19 -0
  53. package/src/components/atoms/link/Link.stories.js +155 -49
  54. package/src/components/atoms/loading/Loading.mdx +13 -0
  55. package/src/components/atoms/loading/Loading.stories.js +22 -0
  56. package/src/components/atoms/loading-line/LoadingLine.js +14 -10
  57. package/src/components/atoms/loading-line/LoadingLine.mdx +15 -0
  58. package/src/components/atoms/loading-line/LoadingLine.stories.js +132 -28
  59. package/src/components/atoms/nav-footer/.DS_Store +0 -0
  60. package/src/components/atoms/nav-footer/NavFooter.mdx +15 -0
  61. package/src/components/atoms/nav-footer/NavFooter.stories.js +235 -22
  62. package/src/components/atoms/nav-header/NavHeader.mdx +13 -0
  63. package/src/components/atoms/nav-header/NavHeader.stories.js +122 -21
  64. package/src/components/atoms/nav-tabs/NavTabs.mdx +30 -0
  65. package/src/components/atoms/nav-tabs/NavTabs.stories.js +49 -0
  66. package/src/components/atoms/password-requirements/PasswordRequirements.mdx +39 -0
  67. package/src/components/atoms/password-requirements/PasswordRequirements.stories.js +108 -44
  68. package/src/components/atoms/placeholder/Placeholder.mdx +19 -0
  69. package/src/components/atoms/placeholder/Placeholder.stories.js +164 -36
  70. package/src/components/atoms/searchable-select/SearchableSelect.mdx +44 -0
  71. package/src/components/atoms/searchable-select/SearchableSelect.stories.js +103 -28
  72. package/src/components/atoms/state-province-dropdown/StateProvinceDropdown.mdx +36 -0
  73. package/src/components/atoms/state-province-dropdown/StateProvinceDropdown.stories.js +65 -40
  74. package/src/components/atoms/table/Table.mdx +71 -0
  75. package/src/components/atoms/table/Table.oldstories.js +84 -0
  76. package/src/components/atoms/table/Table.stories.js +59 -75
  77. package/src/components/atoms/table/TableRow.js +1 -0
  78. package/src/components/atoms/title/Title.js +0 -23
  79. package/src/components/atoms/title/Title.mdx +26 -0
  80. package/src/components/atoms/title/Title.stories.js +144 -0
  81. package/src/components/atoms/toggle-switch/ToggleSwitch.mdx +17 -0
  82. package/src/components/atoms/toggle-switch/ToggleSwitch.stories.js +103 -20
  83. package/src/components/atoms/toggle-switch/ToggleSwitch.theme.js +8 -5
  84. package/src/components/atoms/typeahead-input/TypeaheadInput.mdx +13 -0
  85. package/src/components/atoms/typeahead-input/TypeaheadInput.stories.js +63 -0
  86. package/src/components/molecules/.DS_Store +0 -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/obligation/.DS_Store +0 -0
  112. package/src/components/molecules/obligation/Obligation.mdx +23 -0
  113. package/src/components/molecules/obligation/Obligation.stories.js +460 -0
  114. package/src/components/molecules/obligation/icons/PropertyPersonalIcon.js +1 -1
  115. package/src/components/molecules/pagination/Pagination.mdx +15 -0
  116. package/src/components/molecules/pagination/Pagination.stories.js +177 -28
  117. package/src/components/molecules/popover/Popover.mdx +15 -0
  118. package/src/components/molecules/popover/Popover.stories.js +220 -0
  119. package/src/components/molecules/tabs/Tabs.mdx +17 -0
  120. package/src/components/molecules/tabs/Tabs.stories.js +135 -227
  121. package/src/components/molecules/toast-notification/Toast.mdx +15 -0
  122. package/src/components/molecules/toast-notification/Toast.stories.js +183 -0
  123. package/src/util/idleTimerUtils.js +36 -0
  124. package/src/util/index.js +3 -1
  125. package/src/components/molecules/edit-name-form/EdidNameForm.stories.js +0 -24
  126. package/src/components/molecules/toast-notification/ToastNotification.stories.js +0 -105
  127. /package/src/components/atoms/add-obligation/{AddObligation.stories.js → AddObligation.oldstories.js} +0 -0
  128. /package/src/components/atoms/amount-callout/{AmountCallout.stories.js → AmountCallout.oldstories.js} +0 -0
  129. /package/src/components/atoms/checkbox-list/{CheckboxList.stories.js → CheckboxList.oldstories.js} +0 -0
  130. /package/src/components/atoms/form-layouts/{FormLayouts.stories.js → FormLayouts.oldstories.js} +0 -0
  131. /package/src/components/atoms/hamburger-button/{HamburgerButton.stories.js → HamburgerButton.oldstories.js} +0 -0
  132. /package/src/components/atoms/heading/{Heading.stories.js → Heading.oldstories.js} +0 -0
  133. /package/src/components/atoms/icons/{icons.stories.js → icons.oldstories.js} +0 -0
  134. /package/src/components/atoms/layouts/examples/box-example/{BoxExample.stories.js → BoxExample.oldstories.js} +0 -0
  135. /package/src/components/atoms/layouts/examples/center-example/{CenterExample.stories.js → CenterExample.oldstories.js} +0 -0
  136. /package/src/components/atoms/layouts/examples/cluster-example/{ClusterExample.stories.js → ClusterExample.oldstories.js} +0 -0
  137. /package/src/components/atoms/layouts/examples/cover-example/{CoverExample.stories.js → CoverExample.oldstories.js} +0 -0
  138. /package/src/components/atoms/layouts/examples/frame-example/{FrameExample.stories.js → FrameExample.oldstories.js} +0 -0
  139. /package/src/components/atoms/layouts/examples/grid-example/{GridExample.stories.js → GridExample.oldstories.js} +0 -0
  140. /package/src/components/atoms/layouts/examples/imposter-example/{ImposterExample.stories.js → ImposterExample.oldstories.js} +0 -0
  141. /package/src/components/atoms/layouts/examples/motion-example/{MotionExample.stories.js → MotionExample.oldstories.js} +0 -0
  142. /package/src/components/atoms/layouts/examples/reel-example/{ReelExample.stories.js → ReelExample.oldstories.js} +0 -0
  143. /package/src/components/atoms/layouts/examples/sidebar-example/{SidebarExample.stories.js → SidebarExample.oldstories.js} +0 -0
  144. /package/src/components/atoms/layouts/examples/stack-example/{StackExample.stories.js → StackExample.oldstories.js} +0 -0
  145. /package/src/components/atoms/layouts/examples/switcher-example/{SwitcherExample.stories.js → SwitcherExample.oldstories.js} +0 -0
  146. /package/src/components/atoms/paragraph/{Paragraph.stories.js → Paragraph.oldstories.js} +0 -0
  147. /package/src/components/atoms/processing-fee/{ProcessingFee.stories.js → ProcessingFee.oldstories.js} +0 -0
  148. /package/src/components/atoms/search/{Search.stories.js → Search.oldstories.js} +0 -0
  149. /package/src/components/atoms/solid-divider/{SolidDivider.stories.js → SolidDivider.oldstories.js} +0 -0
  150. /package/src/components/atoms/sortable-table-heading/{SortableTableHeading.stories.js → SortableTableHeading.oldstories.js} +0 -0
  151. /package/src/components/atoms/spinner/{Spinner.stories.js → Spinner.oldstories.js} +0 -0
  152. /package/src/components/atoms/tab/{Tab.stories.js → Tab.oldstories.js} +0 -0
  153. /package/src/components/atoms/text/{Text.stories.js → Text.oldstories.js} +0 -0
  154. /package/src/components/atoms/typeahead-input/{TypeaheadIinput.stories.js → TypeaheadIinput.oldstories.js} +0 -0
  155. /package/src/components/atoms/wallet-name/{WalletName.stories.js → WalletName.oldstories.js} +0 -0
  156. /package/src/components/molecules/account-and-routing-modal/{AccountAndRoutingModal.stories.js → AccountAndRoutingModal.oldstories.js} +0 -0
  157. /package/src/components/molecules/editable-list/{EditableList.stories.js → EditableList.oldstories.js} +0 -0
  158. /package/src/components/molecules/email-form/{EmailForm.stories.js → EmailForm.oldstories.js} +0 -0
  159. /package/src/components/molecules/forgot-password-form/{ForgotPasswordForm.stories.js → ForgotPasswordForm.oldstories.js} +0 -0
  160. /package/src/components/molecules/highlight-tab-row/{HighlightTabRow.stories.js → HighlightTabRow.oldstories.js} +0 -0
  161. /package/src/components/molecules/multiple-select-filter/{MultipleSelectFilter.stories.js → MultipleSelectFilter.oldstories.js} +0 -0
  162. /package/src/components/molecules/obligation/modules/{AmountModule.stories.js → AmountModule.oldstories.js} +0 -0
  163. /package/src/components/molecules/payment-button-bar/{PaymentButtonBar.stories.js → PaymentButtonBar.oldstories.js} +0 -0
  164. /package/src/components/molecules/payment-details/{PaymentDetails.stories.js → PaymentDetails.oldstories.js} +0 -0
  165. /package/src/components/molecules/payment-form-ach/{PaymentFormACH.stories.js → PaymentFormACH.oldstories.js} +0 -0
  166. /package/src/components/molecules/payment-form-card/{PaymentFormCard.stories.js → PaymentFormCard.oldstories.js} +0 -0
  167. /package/src/components/molecules/periscope-dashboard-iframe/{PeriscopeDashBoardIframe.stories.js → PeriscopeDashBoardIframe.oldstories.js} +0 -0
  168. /package/src/components/molecules/phone-form/{PhoneForm.stories.js → PhoneForm.oldstories.js} +0 -0
  169. /package/src/components/molecules/popup-menu/{PopupMenu.stories.js → PopupMenu.oldstories.js} +0 -0
  170. /package/src/components/molecules/radio-group/{RadioGroup.stories.js → RadioGroup.oldstories.js} +0 -0
  171. /package/src/components/molecules/radio-section/{RadioSection.stories.js → RadioSection.oldstories.js} +0 -0
  172. /package/src/components/molecules/registration-form/{RegistrationForm.stories.js → RegistrationForm.oldstories.js} +0 -0
  173. /package/src/components/molecules/reset-confirmation-form/{ResetConfirmationForm.stories.js → ResetConfirmationForm.oldstories.js} +0 -0
  174. /package/src/components/molecules/reset-password-form/{ResetPasswordForm.stories.js → ResetPasswordForm.oldstories.js} +0 -0
  175. /package/src/components/molecules/reset-password-success/{ResetPasswordSuccess.stories.js → ResetPasswordSuccess.oldstories.js} +0 -0
  176. /package/src/components/molecules/tab-sidebar/{TabSidebar.stories.js → TabSidebar.oldstories.js} +0 -0
  177. /package/src/components/molecules/terms-and-conditions/{TermsAndConditions.stories.js → TermsAndConditions.oldstories.js} +0 -0
  178. /package/src/components/molecules/terms-and-conditions-modal/{TermsAndConditionsModal.stories.js → TermsAndConditionsModal.oldstories.js} +0 -0
  179. /package/src/components/molecules/workflow-tile/{WorkflowTile.stories.js → WorkflowTile.oldstories.js} +0 -0
@@ -1,53 +1,78 @@
1
1
  import React from "react";
2
- import { connect } from "react-redux";
3
- import { text, boolean } from "@storybook/addon-knobs";
2
+ import StateProvinceDropdown from "./StateProvinceDropdown";
3
+ import { connect, Provider } from "react-redux";
4
+ import { createStore } from "redux";
4
5
  import { createFormState, required } from "redux-freeform";
5
-
6
- import StateProvinceDropDown from ".";
7
- import page from "../../../../.storybook/page";
6
+ import { action } from "@storybook/addon-actions";
8
7
 
9
8
  const { mapStateToProps, mapDispatchToProps, reducer } = createFormState({
10
- state: {
9
+ country: {
11
10
  validators: [required()]
12
11
  }
13
12
  });
14
- const errorMessages = {
15
- [required.error]: "State is required"
16
- };
17
13
 
18
- const story = page({
19
- title: "Components|Atoms/StateProvinceDropDown",
20
- Component: StateProvinceDropDown,
14
+ const store = createStore(
21
15
  reducer,
22
- mapStateToProps,
23
- mapDispatchToProps,
24
- height: "500px"
25
- });
26
-
27
- const FormWrapper = ({
28
- autocompleteValue,
29
- fields,
30
- actions,
31
- countryCode,
32
- labelTextWhenNoError,
33
- showErrors
34
- }) => (
35
- <StateProvinceDropDown
36
- errorMessages={errorMessages}
37
- field={fields.state}
38
- fieldActions={actions.fields.state}
39
- countryCode={countryCode}
40
- labelTextWhenNoError={labelTextWhenNoError}
41
- showErrors={showErrors}
42
- />
16
+ window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__()
43
17
  );
44
18
 
45
- export default story;
46
- const ConnectedForm = connect(mapStateToProps, mapDispatchToProps)(FormWrapper);
47
- export const stateProvinceDropDown = () => (
48
- <ConnectedForm
49
- labelTextWhenNoError={text("State/Province", "", "props")}
50
- countryCode={text("countryCode", "US", "props")}
51
- showErrors={boolean("showErrors", false, "props")}
19
+ const errorMessages = {
20
+ [required.error]: "country is required"
21
+ };
22
+
23
+ const FormWrapper = props => (
24
+ <StateProvinceDropdown
25
+ {...props}
26
+ field={props.fields.country}
27
+ fieldActions={props.actions.fields.country}
52
28
  />
53
29
  );
30
+
31
+ const ConnectedStateProvinceDropdown = connect(
32
+ mapStateToProps,
33
+ mapDispatchToProps
34
+ )(FormWrapper);
35
+
36
+ export default {
37
+ title: "Atoms/StateProvinceDropdown",
38
+ component: ConnectedStateProvinceDropdown,
39
+ tags: ["!autodocs"],
40
+ parameters: {
41
+ controls: { expanded: true }
42
+ },
43
+ args: {
44
+ errorMessages: errorMessages,
45
+ showErrors: false,
46
+ onChange: action("onChange"),
47
+ labelTextWhenNoError: "State",
48
+ isRequired: false,
49
+ countryCode: "US"
50
+ },
51
+ argTypes: {
52
+ fieldActions: { type: "object" },
53
+ field: { type: "object" },
54
+ showErrors: {
55
+ table: {
56
+ type: { summary: "boolean" },
57
+ defaultValue: { summary: undefined }
58
+ }
59
+ }
60
+ },
61
+ decorators: [
62
+ Story => (
63
+ <Provider store={store}>
64
+ <Story />
65
+ </Provider>
66
+ )
67
+ ]
68
+ };
69
+
70
+ export const Basic = args => <ConnectedStateProvinceDropdown {...args} />;
71
+
72
+ export const NonUS = {
73
+ args: {
74
+ countryCode: "CA",
75
+ labelTextWhenNoError: "Province/territory"
76
+ },
77
+ render: args => <ConnectedStateProvinceDropdown {...args} />
78
+ };
@@ -0,0 +1,71 @@
1
+ import { Canvas, Meta, Title, Story, Controls } from '@storybook/blocks';
2
+
3
+ import * as TableStories from './Table.stories.js';
4
+
5
+ <Meta of={TableStories} />
6
+
7
+ <Title />
8
+
9
+ The Table component is styled `<table />` element that can be paired with other related table compoments to compose consistent and themeable tables. These components can be mixed with raw HTML.
10
+
11
+ ## Components
12
+
13
+ - [Table](#table)
14
+ - [TableBody](#tablebody)
15
+ - [TableCell](#tablecell)
16
+ - [TableHead](#tablehead)
17
+ - [TableHeading](#tableheading)
18
+ - [TableRow](#tablerow)
19
+
20
+ ## Table
21
+ `<table />` element with a small set of default styles.
22
+
23
+ ### Props
24
+ - `extraStyles`
25
+
26
+ ## TableBody
27
+ `<tbody />` element.
28
+
29
+ ### Props
30
+ - `extraStyles`
31
+
32
+ ## TableCell
33
+ `<td />` element with a small set of default styles. Last child will default to `text-align: right`.
34
+
35
+ ### Props
36
+ - `extraStyles`
37
+ - `padding`, default value `24px`
38
+ - `fontSize`, default value `0.875rem`
39
+ - `maxWidth`, default value `250px`
40
+
41
+ ## TableHead
42
+ `<thead />` element. Automatically wraps children `TableRow` component.
43
+
44
+ ### Props
45
+ - `children`
46
+ - `themeValues.backgroundColor`
47
+ - `themeValues.borderColor`
48
+ - `extraStyles`, passed to the `<TableRow />`
49
+
50
+ ## TableHeading
51
+ `<th />` element with a small set of default styles. Last child will default to `text-align: right`.
52
+
53
+ ### Props
54
+ - `extraStyles`
55
+ - `padding`, default value `24px`
56
+ - `minWidth`, default value `initial`
57
+
58
+ ## TableRow
59
+ `<tr />` element.
60
+
61
+ ### Props
62
+ - `extraStyles`
63
+ - `children`
64
+ - `onClick`, function handler for `onClick` on the `<tr />` element
65
+ - `borderColor`, color of the bottom border of the row if it is not the last row
66
+ - `hoverEffect`, set to `true` to add CSS `:hover` styles to the row
67
+ - `hoverCursor`, adds `cursor: pointer` if `hoverEffect` is true
68
+ - `hoverBackgroundColor`, sets background color on `:hover`
69
+ - all other props passed to the `<tr />` element
70
+
71
+ <Story />
@@ -0,0 +1,84 @@
1
+ /*
2
+ Changes were made to the Table stories while the TOOl-597 feature branch was pending, this file has been kept to memorialize those changes so that the v8 story can be updated to match
3
+ */
4
+ import React, { useState } from "react";
5
+ import { Table, TableHead, TableBody, TableRow, TableCell } from "./";
6
+ import page from "../../../../.storybook/page";
7
+ import SortableTableHeading from "../sortable-table-heading";
8
+
9
+ const data = [
10
+ { name: "Alice", occupation: "Engineer", location: "New York" },
11
+ { name: "Bob", occupation: "Designer", location: "Los Angeles" },
12
+ { name: "Charlie", occupation: "Doctor", location: "Chicago" }
13
+ ];
14
+
15
+ const headings = [
16
+ { displayName: "Name", sortKey: "name" },
17
+ { displayName: "Occupation", sortKey: "occupation" },
18
+ { displayName: "Location", sortKey: "location" }
19
+ ];
20
+
21
+ const ComposedSortableTable = () => {
22
+ const [sortState, setSortState] = useState({
23
+ column: "name",
24
+ order: "asc"
25
+ });
26
+ const [sortedData, setSortedData] = useState(data);
27
+ const handleSortChange = column => {
28
+ // Determine the new sort order for SortableTableHeading components
29
+ const newOrder =
30
+ sortState.column === column && sortState.order === "asc" ? "desc" : "asc";
31
+
32
+ setSortState({
33
+ column,
34
+ order: newOrder
35
+ });
36
+
37
+ // Perform sort and update sortedData state
38
+ const sorted = [...data].sort((a, b) => {
39
+ const valueA = a[column];
40
+ const valueB = b[column];
41
+ if (newOrder === "asc") {
42
+ return valueA > valueB ? 1 : -1;
43
+ } else {
44
+ return valueA < valueB ? 1 : -1;
45
+ }
46
+ });
47
+
48
+ setSortedData(sorted);
49
+ };
50
+ return (
51
+ <Table id="users-table">
52
+ <TableHead>
53
+ {headings.map(heading => (
54
+ <SortableTableHeading
55
+ ariaControlsId="users-table"
56
+ displayName={heading.displayName}
57
+ key={heading.sortKey}
58
+ onSortChange={() => handleSortChange(heading.sortKey)}
59
+ sortOrder={
60
+ sortState.column === heading.sortKey ? sortState.order : null
61
+ }
62
+ />
63
+ ))}
64
+ </TableHead>
65
+ <TableBody>
66
+ {sortedData.map((item, idx) => (
67
+ <TableRow key={idx}>
68
+ <TableCell>{item.name}</TableCell>
69
+ <TableCell>{item.occupation}</TableCell>
70
+ <TableCell>{item.location}</TableCell>
71
+ </TableRow>
72
+ ))}
73
+ </TableBody>
74
+ </Table>
75
+ );
76
+ };
77
+
78
+ export const table = () => <ComposedSortableTable />;
79
+ const story = page({
80
+ title: "Components|Atoms/Table",
81
+ Component: Table
82
+ });
83
+
84
+ export default story;
@@ -1,81 +1,65 @@
1
- import React, { useState } from "react";
2
- import { Table, TableHead, TableBody, TableRow, TableCell } from "./";
3
- import page from "../../../../.storybook/page";
4
- import SortableTableHeading from "../sortable-table-heading";
1
+ import {
2
+ Table,
3
+ TableBody,
4
+ TableCell,
5
+ TableHead,
6
+ TableHeading,
7
+ TableRow
8
+ } from "./index.js";
9
+ import { fn } from "@storybook/test";
10
+ import { noop } from "../../../util/general";
5
11
 
6
- const data = [
7
- { name: "Alice", occupation: "Engineer", location: "New York" },
8
- { name: "Bob", occupation: "Designer", location: "Los Angeles" },
9
- { name: "Charlie", occupation: "Doctor", location: "Chicago" }
10
- ];
11
-
12
- const headings = [
13
- { displayName: "Name", sortKey: "name" },
14
- { displayName: "Occupation", sortKey: "occupation" },
15
- { displayName: "Location", sortKey: "location" }
16
- ];
12
+ const meta = {
13
+ title: "Atoms/Table",
14
+ component: Table,
15
+ tags: ["!autodocs"],
16
+ parameters: {
17
+ layout: "centered",
18
+ controls: { expanded: true }
19
+ },
20
+ args: {
21
+ extraStyles: undefined
22
+ },
23
+ argTypes: {
24
+ extraStyles: {
25
+ description: "Styles for the table element.",
26
+ control: { type: "text" },
27
+ table: {
28
+ type: { summary: "string" },
29
+ defaultValue: { summary: undefined }
30
+ }
31
+ }
32
+ }
33
+ };
17
34
 
18
- const ComposedSortableTable = () => {
19
- const [sortState, setSortState] = useState({
20
- column: "name",
21
- order: "asc"
22
- });
23
- const [sortedData, setSortedData] = useState(data);
24
- const handleSortChange = column => {
25
- // Determine the new sort order for SortableTableHeading components
26
- const newOrder =
27
- sortState.column === column && sortState.order === "asc" ? "desc" : "asc";
35
+ export default meta;
28
36
 
29
- setSortState({
30
- column,
31
- order: newOrder
32
- });
37
+ const ComposedTable = ({ hoverCursor = false, onClick = noop }) => (
38
+ <Table>
39
+ <TableHead>
40
+ <TableHeading>Heading 1</TableHeading>
41
+ <TableHeading>Heading 2</TableHeading>
42
+ <TableHeading>Heading 3</TableHeading>
43
+ </TableHead>
44
+ <TableBody>
45
+ <TableRow hoverCursor={hoverCursor} onClick={onClick}>
46
+ <TableCell>Cell 1</TableCell>
47
+ <TableCell>Cell 2</TableCell>
48
+ <TableCell>Cell 3</TableCell>
49
+ </TableRow>
50
+ <TableRow hoverCursor={hoverCursor} onClick={onClick}>
51
+ <TableCell>Cell 4</TableCell>
52
+ <TableCell>Cell 5</TableCell>
53
+ <TableCell>Cell 6</TableCell>
54
+ </TableRow>
55
+ </TableBody>
56
+ </Table>
57
+ );
33
58
 
34
- // Perform sort and update sortedData state
35
- const sorted = [...data].sort((a, b) => {
36
- const valueA = a[column];
37
- const valueB = b[column];
38
- if (newOrder === "asc") {
39
- return valueA > valueB ? 1 : -1;
40
- } else {
41
- return valueA < valueB ? 1 : -1;
42
- }
43
- });
44
-
45
- setSortedData(sorted);
46
- };
47
- return (
48
- <Table id="users-table">
49
- <TableHead>
50
- {headings.map(heading => (
51
- <SortableTableHeading
52
- ariaControlsId="users-table"
53
- displayName={heading.displayName}
54
- key={heading.sortKey}
55
- onSortChange={() => handleSortChange(heading.sortKey)}
56
- sortOrder={
57
- sortState.column === heading.sortKey ? sortState.order : null
58
- }
59
- />
60
- ))}
61
- </TableHead>
62
- <TableBody>
63
- {sortedData.map((item, idx) => (
64
- <TableRow key={idx}>
65
- <TableCell>{item.name}</TableCell>
66
- <TableCell>{item.occupation}</TableCell>
67
- <TableCell>{item.location}</TableCell>
68
- </TableRow>
69
- ))}
70
- </TableBody>
71
- </Table>
72
- );
59
+ export const Basic = {
60
+ render: () => <ComposedTable />
73
61
  };
74
62
 
75
- export const table = () => <ComposedSortableTable />;
76
- const story = page({
77
- title: "Components|Atoms/Table",
78
- Component: Table
79
- });
80
-
81
- export default story;
63
+ export const InteractiveRows = {
64
+ render: () => <ComposedTable hoverCursor={true} onClick={fn()} />
65
+ };
@@ -15,6 +15,7 @@ const TableRow = ({
15
15
  <TableRowWrapper
16
16
  onClick={onClick}
17
17
  hoverEffect={hoverEffect}
18
+ hoverCursor={hoverCursor}
18
19
  extraStyles={extraStyles}
19
20
  borderColor={themeValues.borderColor}
20
21
  hoverBackgroundColor={themeValues.hoverBackgroundColor}
@@ -10,29 +10,6 @@ import {
10
10
  } from "./Title.theme";
11
11
  import { themeComponent } from "../../../util/themeUtils";
12
12
 
13
- /*
14
- New responsive text component for Title elements
15
- Size is decoupled from tag
16
- Comes with two variants - "large" and "small"
17
- Large variant results in text that is 1.5rem (24px desktop, 21px mobile)
18
- Small variant results in text that is 1.25rem/1.2142rem (20px desktop, 17px mobile)
19
-
20
- If you need a smaller text size, use the <Detail /> atom, which has smaller variants
21
-
22
- Use the "as" prop to specify element type, can use any of: h1/h2/h3/h4/h5/h6/p
23
- If you need an inline text element (span), use the <Text /> atom
24
- The "as" value should be dictated by the structure of your page, not what font-size you want
25
-
26
- Title / Detail both use slightly different desktop/mobile scales
27
- (Mobile scale is different to allow for design-friendly px values)
28
- Both atoms detect the presence of a mobile device on their own
29
- and apply the corresponding scale
30
-
31
- Mobile breakpoint value is specified in Title.theme.js
32
-
33
- If you want to disable mobile text scales (use the same rem scale for desktop/mobile), then use a theme in FCS to set both the "large" and "small" variants to use the same rem sizes. FCS themes override fallbacks defined in the .theme file
34
- */
35
-
36
13
  const isBelowBreakpoint = window.innerWidth < MOBILE_BREAKPOINT;
37
14
  const isTouchDevice = "ontouchstart" in window || navigator.maxTouchPoints > 1;
38
15
  const mobileDeviceDetected = isBelowBreakpoint && isTouchDevice;
@@ -0,0 +1,26 @@
1
+ import { Canvas, Meta, Title, Story, Controls } from '@storybook/blocks';
2
+
3
+ import * as TitleStories from './Title.stories.js';
4
+
5
+ <Meta of={TitleStories} />
6
+
7
+ <Title />
8
+
9
+ Title is a responsive text component for heading elements where the font size is decoupled from tag. It comes with two variants - "large" and "small":
10
+
11
+ - Large variant results in text that is `1.5rem` (`24px` desktop, `21px` mobile)
12
+ - Small variant results in text that is `1.25rem/1.2142rem` (`20px` desktop, `17px` mobile)
13
+
14
+ If you need a smaller text size, use the `<Detail />` atom, which has smaller variants.
15
+
16
+ Use the "as" prop to specify element type, can use any of: `h1/h2/h3/h4/h5/h6/p`. If you need an inline text element (span), use the `<Text />` atom. The "as" value should be dictated by the structure of your page, not what font-size you want.
17
+
18
+ Title / Detail both use slightly different desktop/mobile scales (Mobile scale is different to allow for design-friendly px values). Both atoms detect the presence of a mobile device on their own and apply the corresponding scale.
19
+
20
+ Mobile breakpoint value is specified in `Title.theme.js`.
21
+
22
+ If you want to disable mobile text scales (use the same rem scale for desktop/mobile), then use a theme in FCS to set both the "large" and "small" variants to use the same rem sizes. FCS themes override fallbacks defined in the .theme file.
23
+
24
+ <Story />
25
+
26
+ <Controls />
@@ -0,0 +1,144 @@
1
+ import Title from "./Title";
2
+ import { FONT_WEIGHT_REGULAR } from "../../../constants/style_constants";
3
+ import { FIREFLY_GREY } from "../../../constants/colors";
4
+ import { Box } from "../layouts";
5
+
6
+ const meta = {
7
+ title: "Atoms/Title",
8
+ component: Title,
9
+ parameters: {
10
+ layout: "centered",
11
+ controls: { expanded: true }
12
+ },
13
+ tags: ["!autodocs"],
14
+ args: {
15
+ weight: FONT_WEIGHT_REGULAR,
16
+ color: FIREFLY_GREY,
17
+ margin: 0,
18
+ textAlign: undefined,
19
+ extraStyles: "",
20
+ className: undefined,
21
+ variant: "large",
22
+ as: "h1",
23
+ dataQa: undefined,
24
+ children: "Title Component!"
25
+ },
26
+ argTypes: {
27
+ weight: {
28
+ control: { type: "text" },
29
+ table: {
30
+ type: { summary: "string" },
31
+ defaultValue: { summary: FONT_WEIGHT_REGULAR }
32
+ }
33
+ },
34
+ color: {
35
+ control: { type: "text" },
36
+ table: {
37
+ type: { summary: "string" },
38
+ defaultValue: { summary: FIREFLY_GREY }
39
+ }
40
+ },
41
+ margin: {
42
+ control: { type: "text" },
43
+ table: {
44
+ type: { summary: "number | string" },
45
+ defaultValue: { summary: 0 }
46
+ }
47
+ },
48
+ textAlign: {
49
+ control: { type: "text" },
50
+ table: {
51
+ type: { summary: "string" },
52
+ defaultValue: { summary: undefined }
53
+ }
54
+ },
55
+ extraStyles: {
56
+ control: { type: "text" },
57
+ table: {
58
+ type: { summary: "string" },
59
+ defaultValue: { summary: undefined }
60
+ }
61
+ },
62
+ className: {
63
+ control: { type: "text" },
64
+ table: {
65
+ type: { summary: "string" },
66
+ defaultValue: { summary: undefined }
67
+ }
68
+ },
69
+ variant: {
70
+ description: "`large` `small`",
71
+ control: { type: "text" },
72
+ table: {
73
+ type: { summary: "string" },
74
+ defaultValue: { summary: "large" }
75
+ }
76
+ },
77
+ as: {
78
+ description: "`h1` `h2` `h3` `h4` `h5` `h6` `p`",
79
+ control: { type: "text" },
80
+ table: {
81
+ type: { summary: "string" },
82
+ defaultValue: { summary: "h1" }
83
+ }
84
+ },
85
+ dataQa: {
86
+ control: { type: "text" },
87
+ table: {
88
+ type: { summary: "string" },
89
+ defaultValue: { summary: undefined }
90
+ }
91
+ },
92
+ children: {
93
+ control: { type: "text" },
94
+ table: {
95
+ type: { summary: "string | element | array" },
96
+ defaultValue: { summary: undefined }
97
+ }
98
+ }
99
+ }
100
+ };
101
+
102
+ export default meta;
103
+
104
+ export const Basic = {};
105
+
106
+ export const CustomWeight = {
107
+ args: {
108
+ weight: "700"
109
+ }
110
+ };
111
+
112
+ export const CustomColor = {
113
+ args: {
114
+ color: "green"
115
+ }
116
+ };
117
+
118
+ export const CustomMargin = {
119
+ args: {
120
+ margin: "2rem"
121
+ },
122
+ render: args => (
123
+ <Box border={`1px dotted ${FIREFLY_GREY}`} padding="0">
124
+ <Title {...args} />
125
+ </Box>
126
+ )
127
+ };
128
+
129
+ export const TextAlign = {
130
+ args: {
131
+ textAlign: "right"
132
+ },
133
+ render: args => (
134
+ <Box border={`1px dotted ${FIREFLY_GREY}`} padding="0" minWidth="400px">
135
+ <Title {...args} />
136
+ </Box>
137
+ )
138
+ };
139
+
140
+ export const SmallVariant = {
141
+ args: {
142
+ variant: "small"
143
+ }
144
+ };
@@ -0,0 +1,17 @@
1
+ import { Canvas, Meta, Title, Story, Controls } from '@storybook/blocks';
2
+
3
+ import * as ToggleSwitchStories from './ToggleSwitch.stories.js';
4
+
5
+ <Meta of={ToggleSwitchStories} />
6
+
7
+ <Title />
8
+
9
+ The ToggleSwitch is a small button with an on/off state. Use the ToggleSwitch for interactions with binary values, like whether a user's payment method is used as the default, or whether a particular account has automatic payments enabled.
10
+
11
+ The ToggleSwitch is a dumb component and requires its parent component to provide both its curent state as well as the action that occurs when a user interacts with the switch. The Basic Toggle Switch story demonstrates manually providing the `isOn` value via the story controls, while the other stories feature use of the `useState` hook to setup basic state control.
12
+
13
+ <Controls />
14
+
15
+ <div style={{ marginBottom: "2em"}}>
16
+ <Story />
17
+ </div>