@thecb/components 10.7.0-beta.2 → 10.7.1-beta.1

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 (54) hide show
  1. package/dist/index.cjs.js +485 -193
  2. package/dist/index.cjs.js.map +1 -1
  3. package/dist/index.esm.js +484 -192
  4. package/dist/index.esm.js.map +1 -1
  5. package/package.json +1 -1
  6. package/src/components/{molecules/obligation → atoms}/.DS_Store +0 -0
  7. package/src/components/atoms/button-with-action/ButtonWithAction.js +0 -2
  8. package/src/components/atoms/icons/.DS_Store +0 -0
  9. package/src/components/atoms/wallet-name/WalletName.js +6 -4
  10. package/src/components/atoms/wallet-name/WalletName.stories.js +26 -1
  11. package/src/components/atoms/wallet-name/index.d.ts +2 -0
  12. package/src/components/molecules/obligation/Obligation.js +2 -7
  13. package/src/components/molecules/obligation/modules/AmountModule.js +1 -1
  14. package/src/components/molecules/obligation/modules/AutopayModalModule.js +11 -11
  15. package/src/components/molecules/obligation/modules/AutopayModalModule.theme.js +20 -0
  16. package/src/components/molecules/obligation/modules/IconModule.js +7 -3
  17. package/src/components/molecules/obligation/modules/InactiveControlsModule.js +1 -1
  18. package/src/components/molecules/obligation/modules/PaymentDetailsActions.js +1 -1
  19. package/src/components/molecules/payment-button-bar/PaymentButtonBar.js +6 -4
  20. package/src/components/molecules/radio-section/RadioSection.js +2 -1
  21. package/src/components/molecules/reset-confirmation-form/ResetConfirmationForm.js +15 -3
  22. package/src/components/molecules/reset-confirmation-form/ResetConfirmationForm.theme.js +9 -0
  23. package/src/components/molecules/reset-password-success/ResetPasswordSuccess.js +17 -5
  24. package/src/components/molecules/reset-password-success/ResetPasswordSuccess.theme.js +9 -0
  25. package/src/.DS_Store +0 -0
  26. package/src/components/.DS_Store +0 -0
  27. package/src/components/molecules/.DS_Store +0 -0
  28. package/src/components/molecules/obligation/Obligation.theme.js +0 -7
  29. package/src/stories/Button.stories.ts +0 -53
  30. package/src/stories/Button.tsx +0 -48
  31. package/src/stories/Configure.mdx +0 -364
  32. package/src/stories/Header.stories.ts +0 -33
  33. package/src/stories/Header.tsx +0 -56
  34. package/src/stories/Page.stories.ts +0 -32
  35. package/src/stories/Page.tsx +0 -73
  36. package/src/stories/assets/accessibility.png +0 -0
  37. package/src/stories/assets/accessibility.svg +0 -5
  38. package/src/stories/assets/addon-library.png +0 -0
  39. package/src/stories/assets/assets.png +0 -0
  40. package/src/stories/assets/avif-test-image.avif +0 -0
  41. package/src/stories/assets/context.png +0 -0
  42. package/src/stories/assets/discord.svg +0 -15
  43. package/src/stories/assets/docs.png +0 -0
  44. package/src/stories/assets/figma-plugin.png +0 -0
  45. package/src/stories/assets/github.svg +0 -3
  46. package/src/stories/assets/share.png +0 -0
  47. package/src/stories/assets/styling.png +0 -0
  48. package/src/stories/assets/testing.png +0 -0
  49. package/src/stories/assets/theming.png +0 -0
  50. package/src/stories/assets/tutorials.svg +0 -12
  51. package/src/stories/assets/youtube.svg +0 -4
  52. package/src/stories/button.css +0 -30
  53. package/src/stories/header.css +0 -32
  54. package/src/stories/page.css +0 -69
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thecb/components",
3
- "version": "10.7.0-beta.2",
3
+ "version": "10.7.1-beta.1",
4
4
  "description": "Common lib for CityBase react components",
5
5
  "main": "dist/index.cjs.js",
6
6
  "typings": "dist/index.d.ts",
