@thecb/components 10.7.2-beta.0 → 12.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 (125) hide show
  1. package/dist/index.cjs.js +129 -426
  2. package/dist/index.cjs.js.map +1 -1
  3. package/dist/index.esm.js +129 -426
  4. package/dist/index.esm.js.map +1 -1
  5. package/package.json +21 -13
  6. package/src/.DS_Store +0 -0
  7. package/src/components/.DS_Store +0 -0
  8. package/src/components/atoms/alert/Alert.js +1 -10
  9. package/src/components/atoms/button-with-action/ButtonWithAction.js +4 -0
  10. package/src/components/atoms/button-with-action/ButtonWithAction.oldstories.js +56 -0
  11. package/src/components/atoms/button-with-action/ButtonWithAction.stories.js +109 -55
  12. package/src/components/molecules/.DS_Store +0 -0
  13. package/src/components/molecules/obligation/.DS_Store +0 -0
  14. package/src/components/molecules/toast-notification/ToastNotification.js +43 -74
  15. package/src/constants/style_constants.js +0 -12
  16. package/src/stories/Button.stories.ts +53 -0
  17. package/src/stories/Button.tsx +48 -0
  18. package/src/stories/Configure.mdx +364 -0
  19. package/src/stories/Header.stories.ts +33 -0
  20. package/src/stories/Header.tsx +56 -0
  21. package/src/stories/Page.stories.ts +32 -0
  22. package/src/stories/Page.tsx +73 -0
  23. package/src/stories/assets/accessibility.png +0 -0
  24. package/src/stories/assets/accessibility.svg +5 -0
  25. package/src/stories/assets/addon-library.png +0 -0
  26. package/src/stories/assets/assets.png +0 -0
  27. package/src/stories/assets/avif-test-image.avif +0 -0
  28. package/src/stories/assets/context.png +0 -0
  29. package/src/stories/assets/discord.svg +15 -0
  30. package/src/stories/assets/docs.png +0 -0
  31. package/src/stories/assets/figma-plugin.png +0 -0
  32. package/src/stories/assets/github.svg +3 -0
  33. package/src/stories/assets/share.png +0 -0
  34. package/src/stories/assets/styling.png +0 -0
  35. package/src/stories/assets/testing.png +0 -0
  36. package/src/stories/assets/theming.png +0 -0
  37. package/src/stories/assets/tutorials.svg +12 -0
  38. package/src/stories/assets/youtube.svg +4 -0
  39. package/src/stories/button.css +30 -0
  40. package/src/stories/header.css +32 -0
  41. package/src/stories/page.css +69 -0
  42. /package/src/components/atoms/add-obligation/{AddObligation.stories.js → AddObligation.oldstories.js} +0 -0
  43. /package/src/components/atoms/alert/{Alert.stories.js → Alert.oldstories.js} +0 -0
  44. /package/src/components/atoms/amount-callout/{AmountCallout.stories.js → AmountCallout.oldstories.js} +0 -0
  45. /package/src/components/atoms/badge/{Badge.stories.js → Badge.oldstories.js} +0 -0
  46. /package/src/components/atoms/breadcrumb/{Breadcrumb.stories.js → Breadcrumb.oldstories.js} +0 -0
  47. /package/src/components/atoms/button-with-link/{ButtonWithLink.stories.js → ButtonWithLink.oldstories.js} +0 -0
  48. /package/src/components/atoms/checkbox/{Checkbox.stories.js → Checkbox.oldstories.js} +0 -0
  49. /package/src/components/atoms/checkbox-list/{CheckboxList.stories.js → CheckboxList.oldstories.js} +0 -0
  50. /package/src/components/atoms/country-dropdown/{CountryDropdown.stories.js → CountryDropdown.oldstories.js} +0 -0
  51. /package/src/components/atoms/display-box/{DisplayBox.stories.js → DisplayBox.oldstories.js} +0 -0
  52. /package/src/components/atoms/display-card/{DisplayCard.stories.js → DisplayCard.oldstories.js} +0 -0
  53. /package/src/components/atoms/dropdown/{Dropdown.stories.js → Dropdown.oldstories.js} +0 -0
  54. /package/src/components/atoms/form-layouts/{FormLayouts.stories.js → FormLayouts.oldstories.js} +0 -0
  55. /package/src/components/atoms/form-select/{FormSelect.stories.js → FormSelect.oldstories.js} +0 -0
  56. /package/src/components/atoms/formatted-address/{FormattedAddress.stories.js → FormattedAddress.oldstories.js} +0 -0
  57. /package/src/components/atoms/hamburger-button/{HamburgerButton.stories.js → HamburgerButton.oldstories.js} +0 -0
  58. /package/src/components/atoms/heading/{Heading.stories.js → Heading.oldstories.js} +0 -0
  59. /package/src/components/atoms/icons/{icons.stories.js → icons.oldstories.js} +0 -0
  60. /package/src/components/atoms/labeled-amount/{LabeledAmount.stories.js → LabeledAmount.oldstories.js} +0 -0
  61. /package/src/components/atoms/layouts/examples/box-example/{BoxExample.stories.js → BoxExample.oldstories.js} +0 -0
  62. /package/src/components/atoms/layouts/examples/center-example/{CenterExample.stories.js → CenterExample.oldstories.js} +0 -0
  63. /package/src/components/atoms/layouts/examples/cluster-example/{ClusterExample.stories.js → ClusterExample.oldstories.js} +0 -0
  64. /package/src/components/atoms/layouts/examples/cover-example/{CoverExample.stories.js → CoverExample.oldstories.js} +0 -0
  65. /package/src/components/atoms/layouts/examples/frame-example/{FrameExample.stories.js → FrameExample.oldstories.js} +0 -0
  66. /package/src/components/atoms/layouts/examples/grid-example/{GridExample.stories.js → GridExample.oldstories.js} +0 -0
  67. /package/src/components/atoms/layouts/examples/imposter-example/{ImposterExample.stories.js → ImposterExample.oldstories.js} +0 -0
  68. /package/src/components/atoms/layouts/examples/motion-example/{MotionExample.stories.js → MotionExample.oldstories.js} +0 -0
  69. /package/src/components/atoms/layouts/examples/reel-example/{ReelExample.stories.js → ReelExample.oldstories.js} +0 -0
  70. /package/src/components/atoms/layouts/examples/sidebar-example/{SidebarExample.stories.js → SidebarExample.oldstories.js} +0 -0
  71. /package/src/components/atoms/layouts/examples/stack-example/{StackExample.stories.js → StackExample.oldstories.js} +0 -0
  72. /package/src/components/atoms/layouts/examples/switcher-example/{SwitcherExample.stories.js → SwitcherExample.oldstories.js} +0 -0
  73. /package/src/components/atoms/line-item/{LineItem.stories.js → LineItem.oldstories.js} +0 -0
  74. /package/src/components/atoms/link/{Link.stories.js → Link.oldstories.js} +0 -0
  75. /package/src/components/atoms/loading-line/{LoadingLine.stories.js → LoadingLine.oldstories.js} +0 -0
  76. /package/src/components/atoms/nav-footer/{NavFooter.stories.js → NavFooter.oldstories.js} +0 -0
  77. /package/src/components/atoms/nav-header/{NavHeader.stories.js → NavHeader.oldstories.js} +0 -0
  78. /package/src/components/atoms/paragraph/{Paragraph.stories.js → Paragraph.oldstories.js} +0 -0
  79. /package/src/components/atoms/password-requirements/{PasswordRequirements.stories.js → PasswordRequirements.oldstories.js} +0 -0
  80. /package/src/components/atoms/placeholder/{Placeholder.stories.js → Placeholder.oldstories.js} +0 -0
  81. /package/src/components/atoms/processing-fee/{ProcessingFee.stories.js → ProcessingFee.oldstories.js} +0 -0
  82. /package/src/components/atoms/searchable-select/{SearchableSelect.stories.js → SearchableSelect.oldstories.js} +0 -0
  83. /package/src/components/atoms/solid-divider/{SolidDivider.stories.js → SolidDivider.oldstories.js} +0 -0
  84. /package/src/components/atoms/spinner/{Spinner.stories.js → Spinner.oldstories.js} +0 -0
  85. /package/src/components/atoms/state-province-dropdown/{StateProvinceDropdown.stories.js → StateProvinceDropdown.oldstories.js} +0 -0
  86. /package/src/components/atoms/tab/{Tab.stories.js → Tab.oldstories.js} +0 -0
  87. /package/src/components/atoms/text/{Text.stories.js → Text.oldstories.js} +0 -0
  88. /package/src/components/atoms/toggle-switch/{ToggleSwitch.stories.js → ToggleSwitch.oldstories.js} +0 -0
  89. /package/src/components/atoms/typeahead-input/{TypeaheadIinput.stories.js → TypeaheadIinput.oldstories.js} +0 -0
  90. /package/src/components/atoms/wallet-name/{WalletName.stories.js → WalletName.oldstories.js} +0 -0
  91. /package/src/components/molecules/account-and-routing-modal/{AccountAndRoutingModal.stories.js → AccountAndRoutingModal.oldstories.js} +0 -0
  92. /package/src/components/molecules/address-form/{AddressForm.stories.js → AddressForm.oldstories.js} +0 -0
  93. /package/src/components/molecules/banner/{Banner.stories.js → Banner.oldstories.js} +0 -0
  94. /package/src/components/molecules/change-password-form/{ChangePasswordForm.stories.js → ChangePasswordForm.oldstories.js} +0 -0
  95. /package/src/components/molecules/collapsible-section/{CollapsibleSection.stories.js → CollapsibleSection.oldstories.js} +0 -0
  96. /package/src/components/molecules/edit-name-form/{EdidNameForm.stories.js → EdidNameForm.oldstories.js} +0 -0
  97. /package/src/components/molecules/editable-list/{EditableList.stories.js → EditableList.oldstories.js} +0 -0
  98. /package/src/components/molecules/email-form/{EmailForm.stories.js → EmailForm.oldstories.js} +0 -0
  99. /package/src/components/molecules/forgot-password-form/{ForgotPasswordForm.stories.js → ForgotPasswordForm.oldstories.js} +0 -0
  100. /package/src/components/molecules/highlight-tab-row/{HighlightTabRow.stories.js → HighlightTabRow.oldstories.js} +0 -0
  101. /package/src/components/molecules/link-card/{LinkCard.stories.js → LinkCard.oldstories.js} +0 -0
  102. /package/src/components/molecules/login-form/{LoginForm.stories.js → LoginForm.oldstories.js} +0 -0
  103. /package/src/components/molecules/modal/{Modal.stories.js → Modal.oldstories.js} +0 -0
  104. /package/src/components/molecules/module/{Module.stories.js → Module.oldstories.js} +0 -0
  105. /package/src/components/molecules/obligation/modules/{AmountModule.stories.js → AmountModule.oldstories.js} +0 -0
  106. /package/src/components/molecules/pagination/{Pagination.stories.js → Pagination.oldstories.js} +0 -0
  107. /package/src/components/molecules/payment-button-bar/{PaymentButtonBar.stories.js → PaymentButtonBar.oldstories.js} +0 -0
  108. /package/src/components/molecules/payment-details/{PaymentDetails.stories.js → PaymentDetails.oldstories.js} +0 -0
  109. /package/src/components/molecules/payment-form-ach/{PaymentFormACH.stories.js → PaymentFormACH.oldstories.js} +0 -0
  110. /package/src/components/molecules/payment-form-card/{PaymentFormCard.stories.js → PaymentFormCard.oldstories.js} +0 -0
  111. /package/src/components/molecules/periscope-dashboard-iframe/{PeriscopeDashBoardIframe.stories.js → PeriscopeDashBoardIframe.oldstories.js} +0 -0
  112. /package/src/components/molecules/phone-form/{PhoneForm.stories.js → PhoneForm.oldstories.js} +0 -0
  113. /package/src/components/molecules/popup-menu/{PopupMenu.stories.js → PopupMenu.oldstories.js} +0 -0
  114. /package/src/components/molecules/radio-group/{RadioGroup.stories.js → RadioGroup.oldstories.js} +0 -0
  115. /package/src/components/molecules/radio-section/{RadioSection.stories.js → RadioSection.oldstories.js} +0 -0
  116. /package/src/components/molecules/registration-form/{RegistrationForm.stories.js → RegistrationForm.oldstories.js} +0 -0
  117. /package/src/components/molecules/reset-confirmation-form/{ResetConfirmationForm.stories.js → ResetConfirmationForm.oldstories.js} +0 -0
  118. /package/src/components/molecules/reset-password-form/{ResetPasswordForm.stories.js → ResetPasswordForm.oldstories.js} +0 -0
  119. /package/src/components/molecules/reset-password-success/{ResetPasswordSuccess.stories.js → ResetPasswordSuccess.oldstories.js} +0 -0
  120. /package/src/components/molecules/tab-sidebar/{TabSidebar.stories.js → TabSidebar.oldstories.js} +0 -0
  121. /package/src/components/molecules/tabs/{Tabs.stories.js → Tabs.oldstories.js} +0 -0
  122. /package/src/components/molecules/terms-and-conditions/{TermsAndConditions.stories.js → TermsAndConditions.oldstories.js} +0 -0
  123. /package/src/components/molecules/terms-and-conditions-modal/{TermsAndConditionsModal.stories.js → TermsAndConditionsModal.oldstories.js} +0 -0
  124. /package/src/components/molecules/toast-notification/{ToastNotification.stories.js → ToastNotification.oldstories.js} +0 -0
  125. /package/src/components/molecules/workflow-tile/{WorkflowTile.stories.js → WorkflowTile.oldstories.js} +0 -0
