@thecb/components 10.1.3-beta.4 → 10.2.1-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 (32) hide show
  1. package/README.md +2 -2
  2. package/dist/index.cjs.js +210 -145
  3. package/dist/index.cjs.js.map +1 -1
  4. package/dist/index.d.ts +36 -0
  5. package/dist/index.esm.js +209 -144
  6. package/dist/index.esm.js.map +1 -1
  7. package/package.json +1 -1
  8. package/src/components/atoms/breadcrumb/Breadcrumb.js +4 -3
  9. package/src/components/atoms/breadcrumb/Breadcrumb.theme.js +5 -2
  10. package/src/components/atoms/button-with-action/ButtonWithAction.js +9 -12
  11. package/src/components/atoms/button-with-action/ButtonWithAction.stories.js +4 -1
  12. package/src/components/atoms/button-with-action/ButtonWithAction.theme.js +22 -2
  13. package/src/components/atoms/button-with-link/ButtonWithLink.js +7 -3
  14. package/src/components/atoms/layouts/Box.styled.js +15 -0
  15. package/src/components/atoms/link/ExternalLink.styled.js +6 -3
  16. package/src/components/atoms/link/InternalLink.styled.js +6 -3
  17. package/src/components/atoms/text/Text.js +2 -0
  18. package/src/components/atoms/text/Text.styled.js +1 -0
  19. package/src/components/molecules/obligation/modules/AutopayModalModule.js +9 -11
  20. package/src/components/molecules/pagination/Pagination.js +1 -7
  21. package/src/components/molecules/pagination/Pagination.stories.js +32 -0
  22. package/src/components/molecules/pagination/Pagination.theme.js +1 -2
  23. package/src/components/molecules/tab-sidebar/TabSidebar.js +0 -1
  24. package/src/constants/index.d.ts +2 -1
  25. package/src/constants/index.js +12 -3
  26. package/src/constants/style_constants.d.ts +11 -0
  27. package/src/constants/style_constants.js +3 -1
  28. package/dist/src/apps/checkout/pages/payment/sub-pages/payment-amount/PaymentAmount_old.js +0 -49322
  29. package/src/.DS_Store +0 -0
  30. package/src/components/.DS_Store +0 -0
  31. package/src/components/atoms/.DS_Store +0 -0
  32. package/src/components/atoms/icons/.DS_Store +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thecb/components",