@@ -89,8 +89,6 @@ const ButtonWithAction = forwardRef(
89
89
  variant
90
90
  );
91
91
  const { isMobile } = themeContext;
92
- console.log("button text / theme context is", text, themeContext);
93
- console.log("button text / theme values are", text, themeValues);
94
92
 
95
93
  const hoverStyles = `
96
94
  outline: none;
@@ -7,7 +7,6 @@ import { ThemeContext } from "styled-components";
7
7
  import Module from "../../molecules/module/Module";
8
8
  import Spinner from "../spinner/Spinner";
9
9
  import { CHARADE_GREY } from "../../../constants/colors";
10
- import { noop } from "../../../util/general";
11
10
 
12
11
  const WalletName = ({
13
12
  mainText, // left side text
@@ -16,7 +15,9 @@ const WalletName = ({
16
15
  actionText = null, // right side hyperlinked text
17
16
  disableAction = false,
18
17
  linkButtonExtraStyles = "", // hyperlinked text extraStyles
19
- isLoading = false // shows a spinner on the left when true
18
+ isLoading = false, // shows a spinner on the left when true
19
+ dataQa = null,
20
+ actionTextPositionMobile = "outside" // whether action text is outside/below box or inside it
20
21
  }) => {
21
22
  const { isMobile } = useContext(ThemeContext);
22
23
 
@@ -49,7 +50,7 @@ const WalletName = ({
49
50
  mainText && <Text>{mainText}</Text>
50
51
  )}
51
52
  </Box>
52
- {!isMobile && (
53
+ {(actionTextPositionMobile === "inside" || !isMobile) && (
53
54
  <Box padding="0">
54
55
  {text && <Text variant="pXS">{text}</Text>}
55
56
  {(text || actionText) && <>&nbsp;</>}
@@ -57,6 +58,7 @@ const WalletName = ({
57
58
  <ButtonWithAction
58
59
  disabled={disableAction}
59
60
  text={actionText}
61
+ dataQa={dataQa}
60
62
  action={action}
61
63
  variant="smallGhost"
62
64
  extraStyles={`
@@ -71,7 +73,7 @@ const WalletName = ({
71
73
  )}
72
74
  </Cluster>
73
75
  </Module>