package/package.json CHANGED
@@ -1,14 +1,15 @@
1
1
  {
2
2
  "name": "@thecb/components",
3
- "version": "10.7.2-beta.0",
3
+ "version": "12.0.0-beta.0",
4
4
  "description": "Common lib for CityBase react components",
5
5
  "main": "dist/index.cjs.js",
6
6
  "typings": "dist/index.d.ts",
7
7
  "module": "dist/index.esm.js",
8
8
  "source": "src/index.js",
9
9
  "scripts": {
10
- "storybook": "start-storybook",
11
- "build": "rollup -cm"
10
+ "storybook": "storybook dev -p 6006",
11
+ "build": "rollup -cm",
12
+ "build-storybook": "storybook build"
12
13
  },
13
14
  "repository": {
14
15
  "type": "git",
@@ -30,15 +31,19 @@
30
31
  "@babel/preset-env": "^7.6.0",
31
32
  "@babel/preset-react": "^7.0.0",
32
33
  "@babel/register": "^7.6.2",
34
+ "@chromatic-com/storybook": "^1.4.0",
33
35
  "@rollup/plugin-json": "^4.0.3",
34
- "@storybook/addon-a11y": "6.4.22",
35
- "@storybook/addon-actions": "^6.4.22",
36
- "@storybook/addon-console": "^1.2.3",
37
- "@storybook/addon-docs": "^6.4.22",
38
- "@storybook/addon-knobs": "^5.3.14",
39
- "@storybook/addon-storysource": "^6.4.22",
40
- "@storybook/addon-viewport": "^6.4.22",
41
- "@storybook/react": "^6.4.22",
36
+ "@storybook/addon-essentials": "^8.1.1",
37
+ "@storybook/addon-interactions": "^8.1.1",
38
+ "@storybook/addon-links": "^8.1.1",
39
+ "@storybook/addon-mdx-gfm": "^8.1.1",
40
+ "@storybook/addon-onboarding": "^8.1.1",
41
+ "@storybook/addon-themes": "^8.1.3",
42
+ "@storybook/blocks": "^8.1.1",
43
+ "@storybook/react": "^8.1.1",
44
+ "@storybook/react-vite": "^8.1.1",
45
+ "@storybook/test": "^8.1.1",
46
+ "@vitejs/plugin-react": "^4.2.1",
42
47
  "babel-core": "^6.26.3",
43
48
  "babel-loader": "^8.1.0",
44
49
  "babel-preset-env": "^1.7.0",
@@ -48,6 +53,7 @@
48
53
  "eslint-plugin-babel": "^5.3.0",
49
54
  "eslint-plugin-prettier": "^3.1.3",
50
55
  "eslint-plugin-react": "^7.20.0",
56
+ "eslint-plugin-storybook": "^0.8.0",
51
57
  "history": "^5.0.0",
52
58
  "husky": "^4.2.3",
53
59
  "prettier": "^1.19.1",
@@ -63,10 +69,11 @@
63
69
  "rollup-plugin-node-resolve": "^5.1.0",
64
70
  "rollup-plugin-ts": "^3.0.2",
65
71
  "rollup-plugin-visualizer": "^4.0.4",
66
- "storybook": "^6.4.22",
72
+ "storybook": "^8.1.1",
67
73
  "styled-components": "^5.3.5",
68
74
  "styled-theming": "^2.2.0",
69
- "typescript": "^4.8.2"
75
+ "typescript": "^4.8.2",
76
+ "vite": "^5.2.11"
70
77
  },
71
78
  "peerDependencies": {
72
79
  "react": "^16.13.1",
@@ -82,6 +89,7 @@
82
89
  },
83
90
  "dependencies": {
84
91
  "@babel/runtime": "^7.15.4",
92
+ "@types/styled-components": "^5.1.34",
85
93
  "core-js": "^3.22.5",
86
94
  "formatted-input": "^1.0.0",
87
95
  "framer-motion": "^1.11.0",
package/src/.DS_Store ADDED
Binary file
Binary file
@@ -73,16 +73,7 @@ const Alert = ({
73
73
  </Box>
74
74
  <Cluster justify="flex-end" align="flex-start">
75
75
  {showQuitLink && (
76
- <Box
77
- padding="0"
78
- minHeight="100%"
79
- onClick={onLinkClick}
80
- onKeyDown={e => e.key === "Enter" && onLinkClick()}
81
- role="button"
82
- tabIndex={0}
83
- aria-label={`Close Alert: ${heading}`}
84
- extraStyles="cursor: pointer;"
85
- >
76
+ <Box padding="0" minHeight="100%" onClick={onLinkClick}>
86
77
  <IconQuit />
87
78
  </Box>
88
79
  )}
@@ -82,12 +82,16 @@ const ButtonWithAction = forwardRef(
82
82
  ref
83
83
  ) => {
84
84
  const themeContext = useContext(ThemeContext);
85
+ console.log("theme context is", themeContext);
86
+ console.log("fallback values are", fallbackValues);
87
+ console.log("variant is", variant);
85
88
  const themeValues = createThemeValues(
86
89
  themeContext,
87
90
  fallbackValues,
88
91
  "Button",
89
92
  variant
90
93
  );
94
+ console.log("theme values are", themeValues);
91
95
  const { isMobile } = themeContext;
92
96
 
93
97
  const hoverStyles = `
@@ -0,0 +1,56 @@
1
+ import React, { Fragment, useState } from "react";
2
+ import { text, select, boolean } from "@storybook/addon-knobs";
3
+ import { Box } from "../layouts";
4
+ import ButtonWithAction from "./ButtonWithAction";
5
+ import page from "../../../../.storybook/page";
6
+
7
+ const variantsLabel = "variant";
8
+ const variants = {
9
+ primary: "primary",
10
+ secondary: "secondary",
11
+ back: "back",
12
+ smallPrimary: "smallPrimary",
13
+ smallSecondary: "smallSecondary",
14
+ ghost: "ghost",
15
+ smallGhost: "smallGhost",
16
+ tertiary: "tertiary",
17
+ danger: "danger",
18
+ dangerSecondary: "dangerSecondary",
19
+ whiteSecondary: "whiteSecondary",
20
+ whitePrimary: "whitePrimary",
21
+ None: undefined
22
+ };
23
+ const defaultValue = "primary";
24
+ const groupId = "props";
25
+
26
+ const buttonHandler = () => window.alert("Button click!");
27
+
28
+ export const buttonWithAction = () => (
29
+ <Fragment>
30
+ {/* Uncomment to view buttons on a dark background */}
31
+ {/* <Box extraStyles="background-color: #000;">
32
+ <ButtonWithAction
33
+ variant={select(variantsLabel, variants, defaultValue, groupId)}
34
+ disabled={boolean("disabled", false, "props")}
35
+ text={text("text", "button", "props")}
36
+ isLoading={boolean("isLoading", false, "props")}
37
+ action={text("action", buttonHandler, "props")}
38
+ />
39
+ </Box> */}
40
+ <Box extraStyles="background-color: #fff;">
41
+ <ButtonWithAction
42
+ variant={select(variantsLabel, variants, defaultValue, groupId)}
43
+ disabled={boolean("disabled", false, "props")}
44
+ text={text("text", "button", "props")}
45
+ isLoading={boolean("isLoading", false, "props")}
46
+ action={text("action", buttonHandler, "props")}
47
+ />
48
+ </Box>
49
+ </Fragment>
50
+ );
51
+
52
+ const story = page({
53
+ title: "Components|Atoms/ButtonWithAction",
54
+ Component: ButtonWithAction
55
+ });
56
+ export default story;
@@ -1,56 +1,110 @@
1
- import React, { Fragment, useState } from "react";
2
- import { text, select, boolean } from "@storybook/addon-knobs";
3
- import { Box } from "../layouts";
1
+ import { Button } from "../../../stories/Button";
4
2
  import ButtonWithAction from "./ButtonWithAction";
5
- import page from "../../../../.storybook/page";
6
-
7
- const variantsLabel = "variant";
8
- const variants = {
9
- primary: "primary",
10
- secondary: "secondary",
11
- back: "back",
12
- smallPrimary: "smallPrimary",
13
- smallSecondary: "smallSecondary",
14
- ghost: "ghost",
15
- smallGhost: "smallGhost",
16
- tertiary: "tertiary",
17
- danger: "danger",
18
- dangerSecondary: "dangerSecondary",
19
- whiteSecondary: "whiteSecondary",
20
- whitePrimary: "whitePrimary",
21
- None: undefined
22
- };
23
- const defaultValue = "primary";
24
- const groupId = "props";
25
-
26
- const buttonHandler = () => window.alert("Button click!");
27
-
28
- export const buttonWithAction = () => (
29
- <Fragment>
30
- {/* Uncomment to view buttons on a dark background */}
31
- {/* <Box extraStyles="background-color: #000;">
32
- <ButtonWithAction
33
- variant={select(variantsLabel, variants, defaultValue, groupId)}
34
- disabled={boolean("disabled", false, "props")}
35
- text={text("text", "button", "props")}
36
- isLoading={boolean("isLoading", false, "props")}
37
- action={text("action", buttonHandler, "props")}
38
- />
39
- </Box> */}
40
- <Box extraStyles="background-color: #fff;">
41
- <ButtonWithAction
42
- variant={select(variantsLabel, variants, defaultValue, groupId)}
43
- disabled={boolean("disabled", false, "props")}
44
- text={text("text", "button", "props")}
45
- isLoading={boolean("isLoading", false, "props")}
46
- action={text("action", buttonHandler, "props")}
47
- />
48
- </Box>
49
- </Fragment>
50
- );
51
-
52
- const story = page({
53
- title: "Components|Atoms/ButtonWithAction",
54
- Component: ButtonWithAction
55
- });
56
- export default story;
3
+ import { fn } from "@storybook/test";
4
+
5
+ const meta = {
6
+ title: "Atoms/ButtonWithAction",
7
+ component: ButtonWithAction,
8
+ parameters: {
9
+ layout: "centered"
10
+ },
11
+ tags: ["autodocs"],
12
+ args: {
13
+ action: fn(),
14
+ dataQa: null,
15
+ textExtraStyles: "",
16
+ extraStyles: "",
17
+ extraDisabledStyles: ""
18
+ }
19
+ };
20
+
21
+ export default meta;
22
+
23
+ export const Primary = {
24
+ args: {
25
+ variant: "primary",
26
+ text: "Pay Now"
27
+ }
28
+ };
29
+
30
+ export const Secondary = {
31
+ args: {
32
+ ...Primary.args,
33
+ variant: "secondary"
34
+ }
35
+ };
36
+
37
+ export const Tertiary = {
38
+ args: {
39
+ ...Primary.args,
40
+ variant: "tertiary"
41
+ }
42
+ };
43
+
44
+ export const Back = {
45
+ args: {
46
+ ...Primary.args,
47
+ variant: "back"
48
+ }
49
+ };
50
+
51
+ export const Danger = {
52
+ args: {
53
+ ...Primary.args,
54
+ variant: "danger"
55
+ }
56
+ };
57
+
58
+ export const Ghost = {
59
+ args: {
60
+ ...Primary.args,
61
+ variant: "ghost"
62
+ }
63
+ };
64
+
65
+ export const LoadingPrimary = {
66
+ args: {
67
+ ...Primary.args,
68
+ isLoading: true
69
+ }
70
+ };
71
+
72
+ export const DisabledPrimary = {
73
+ args: {
74
+ ...Primary.args,
75
+ disabled: true
76
+ }
77
+ };
78
+
79
+ export const SmallGhost = {
80
+ args: {
81
+ ...Primary.args,
82
+ variant: "smallGhost"
83
+ }
84
+ };
85
+
86
+ export const SmallPrimary = {
87
+ args: {
88
+ ...Primary.args,
89
+ variant: "smallPrimary"
90
+ }
91
+ };
92
+
93
+ export const SmallSecondary = {
94
+ args: {
95
+ ...Primary.args,
96
+ variant: "smallSecondary"
97
+ }
98
+ };
99
+
100
+ export const WhitePrimary = {
101
+ args: {
102
+ ...Primary.args,
103
+ variant: "whitePrimary"
104
+ }
105
+ };
106
+
107
+ export const WhiteSecondary = {
108
+ ...Primary.args,
109
+ variant: "whiteSecondary"
110
+ };
@@ -1,4 +1,4 @@
1
- import React, { useRef, useEffect } from "react";
1
+ import React from "react";
2
2
  import { Box, Cluster } from "../../atoms/layouts";
3
3
  import { Paragraph } from "../../atoms";
4
4
  import {
@@ -13,7 +13,6 @@ import {
13
13
  } from "../../../constants/colors";
14
14
  import { FONT_WEIGHT_SEMIBOLD } from "../../../constants/style_constants";
15
15
  import { generateShadows } from "../../../util/generateShadows";
16
- import { SCREEN_READER_ONLY } from "../../../constants/style_constants";
17
16
 
18
17
  const VARIANTS = {
19
18
  SUCCESS: "success",
@@ -31,85 +30,55 @@ const ToastNotification = ({
31
30
  height = "56px",
32
31
  childGap = "1rem",
33
32
  backgroundColor,
34
- role = "log",
33
+ role = "alert",
35
34
  ariaLive = "polite",
36
- screenReaderMessage,
37
- showScreenReaderMessage = true,
38
35
  ...rest
39
- }) => {
40
- const screenReaderMessageRef = useRef();
41
- const LIVEREGION_TRANSITION_DELAY = 1000;
42
-
43
- useEffect(() => {
44
- if (showScreenReaderMessage) {
45
- const timeout = setTimeout(() => {
46
- if (screenReaderMessageRef.current) {
47
- screenReaderMessageRef.current.textContent = `${
48
- screenReaderMessage ? screenReaderMessage : message ? message : ""
49
- }`;
50
- }
51
- }, LIVEREGION_TRANSITION_DELAY);
52
-
53
- return () => clearTimeout(timeout);
36
+ }) => (
37
+ <Box
38
+ onClick={closeToastNotification}
39
+ onKeyDown={e => e.key === "Enter" && closeToastNotification()}
40
+ background={
41
+ backgroundColor
42
+ ? backgroundColor
43
+ : variant === VARIANTS.SUCCESS
44
+ ? HINT_GREEN
45
+ : variant === VARIANTS.ERROR
46
+ ? ERROR_BACKGROUND_COLOR
47
+ : WHITE
54
48
  }
55
- }, [showScreenReaderMessage, screenReaderMessage, message]);
56
-
57
- return (
58
- <>
59
- <Box
60
- onClick={closeToastNotification}
61
- onKeyDown={e => e.key === "Enter" && closeToastNotification()}
62
- background={
63
- backgroundColor
64
- ? backgroundColor
65
- : variant === VARIANTS.SUCCESS
66
- ? HINT_GREEN
67
- : variant === VARIANTS.ERROR
68
- ? ERROR_BACKGROUND_COLOR
69
- : WHITE
70
- }
71
- minWidth={minWidth}
72
- minHeight={height && parseInt(height) < 100 ? height : "100px"}
73
- height={height ? height : "auto"}
74
- tabIndex={toastOpen ? "-1" : "0"}
75
- padding="0rem 1rem"
76
- borderRadius="4px"
77
- boxShadow={generateShadows().standard.base}
78
- extraStyles={`
49
+ minWidth={minWidth}
50
+ minHeight={height && parseInt(height) < 100 ? height : "100px"}
51
+ height={height ? height : "auto"}
52
+ tabIndex={toastOpen ? "-1" : "0"}
53
+ padding="0rem 1rem"
54
+ borderRadius="4px"
55
+ boxShadow={generateShadows().standard.base}
56
+ extraStyles={`
79
57
  display: ${toastOpen ? "block" : "none"};
80
58
  position: fixed; bottom: 4rem; left: 4rem;
81
59
  ${extraStyles};
82
60
  cursor: pointer;
83
61
  `}
84
- {...rest}
85
- >
86
- <Cluster align="center" childGap={childGap} justify="space-between">
87
- <Cluster align="center" childGap={childGap}>
88
- {variant === VARIANTS.SUCCESS && <SuccessfulIconMedium />}
89
- {variant === VARIANTS.ERROR && <ErroredIcon />}
90
- <Box padding="1rem 0" maxWidth={maxWidth}>
91
- <Paragraph
92
- weight={FONT_WEIGHT_SEMIBOLD}
93
- extraStyles={"word-break: break-word;"}
94
- >
95
- {message}
96
- </Paragraph>
97
- </Box>
98
- </Cluster>
99
- <IconQuitLarge />
100
- </Cluster>
101
- </Box>
102
- {showScreenReaderMessage && (
103
- <span
104
- ref={screenReaderMessageRef}
105
- style={SCREEN_READER_ONLY}
106
- role={role}
107
- aria-live={ariaLive}
108
- aria-atomic={true}
109
- ></span>
110
- )}
111
- </>
112
- );
113
- };
62
+ role={role}
63
+ aria-live={ariaLive}
64
+ {...rest}
65
+ >
66
+ <Cluster align="center" childGap={childGap} justify="space-between">
67
+ <Cluster align="center" childGap={childGap}>
68
+ {variant === VARIANTS.SUCCESS && <SuccessfulIconMedium />}
69
+ {variant === VARIANTS.ERROR && <ErroredIcon />}
70
+ <Box padding="1rem 0" maxWidth={maxWidth}>
71
+ <Paragraph
72
+ weight={FONT_WEIGHT_SEMIBOLD}
73
+ extraStyles={"word-break: break-word;"}
74
+ >
75
+ {message}
76
+ </Paragraph>
77
+ </Box>
78
+ </Cluster>
79
+ <IconQuitLarge />
80
+ </Cluster>
81
+ </Box>
82
+ );
114
83
 
115
84
  export default ToastNotification;
@@ -24,15 +24,3 @@ export const SPACING = {
24
24
  XS: "1.0rem", // Figma: Spacing/XS
25
25
  MD: "1.5rem" // Figma: Spacing/Normal
26
26
  };
27
- export const SCREEN_READER_ONLY = {
28
- border: 0,
29
- clip: "rect(0 0 0 0)",
30
- clipPath: "inset(50%)",
31
- height: "1px",
32
- margin: "-1px",
33
- overflow: "hidden",
34
- padding: 0,
35
- position: "absolute",
36
- width: "1px",
37
- whiteSpace: "nowrap"
38
- };
@@ -0,0 +1,53 @@
1
+ import type { Meta, StoryObj } from '@storybook/react';
2
+ import { fn } from '@storybook/test';
3
+
4
+ import { Button } from './Button';
5
+
6
+ // More on how to set up stories at: https://storybook.js.org/docs/writing-stories#default-export
7
+ const meta: Meta<typeof Button> = {
8
+ title: 'Example/Button',
9
+ component: Button,
10
+ parameters: {
11
+ // Optional parameter to center the component in the Canvas. More info: https://storybook.js.org/docs/configure/story-layout
12
+ layout: 'centered',
13
+ },
14
+ // This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs
15
+ tags: ['autodocs'],
16
+ // More on argTypes: https://storybook.js.org/docs/api/argtypes
17
+ argTypes: {
18
+ backgroundColor: { control: 'color' },
19
+ },
20
+ // Use `fn` to spy on the onClick arg, which will appear in the actions panel once invoked: https://storybook.js.org/docs/essentials/actions#action-args
21
+ args: { onClick: fn() },
22
+ };
23
+
24
+ export default meta;
25
+ type Story = StoryObj<typeof Button>;
26
+
27
+ // More on writing stories with args: https://storybook.js.org/docs/writing-stories/args
28
+ export const Primary: Story = {
29
+ args: {
30
+ primary: true,
31
+ label: 'Button',
32
+ },
33
+ };
34
+
35
+ export const Secondary: Story = {
36
+ args: {
37
+ label: 'Button',
38
+ },
39
+ };
40
+
41
+ export const Large: Story = {
42
+ args: {
43
+ size: 'large',
44
+ label: 'Button',
45
+ },
46
+ };
47
+
48
+ export const Small: Story = {
49
+ args: {
50
+ size: 'small',
51
+ label: 'Button',
52
+ },
53
+ };
@@ -0,0 +1,48 @@
1
+ import React from 'react';
2
+ import './button.css';
3
+
4
+ interface ButtonProps {
5
+ /**
6
+ * Is this the principal call to action on the page?
7
+ */
8
+ primary?: boolean;
9
+ /**
10
+ * What background color to use
11
+ */
12
+ backgroundColor?: string;
13
+ /**
14
+ * How large should the button be?
15
+ */
16
+ size?: 'small' | 'medium' | 'large';
17
+ /**
18
+ * Button contents
19
+ */
20
+ label: string;
21
+ /**
22
+ * Optional click handler
23
+ */
24
+ onClick?: () => void;
25
+ }
26
+
27
+ /**
28
+ * Primary UI component for user interaction
29
+ */
30
+ export const Button = ({
31
+ primary = false,
32
+ size = 'medium',
33
+ backgroundColor,
34
+ label,
35
+ ...props
36
+ }: ButtonProps) => {
37
+ const mode = primary ? 'storybook-button--primary' : 'storybook-button--secondary';
38
+ return (
39
+ <button
40
+ type="button"
41
+ className={['storybook-button', `storybook-button--${size}`, mode].join(' ')}
42
+ style={{ backgroundColor }}
43
+ {...props}
44
+ >
45
+ {label}
46
+ </button>
47
+ );
48
+ };