3
- "version": "10.1.3-beta.4",
3
+ "version": "10.2.1-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",
@@ -34,14 +34,15 @@ const Breadcrumbs = ({ breadcrumbsList = [] }) => {
34
34
  extraStyles={`
35
35
  text-transform: uppercase;
36
36
  ${isActive.toString() === "true" &&
37
- `pointer-events: none;
38
- color: ${themeValues.activeBreadcrumbColor};
37
+ `color: ${themeValues.activeBreadcrumbColor};
38
+ pointer-events: none;
39
+ text-decoration: none;
39
40
  `}
40
41
  &:first-child {
41
42
  margin-left: 0;
42
43
  }
43
44
  &:active {
44
- color: ${themeValues.activeColor};
45
+ color: ${themeValues.activeColor};
45
46
  }`}
46
47
  >
47
48
  {linkText}
@@ -1,5 +1,8 @@
1
1
  // import theme from "styled-theming";
2
- import { MATISSE_BLUE, STORM_GREY } from "../../../constants/colors";
2
+ import { colors, styleConstants } from "../../../constants";
3
+
4
+ const { MATISSE_BLUE, STORM_GREY } = colors;
5
+ const { LINK_TEXT_DECORATION } = styleConstants;
3
6
 
4
7
  /*
5
8
  For now I'm using string values, eventually shared components library will have its own constants file
@@ -13,7 +16,7 @@ const fontSize = "0.875rem";
13
16
  const lineHeight = "1.25rem";
14
17
  const fontWeight = "400";
15
18
  const margin = "0.5rem";
16
- const hover = `text-decoration: none;`;
19
+ const hover = `text-decoration: ${LINK_TEXT_DECORATION};`;
17
20
 
18
21
  export const fallbackValues = {
19
22
  color,
@@ -57,7 +57,7 @@ const Spinner = ({ color, isMobile }) => (
57
57
 
58
58
  Note: the children prop is only used if contentOverride is set to true, in which case
59
59
  the text prop is ignored.
60
-
60
+
61
61
  */
62
62
 
63
63
  const ButtonWithAction = forwardRef(
@@ -68,6 +68,7 @@ const ButtonWithAction = forwardRef(
68
68
  text,
69
69
  textWrap = false,
70
70
  isLoading = false,
71
+ disabled = false,
71
72
  loadingColor = "white",
72
73
  dataQa = null,
73
74
  textExtraStyles,
@@ -94,9 +95,6 @@ const ButtonWithAction = forwardRef(
94
95
  background-color: ${themeValues.hoverBackgroundColor};
95
96
  border-color: ${themeValues.hoverBorderColor};
96
97
  color: ${themeValues.hoverColor};
97
- text-decoration: ${
98
- variant === "ghost" || variant === "smallGhost" ? "underline" : "none"
99
- };
100
98
  cursor: pointer;
101
99
  `;
102
100
  const activeStyles = `
@@ -104,9 +102,6 @@ const ButtonWithAction = forwardRef(
104
102
  background-color: ${themeValues.activeBackgroundColor};
105
103
  border-color: ${themeValues.activeBorderColor};
106
104
  color: ${themeValues.activeColor};
107
- text-decoration: ${
108
- variant === "ghost" || variant === "smallGhost" ? "underline" : "none"
109
- };
110
105
  `;
111
106
  const disabledStyles = `
112
107
  background-color: #6D717E;
@@ -114,8 +109,8 @@ const ButtonWithAction = forwardRef(
114
109
  color: #FFFFFF;
115
110
  cursor: default;
116
111
  &:focus {
117
- box-shadow: 0 0 10px #6D717E;
118
- outline: none;
112
+ outline: 3px solid #6D717E;
113
+ outline-offset: 2px;
119
114
  }
120
115
  ${extraDisabledStyles}
121
116
  `;
@@ -129,11 +124,12 @@ const ButtonWithAction = forwardRef(
129
124
  minWidth={themeValues.minWidth}
130
125
  background={themeValues.backgroundColor}
131
126
  border={themeValues.border}
132
- hoverStyles={hoverStyles}
133
- activeStyles={activeStyles}
127
+ hoverStyles={disabled ? disabledStyles : hoverStyles}
128
+ activeStyles={disabled ? disabledStyles : activeStyles}
134
129
  disabledStyles={disabledStyles}
130
+ aria-disabled={disabled}
135
131
  as="button"
136
- onClick={isLoading ? undefined : action}
132
+ onClick={isLoading || disabled ? undefined : action}
137
133
  borderRadius="2px"
138
134
  theme={themeContext}
139
135
  extraStyles={`margin: 0.5rem; ${extraStyles}`}
@@ -152,6 +148,7 @@ const ButtonWithAction = forwardRef(
152
148
  weight={themeValues.fontWeight}
153
149
  variant={themeValues.fontSizeVariant}
154
150
  color={themeValues.color}
151
+ textDecoration={themeValues.textDecoration}
155
152
  textWrap={textWrap}
156
153
  extraStyles={textExtraStyles}
157
154
  >
@@ -18,12 +18,15 @@ const variants = {
18
18
  const defaultValue = "primary";
19
19
  const groupId = "props";
20
20
 
21
+ const buttonHandler = () => console.log("Button selected");
22
+
21
23
  export const buttonWithAction = () => (
22
24
  <ButtonWithAction
23
25
  variant={select(variantsLabel, variants, defaultValue, groupId)}
24
26
  text={text("text", "button", "props")}
25
27
  isLoading={boolean("isLoading", false, "props")}
26
- action={text("action", undefined, "props")}
28
+ action={text("action", buttonHandler, "props")}
29
+ disabled={boolean("disabled", false, "props")}
27
30
  />
28
31
  );
29
32
 
@@ -1,4 +1,6 @@
1
- import {
1
+ import { colors, styleConstants } from "../../../constants";
2
+
3
+ const {
2
4
  WHITE,
3
5
  TRANSPARENT,
4
6
  SAPPHIRE_BLUE,
@@ -6,7 +8,9 @@ import {
6
8
  MATISSE_BLUE,
7
9
  RASPBERRY,
8
10
  ERROR_COLOR
9
- } from "../../../constants/colors";
11
+ } = colors;
12
+
13
+ const { LINK_TEXT_DECORATION } = styleConstants;
10
14
 
11
15
  const padding = {
12
16
  primary: "0.75rem 1.5rem",
@@ -98,6 +102,21 @@ const minWidth = {
98
102
  whitePrimary: "130px"
99
103
  };
100
104
 
105
+ const textDecoration = {
106
+ primary: "none",
107
+ secondary: "none",
108
+ back: "none",
109
+ smallPrimary: "none",
110
+ smallSecondary: "none",
111
+ smallGhost: LINK_TEXT_DECORATION,
112
+ ghost: LINK_TEXT_DECORATION,
113
+ tertiary: "none",
114
+ danger: "none",
115
+ dangerSecondary: "none",
116
+ whiteSecondary: "none",
117
+ whitePrimary: "none"
118
+ };
119
+
101
120
  const backgroundColor = {
102
121
  primary: MATISSE_BLUE,
103
122
  secondary: TRANSPARENT,
@@ -225,6 +244,7 @@ export const fallbackValues = {
225
244
  fontWeight,
226
245
  height,
227
246
  minWidth,
247
+ textDecoration,
228
248
  backgroundColor,
229
249
  border,
230
250
  hoverBackgroundColor,
@@ -9,8 +9,8 @@ const ButtonWithLink = ({
9
9
  url = "/",
10
10
  disabled = false,
11
11
  fileLink = false,
12
- extraStyles,
13
- linkExtraStyles,
12
+ extraStyles = "",
13
+ linkExtraStyles = "",
14
14
  newTab = false,
15
15
  dataQa,
16
16
  ...otherProps
@@ -57,7 +57,11 @@ const ButtonWithLink = ({
57
57
  text-decoration: none; }`}
58
58
  dataQa={dataQa}
59
59
  >
60
- <ButtonWithAction {...otherProps} extraStyles={extraStyles} />
60
+ <ButtonWithAction
61
+ {...otherProps}
62
+ disabled={disabled}
63
+ extraStyles={extraStyles}
64
+ />
61
65
  </ButtonWithLinkWrapper>
62
66
  );
63
67
  };
@@ -107,6 +107,21 @@ export const BoxWrapper = styled(
107
107
  : ``}
108
108
  `}
109
109
  }
110
+
111
+ &[aria-disabled="true"] {
112
+ ${({ disabledStyles, as }) =>
113
+ css`
114
+ ${disabledStyles}
115
+ ${as === "button"
116
+ ? ` > * > span {
117
+ ${disabledStyles}
118
+ border: none;
119
+ outline: none;
120
+ box-shadow: none;
121
+ }`
122
+ : ``}
123
+ `}
124
+ }
110
125
 
111
126
  & * {
112
127
  color: ${({ color }) => color};
@@ -1,6 +1,10 @@
1
1
  import React, { forwardRef } from "react";
2
2
  import styled from "styled-components";
3
- import { ROYAL_BLUE } from "../../../constants/colors";
3
+ import { colors, styleConstants } from "../../../constants";
4
+
5
+ const { ROYAL_BLUE } = colors;
6
+ const { LINK_TEXT_DECORATION } = styleConstants;
7
+
4
8
  /*
5
9
  The extracting of props and the disabling of the eslint rule is to stop React from complaining about
6
10
  unrecognized DOM attributes.
@@ -18,10 +22,10 @@ export const StyledExternalLink = styled(
18
22
  font-weight: ${({ weight }) => weight};
19
23
  font-family: ${({ fontFamily }) => fontFamily};
20
24
  line-height: ${({ lineheight }) => lineheight};
25
+ text-decoration: ${LINK_TEXT_DECORATION};
21
26
 
22
27
  &:hover {
23
28
  color: ${({ hoverColor }) => hoverColor};
24
- text-decoration: underline;
25
29
  }
26
30
 
27
31
  &:focus {
@@ -30,7 +34,6 @@ export const StyledExternalLink = styled(
30
34
  }
31
35
 
32
36
  &:active {
33
- text-decoration: underline;
34
37
  color: ${({ activeColor }) => activeColor};
35
38
  }
36
39
 
@@ -1,7 +1,11 @@
1
1
  import React, { forwardRef } from "react";
2
2
  import styled from "styled-components";
3
3
  import { Link } from "react-router-dom";
4
- import { ROYAL_BLUE } from "../../../constants/colors";
4
+ import { colors, styleConstants } from "../../../constants";
5
+
6
+ const { ROYAL_BLUE } = colors;
7
+ const { LINK_TEXT_DECORATION } = styleConstants;
8
+
5
9
  /*
6
10
  The extracting of props and the disabling of the eslint rule is to stop React from complaining about
7
11
  unrecognized DOM attributes.
@@ -24,10 +28,10 @@ export const StyledInternalLink = styled(
24
28
  font-size: ${({ fontSize }) => fontSize};
25
29
  font-family: ${({ fontFamily }) => fontFamily};
26
30
  margin: ${({ margin }) => margin};
31
+ text-decoration: ${LINK_TEXT_DECORATION};
27
32
 
28
33
  &:hover {
29
34
  color: ${({ hoverColor }) => hoverColor};
30
- text-decoration: underline;
31
35
  }
32
36
 
33
37
  &:focus {
@@ -36,7 +40,6 @@ export const StyledInternalLink = styled(
36
40
  }
37
41
 
38
42
  &:active {
39
- text-decoration: underline;
40
43
  color: ${({ activeColor }) => activeColor};
41
44
  }
42
45
 
@@ -10,6 +10,7 @@ const Text = ({
10
10
  themeValues,
11
11
  weight = FONT_WEIGHT_REGULAR,
12
12
  color = FIREFLY_GREY,
13
+ textDecoration = "none",
13
14
  textWrap = true,
14
15
  extraStyles = ``,
15
16
  hoverStyles,
@@ -26,6 +27,7 @@ const Text = ({
26
27
  weight={weight}
27
28
  color={color}
28
29
  fontFamily={themeValues.fontFamily}
30
+ textDecoration={textDecoration}
29
31
  as={as}
30
32
  extraStyles={extraStyles}
31
33
  hoverStyles={hoverStyles}
@@ -8,6 +8,7 @@ export const TextSpan = styled.span`
8
8
  font-weight: ${({ weight }) => weight};
9
9
  font-family: ${({ fontFamily }) => fontFamily};
10
10
  color: ${({ color }) => color};
11
+ text-decoration: ${textDecoration => textDecoration};
11
12
  white-space: ${({ $textWrap }) => ($textWrap ? "initial" : "nowrap")};
12
13
 
13
14
  &:hover {
@@ -43,23 +43,21 @@ const AutopayModal = ({
43
43
  };
44
44
  const plan = isPaymentPlan ? "your payment plan" : "autopay";
45
45
  const shortPlan = isPaymentPlan ? "Payment Plan" : "Autopay";
46
- const deactivateText = `Stop ${shortPlan.toLowerCase()} for ${titleCaseString(
47
- description
48
- )}: ${titleCaseString(subDescription)}`;
49
- const activateText = titleCaseString(
50
- `Set Up ${shortPlan} for ${description}: ${subDescription}`
51
- );
46
+ const deactivateText = `deactivate ${shortPlan} for ${description}: ${subDescription}`;
47
+ const activateText = `Set Up ${shortPlan} for ${description}: ${subDescription}`;
52
48
  const nextDate = dueDate || nextAutopayDate;
53
49
  const modalExtraProps = {
54
- modalHeaderText: autoPayActive ? deactivateText : activateText,
50
+ modalHeaderText: autoPayActive
51
+ ? titleCaseString(deactivateText)
52
+ : titleCaseString(activateText),
55
53
  modalBodyText: autoPayActive
56
- ? `Are you sure you want to stop ${plan}? ${
57
- !inactive && nextDate && nextDate !== "On"
58
- ? "Your next payment will be due on " + nextDate + "."
54
+ ? `Are you sure you want to deactivate ${plan}? ${
55
+ !inactive && nextDate
56
+ ? `Your next payment will be due on ${nextDate}.`
59
57
  : ""
60
58
  }`
61
59
  : generateMethodNeededText(plan, allowedPaymentInstruments),
62
- continueButtonText: autoPayActive ? `Stop ${shortPlan}` : "Add",
60
+ continueButtonText: autoPayActive ? `Disable ${shortPlan}` : "Add",
63
61
  useDangerButton: autoPayActive,
64
62
  continueAction: autoPayActive
65
63
  ? () => {
@@ -94,6 +94,7 @@ export const getPagesPanel = (page, pagesCount) => {
94
94
 
95
95
  const Pagination = ({
96
96
  activeBorderWidth = "3px",
97
+ ariaLabel,
97
98
  arrowColor,
98
99
  borderRadius = "3px",
99
100
  buttonHeight = "44px",
@@ -107,7 +108,6 @@ const Pagination = ({
107
108
  pageNext,
108
109
  pagePrevious,
109
110
  setCurrentPage,
110
- ariaLabel,
111
111
  themeValues
112
112
  }) => {
113
113
  const { isMobile } = useContext(ThemeContext);
@@ -115,12 +115,6 @@ const Pagination = ({
115
115
  const extraStyles = `
116
116
  min-width: ${buttonWidth}; min-height: 100%; padding: 0;
117
117
  border-radius: ${borderRadius};
118
- &:hover, &:focus {
119
- text-decoration: none;
120
- > * > span {
121
- text-decoration: none;
122
- }
123
- }
124
118
  > * > span {
125
119
  color: ${numberColor ?? themeValues.numberColor}
126
120
  }
@@ -0,0 +1,32 @@
1
+ import React from "react";
2
+ import { number, text } from "@storybook/addon-knobs";
3
+ import Pagination from "./Pagination";
4
+ import page from "../../../../.storybook/page";
5
+
6
+ export const pagination = () => (
7
+ <Pagination
8
+ activeBorderWidth={text("activeBorderWidth", "3px", "props")}
9
+ ariaLabel={text("ariaLabel", "Aria Label", "props")}
10
+ arrowColor={text("arrowColor", "#FFFFFF", "props")}
11
+ borderRadius={text("borderRadius", "3px", "props")}
12
+ buttonHeight={text("buttonHeight", "44px", "props")}
13
+ buttonWidth={text("buttonWidth", "44px", "props")}
14
+ childGap={text("childGap", "24px", "props")}
15
+ currentPage={number("currentPage", 2)}
16
+ fontSize={text("fontSize", "17px", "props")}
17
+ fontWeight={text("fontWeight", "900", "props")}
18
+ numberColor={text("numberColor", "#15749D", "props")}
19
+ pageCount={number("pageCount", 3)}
20
+ pageNext={() => {}}
21
+ pagePrevious={() => {}}
22
+ setCurrentPage={() => {}}
23
+ // themeValues
24
+ />
25
+ );
26
+
27
+ const story = page({
28
+ title: "Components|Molecules/Pagination",
29
+ Component: Pagination
30
+ });
31
+
32
+ export default story;
@@ -1,8 +1,7 @@
1
1
  import {
2
2
  WHITE,
3
3
  MATISSE_BLUE,
4
- ALABASTER_WHITE,
5
- STORM_GREY
4
+ ALABASTER_WHITE
6
5
  } from "../../../constants/colors";
7
6
 
8
7
  const arrowColor = WHITE;
@@ -36,7 +36,6 @@ const TabSidebar = ({ links, isMobile, themeValues }) => (
36
36
  to={route}
37
37
  key={`${route}-${index}`}
38
38
  extraStyles={`&:hover {
39
- text-decoration: none;
40
39
  ${
41
40
  active
42
41
  ? `> * {
@@ -1,3 +1,4 @@
1
1
  import * as colors from "./colors";
2
+ import * as styleConstants from "./style_constants";
2
3
 
3
- export { colors };
4
+ export { colors, styleConstants };
@@ -1,4 +1,13 @@
1
- import * as colors from "./colors";
2
- import * as fontWeights from "./style_constants";
1
+ export * as colors from "./colors";
2
+ export * as general from "./general";
3
+ export * as regexConstants from "./regex_constants";
4
+ export * as styleConstants from "./style_constants";
3
5
 
4
- export { colors, fontWeights };
6
+ /**
7
+ * This export is named "fontWeights" and referenced as such in much existing code.
8
+ * Navigate Frontend is one example that uses this particular export. However, new
9
+ * usage of style constants should reference the `styleConstants` export instead.
10
+ *
11
+ * @deprecated
12
+ */
13
+ export * as fontWeights from "./style_constants";
@@ -0,0 +1,11 @@
1
+ type StyleDeclaration = string;
2
+
3
+ export const HEADER_HEIGHT: StyleDeclaration;
4
+ export const FOOTER_HEIGHT: StyleDeclaration;
5
+ export const SPACER_HEIGHT: StyleDeclaration;
6
+ export const JUMBO_HEIGHT: StyleDeclaration;
7
+ export const COMPACT_JUMBO_HEIGHT: StyleDeclaration;
8
+ export const FONT_WEIGHT_REGULAR: StyleDeclaration;
9
+ export const FONT_WEIGHT_BOLD: StyleDeclaration;
10
+ export const FONT_WEIGHT_SEMIBOLD: StyleDeclaration;
11
+ export const LINK_TEXT_DECORATION: StyleDeclaration;
@@ -8,6 +8,7 @@ const COMPACT_JUMBO_HEIGHT = "65px";
8
8
  const FONT_WEIGHT_REGULAR = "400";
9
9
  const FONT_WEIGHT_BOLD = "700";
10
10
  const FONT_WEIGHT_SEMIBOLD = "600";
11
+ const LINK_TEXT_DECORATION = "underline solid 1px";
11
12
 
12
13
  export {
13
14
  HEADER_HEIGHT,
@@ -17,5 +18,6 @@ export {
17
18
  COMPACT_JUMBO_HEIGHT,
18
19
  FONT_WEIGHT_REGULAR,
19
20
  FONT_WEIGHT_BOLD,
20
- FONT_WEIGHT_SEMIBOLD
21
+ FONT_WEIGHT_SEMIBOLD,
22
+ LINK_TEXT_DECORATION
21
23
  };