74
- {isMobile && (
76
+ {!!isMobile && actionTextPositionMobile === "outside" && (
75
77
  <Cluster
76
78
  align="center"
77
79
  justify={text || actionText ? "flex-end" : "flex-start"}
@@ -1,6 +1,6 @@
1
1
  import React from "react";
2
2
  import WalletName from "./WalletName";
3
- import { text, object, boolean } from "@storybook/addon-knobs";
3
+ import { text, object, boolean, select } from "@storybook/addon-knobs";
4
4
  import page from "../../../../.storybook/page";
5
5
 
6
6
  export const walletName = () => {
@@ -12,6 +12,31 @@ export const walletName = () => {
12
12
  text={text("text", "Not you?", "props")}
13
13
  disableAction={boolean("disableAction", false, "props")}
14
14
  isLoading={boolean("isLoading", false, "props")}
15
+ actionTextPositionMobile={select(
16
+ "actionTextPositionMobile",
17
+ { inside: "inside", outside: "outside" },
18
+ "outside",
19
+ "props"
20
+ )}
21
+ />
22
+ );
23
+ };
24
+
25
+ export const walletNameWithOverrides = () => {
26
+ return (
27
+ <WalletName
28
+ mainText={text("mainText", "Firstname Lastname", "props")}
29
+ action={object("action", () => window.alert("action fired!"), "props")}
30
+ actionText={text("actionText", "Check out as a guest", "props")}
31
+ text={text("text", "Not you?", "props")}
32
+ disableAction={boolean("disableAction", false, "props")}
33
+ isLoading={boolean("isLoading", false, "props")}
34
+ actionTextPositionMobile={select(
35
+ "actionTextPositionMobile",
36
+ { inside: "inside", outside: "outside" },
37
+ "outside",
38
+ "props"
39
+ )}
15
40
  />
16
41
  );
17
42
  };
@@ -9,6 +9,8 @@ export interface WalletNameProps {
9
9
  text?: string | null;
10
10
  isLoading: boolean;
11
11
  buttonExtraStyles?: string;
12
+ dataQa?: string | null;
13
+ actionTextPositionMobile?: "inside" | "outside";
12
14
  }
13
15
 
14
16
  export const WalletName: React.FC<Expand<WalletNameProps> &
@@ -15,8 +15,6 @@ import {
15
15
  InactiveControlsModule,
16
16
  InactiveTitleModule
17
17
  } from "./modules";
18
- import { themeComponent } from "../../../util/themeUtils";
19
- import { fallbackValues } from "./Obligation.theme";
20
18
 
21
19
  const Obligation = ({
22
20
  config,
@@ -39,8 +37,7 @@ const Obligation = ({
39
37
  inactiveLookupTitle = "",
40
38
  inactiveLookupInput = "Account",
41
39
  inactiveLookupValue = "",
42
- isInCustomerManagement = false,
43
- themeValues
40
+ isInCustomerManagement = false
44
41
  }) => {
45
42
  /*
46
43
  The value of obligations is always an array. It can contain:
@@ -91,7 +88,6 @@ const Obligation = ({
91
88
  configIconMap={config.iconMap}
92
89
  iconValue={config.iconValue}
93
90
  customAttributes={customAttributes}
94
- iconColor={themeValues.iconColor}
95
91
  />
96
92
  )}
97
93
  <TitleModule
@@ -198,7 +194,6 @@ const Obligation = ({
198
194
  configIconMap={config.iconMap}
199
195
  iconValue={config.iconValue}
200
196
  customAttributes={customAttributes}
201
- iconColor={themeValues.iconColor}
202
197
  />
203
198
  <InactiveTitleModule
204
199
  title={inactiveLookupTitle}
@@ -261,4 +256,4 @@ const Obligation = ({
261
256
  return inactive ? inactiveObligation : activeObligation;
262
257
  };
263
258
 
264
- export default themeComponent(Obligation, "Obligation", fallbackValues);
259
+ export default Obligation;
@@ -4,7 +4,7 @@ import { Box, Stack } from "../../../atoms/layouts";
4
4
  import Text from "../../../atoms/text";
5
5
  import { FONT_WEIGHT_SEMIBOLD } from "../../../../constants/style_constants";
6
6
  import { displayCurrency, noop } from "../../../../util/general";
7
- import AutopayModalModule from "./AutopayModalModule";
7
+ import { AutopayModalModule } from "./AutopayModalModule";
8
8
 
9
9
  const AmountModule = ({
10
10
  totalAmountDue,
@@ -6,10 +6,11 @@ import { AutopayOnIcon } from "../../../atoms/icons";
6
6
  import { Box, Cluster } from "../../../atoms/layouts";
7
7
  import { SEA_GREEN } from "../../../../constants/colors";
8
8
  import { ACH_METHOD, CC_METHOD } from "../../../../constants/general";
9
+ import { fallbackValues } from "./AutopayModalModule.theme";
10
+ import { themeComponent } from "../../../../util/themeUtils";
9
11
  import { titleCaseString, noop } from "../../../../util/general";
10
- import { FONT_WEIGHT_REGULAR } from "../../../../constants/style_constants";
11
12
 
12
- const AutopayModalModule = ({
13
+ const AutopayModal = ({
13
14
  autoPayActive,
14
15
  autoPaySchedule,
15
16
  paymentPlanSchedule,
@@ -19,6 +20,7 @@ const AutopayModalModule = ({
19
20
  navigateToSettings,
20
21
  controlType = "tertiary",
21
22
  isMobile,
23
+ themeValues,
22
24
  isPaymentPlan,
23
25
  nextAutopayDate,
24
26
  dueDate,
@@ -73,12 +75,6 @@ const AutopayModalModule = ({
73
75
  }
74
76
  : navigateToSettings
75
77
  };
76
- const modalLinkHoverFocus = `
77
- outline: none;
78
- cursor: pointer;
79
- text-decoration: underline;
80
- text-decoration-color: #317D4F;
81
- `;
82
78
 
83
79
  const hoverStyles = "text-decoration: underline;";
84
80
  const activeStyles = "text-decoration: underline;";
@@ -146,8 +142,8 @@ const AutopayModalModule = ({
146
142
  tabIndex="0"
147
143
  dataQa={`${shortPlan} On`}
148
144
  color={SEA_GREEN}
149
- weight={FONT_WEIGHT_REGULAR}
150
- hoverStyles={modalLinkHoverFocus}
145
+ weight={themeValues.fontWeight}
146
+ hoverStyles={themeValues.modalLinkHoverFocus}
151
147
  extraStyles={`padding-left: 0.25rem;`}
152
148
  disabled={disableActions}
153
149
  >
@@ -171,4 +167,8 @@ const AutopayModalModule = ({
171
167
  );
172
168
  };
173
169
 
174
- export default AutopayModalModule;
170
+ export const AutopayModalModule = themeComponent(
171
+ AutopayModal,
172
+ "AutopayModal",
173
+ fallbackValues
174
+ );
@@ -0,0 +1,20 @@
1
+ import { FONT_WEIGHT_REGULAR } from "../../../../constants/style_constants";
2
+
3
+ const color = "#15749D";
4
+ const hoverColor = "#116285";
5
+ const activeColor = "#0E506D";
6
+ const linkColor = "#3176AA";
7
+ const fontWeight = FONT_WEIGHT_REGULAR;
8
+ const modalLinkHoverFocus = `outline: none;
9
+ cursor: pointer;
10
+ text-decoration: underline;
11
+ text-decoration-color: #317D4F;`;
12
+
13
+ export const fallbackValues = {
14
+ color,
15
+ hoverColor,
16
+ activeColor,
17
+ linkColor,
18
+ fontWeight,
19
+ modalLinkHoverFocus
20
+ };
@@ -1,6 +1,10 @@
1
1
  import React from "react";
2
2
  import { iconsMap } from "../icons";
3
3
  import { Box, Cluster } from "../../../atoms/layouts";
4
+ import { themeComponent } from "../../../../util/themeUtils";
5
+ import { fallbackValues } from "../../../atoms/icons/Icons.theme";
6
+
7
+ // Uses the theme values (singleIconColor) for the other icons, located in /atoms/icons
4
8
 
5
9
  const IconsModule = ({
6
10
  icon,
@@ -8,7 +12,7 @@ const IconsModule = ({
8
12
  configIconMap,
9
13
  iconValue,
10
14
  customAttributes,
11
- iconColor
15
+ themeValues
12
16
  }) => {
13
17
  let Icon;
14
18
  if (typeof icon === "object") {
@@ -21,10 +25,10 @@ const IconsModule = ({
21
25
  return (
22
26
  <Box padding="0 1rem 0 0">
23
27
  <Cluster justify="center" align="center">
24
- <Icon color={iconColor} />
28
+ <Icon color={themeValues.singleIconColor} />
25
29
  </Cluster>
26
30
  </Box>
27
31
  );
28
32
  };
29
33
 
30
- export default IconsModule;
34
+ export default themeComponent(IconsModule, "Icon", fallbackValues, "primary");
@@ -1,7 +1,7 @@
1
1
  import React, { useState } from "react";
2
2
  import { GHOST_GREY } from "../../../../constants/colors";
3
3
  import { Box, Cluster } from "../../../atoms/layouts";
4
- import AutopayModalModule from "./AutopayModalModule";
4
+ import { AutopayModalModule } from "./AutopayModalModule";
5
5
  import RemoveAccountModalModule from "./RemoveAccountModalModule";
6
6
  import { noop } from "../../../../util/general";
7
7
 
@@ -1,7 +1,7 @@
1
1
  import React, { useState } from "react";
2
2
  import { Box, Cluster } from "../../../atoms/layouts";
3
3
  import ButtonWithAction from "../../../atoms/button-with-action";
4
- import AutopayModalModule from "./AutopayModalModule";
4
+ import { AutopayModalModule } from "./AutopayModalModule";
5
5
  import { GHOST_GREY } from "../../../../constants/colors";
6
6
  import AmountModule from "./AmountModule";
7
7
  import { noop } from "../../../../util/general";
@@ -25,7 +25,9 @@ const PaymentButtonBar = ({
25
25
  hideBackButton = false,
26
26
  buttonGroupStyles,
27
27
  hideAdditionalButton = false,
28
- additionalButton
28
+ additionalButton,
29
+ nextButtonTestId = null,
30
+ backButtonTestId = null
29
31
  }) => {
30
32
  const { isMobile } = useContext(ThemeContext);
31
33
 
@@ -36,7 +38,7 @@ const PaymentButtonBar = ({
36
38
  url={cancelURL}
37
39
  variant={backButtonVariant}
38
40
  extraStyles={isMobile && "flex-grow: 1"}
39
- dataQa={cancelText}
41
+ dataQa={backButtonTestId || cancelText}
40
42
  aria-labelledby={`${kebabCaseString(cancelText)}-button`}
41
43
  role="link"
42
44
  />
@@ -60,7 +62,7 @@ const PaymentButtonBar = ({
60
62
  text={redirectText}
61
63
  variant={forwardButtonVariant}
62
64
  extraStyles={isMobile && "flex-grow: 1"}
63
- dataQa={redirectText}
65
+ dataQa={nextButtonTestId || redirectText}
64
66
  disabled={isForwardButtonDisabled}
65
67
  aria-labelledby={`${kebabCaseString(redirectText)}-button`}
66
68
  role={forwardButtonAriaRole}
@@ -73,7 +75,7 @@ const PaymentButtonBar = ({
73
75
  action={forwardButtonAction}
74
76
  isLoading={forwardButtonLoading}
75
77
  extraStyles={isMobile && "flex-grow: 1"}
76
- dataQa={forwardButtonText}
78
+ dataQa={nextButtonTestId || forwardButtonText}
77
79
  disabled={isForwardButtonDisabled}
78
80
  aria-labelledby={`${kebabCaseString(forwardButtonText)}-button`}
79
81
  role={forwardButtonAriaRole}
@@ -58,6 +58,7 @@ const RadioSection = ({
58
58
  ariaDescribedBy,
59
59
  isSectionRequired = false,
60
60
  groupedSections,
61
+ borderOverride,
61
62
  ...rest
62
63
  }) => {
63
64
  const [focused, setFocused] = useState(null);
@@ -98,7 +99,7 @@ const RadioSection = ({
98
99
  return (
99
100
  <Box
100
101
  padding="1px"
101
- border={`1px solid ${themeValues.borderColor}`}
102
+ border={borderOverride || `1px solid ${themeValues.borderColor}`}
102
103
  borderRadius="4px"
103
104
  extraStyles={containerStyles}
104
105
  role="radiogroup"
@@ -3,14 +3,22 @@ import { ThemeContext } from "styled-components";
3
3
  import Heading from "../../atoms/heading";
4
4
  import Paragraph from "../../atoms/paragraph";
5
5
  import { Box, Cluster } from "../../atoms/layouts";
6
- import { GRECIAN_GREY, CHARADE_GREY, WHITE } from "../../../constants/colors";
6
+ import { CHARADE_GREY, WHITE } from "../../../constants/colors";
7
7
  import ButtonWithLink from "../../atoms/button-with-link";
8
8
  import { ForgotPasswordIcon } from "../../atoms/icons";
9
9
  import withWindowSize from "../../withWindowSize";
10
10
  import { FormContainer, FormInputColumn } from "../../atoms/form-layouts";
11
+ import { fallbackValues } from "./ResetConfirmationForm.theme";
12
+ import { createThemeValues } from "../../../util/themeUtils";
11
13
 
12
14
  const ResetConfirmationForm = () => {
13
- const { isMobile } = useContext(ThemeContext);
15
+ const themeContext = useContext(ThemeContext);
16
+ const themeValues = createThemeValues(
17
+ themeContext,
18
+ fallbackValues,
19
+ "ResetConfirmationForm"
20
+ );
21
+ const { isMobile } = themeContext;
14
22
 
15
23
  return (
16
24
  <Box
@@ -20,7 +28,11 @@ const ResetConfirmationForm = () => {
20
28
  background={WHITE}
21
29
  boxShadow="0px 2px 14px 0px rgb(246, 246, 249), 0px 3px 8px 0px rgb(202, 206, 216)"
22
30
  >
23
- <Box background={GRECIAN_GREY} minWidth="100%" padding="0.5rem">
31
+ <Box
32
+ background={themeValues.bannerBackgroundColor}
33
+ minWidth="100%"
34
+ padding="0.5rem"
35
+ >
24
36
  <Cluster justify="center" align="center">
25
37
  <ForgotPasswordIcon />
26
38
  </Cluster>
@@ -0,0 +1,9 @@
1
+ import { colors } from "../../../constants";
2
+
3
+ const { GRECIAN_GREY } = colors;
4
+
5
+ const bannerBackgroundColor = GRECIAN_GREY;
6
+
7
+ export const fallbackValues = {
8
+ bannerBackgroundColor
9
+ };
@@ -3,14 +3,22 @@ import { ThemeContext } from "styled-components";
3
3
  import Heading from "../../atoms/heading";
4
4
  import Paragraph from "../../atoms/paragraph";
5
5
  import { Box, Cluster } from "../../atoms/layouts";
6
- import { GRECIAN_GREY, CHARADE_GREY, WHITE } from "../../../constants/colors";
6
+ import { CHARADE_GREY, WHITE } from "../../../constants/colors";
7
7
  import ButtonWithLink from "../../atoms/button-with-link";
8
8
  import { ForgotPasswordIcon } from "../../atoms/icons";
9
9
  import withWindowSize from "../../withWindowSize";
10
10
  import { FormContainer, FormInputColumn } from "../../atoms/form-layouts";
11
+ import { fallbackValues } from "./ResetPasswordSuccess.theme";
12
+ import { createThemeValues } from "../../../util/themeUtils";
11
13
 
12
- const ResetConfirmationForm = () => {
13
- const { isMobile } = useContext(ThemeContext);
14
+ const ResetPasswordSuccess = () => {
15
+ const themeContext = useContext(ThemeContext);
16
+ const themeValues = createThemeValues(
17
+ themeContext,
18
+ fallbackValues,
19
+ "ResetPasswordSuccess"
20
+ );
21
+ const { isMobile } = themeContext;
14
22
 
15
23
  return (
16
24
  <Box
@@ -20,7 +28,11 @@ const ResetConfirmationForm = () => {
20
28
  background={WHITE}
21
29
  boxShadow="0px 2px 14px 0px rgb(246, 246, 249), 0px 3px 8px 0px rgb(202, 206, 216)"
22
30
  >
23
- <Box background={GRECIAN_GREY} minWidth="100%" padding="0.5rem">
31
+ <Box
32
+ background={themeValues.bannerBackgroundColor}
33
+ minWidth="100%"
34
+ padding="0.5rem"
35
+ >
24
36
  <Cluster justify="center" align="center">
25
37
  <ForgotPasswordIcon />
26
38
  </Cluster>
@@ -53,4 +65,4 @@ const ResetConfirmationForm = () => {
53
65
  </Box>
54
66
  );
55
67
  };
56
- export default withWindowSize(ResetConfirmationForm);
68
+ export default withWindowSize(ResetPasswordSuccess);
@@ -0,0 +1,9 @@
1
+ import { colors } from "../../../constants";
2
+
3
+ const { GRECIAN_GREY } = colors;
4
+
5
+ const bannerBackgroundColor = GRECIAN_GREY;
6
+
7
+ export const fallbackValues = {
8
+ bannerBackgroundColor
9
+ };
package/src/.DS_Store DELETED
Binary file
Binary file
Binary file
@@ -1,7 +0,0 @@
1
- import { ROYAL_BLUE_VIVID } from "../../../constants/colors";
2
-
3
- const iconColor = ROYAL_BLUE_VIVID;
4
-
5
- export const fallbackValues = {
6
- iconColor
7
- };
@@ -1,53 +0,0 @@
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
- };
@@ -1,48 +0,0 @@
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
- };