@thecb/components 10.2.4-beta.0 → 10.2.4-beta.10

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thecb/components",
3
- "version": "10.2.4-beta.0",
3
+ "version": "10.2.4-beta.10",
4
4
  "description": "Common lib for CityBase react components",
5
5
  "main": "dist/index.cjs.js",
6
6
  "typings": "dist/index.d.ts",
@@ -32,9 +32,13 @@ const StyledBadge = styled(Text)`
32
32
 
33
33
  const Badge = ({ label, Icon, themeValues, iconOnLeft = true }) => (
34
34
  <StyledBadgeContainer background={themeValues.background}>
35
- {iconOnLeft && Icon && <Icon fill={themeValues.color} />}
35
+ {iconOnLeft && Icon && (
36
+ <Icon color={themeValues.color} fill={themeValues.color} />
37
+ )}
36
38
  <StyledBadge color={themeValues.color}>{label}</StyledBadge>
37
- {!iconOnLeft && Icon && <Icon fill={themeValues.color} />}
39
+ {!iconOnLeft && Icon && (
40
+ <Icon color={themeValues.color} fill={themeValues.color} />
41
+ )}
38
42
  </StyledBadgeContainer>
39
43
  );
40
44
 
@@ -9,7 +9,8 @@ const variants = {
9
9
  info: "info",
10
10
  warn: "warn",
11
11
  primary: "primary",
12
- success: "success"
12
+ success: "success",
13
+ disabled: "disabled"
13
14
  };
14
15
 
15
16
  const defaultValue = "success";
@@ -1,4 +1,6 @@
1
1
  import {
2
+ MANATEE_GREY,
3
+ GRECIAN_GREY,
2
4
  CORNFLOWER_BLUE,
3
5
  HALF_COLONIAL_WHITE,
4
6
  HINT_GREEN,
@@ -13,17 +15,19 @@ const background = {
13
15
  info: `${INFO_BLUE}`,
14
16
  warn: `${HALF_COLONIAL_WHITE}`,
15
17
  primary: `${CORNFLOWER_BLUE}`,
16
- success: `${HINT_GREEN}`
18
+ success: `${HINT_GREEN}`,
19
+ disabled: `${GRECIAN_GREY}`
17
20
  };
18
21
 
19
22
  const color = {
20
23
  info: `${MATISSE_BLUE}`,
21
24
  warn: `${ZEST_ORANGE}`,
22
25
  primary: `${ROYAL_BLUE_VIVID}`,
23
- success: `${SEA_GREEN}`
26
+ success: `${SEA_GREEN}`,
27
+ disabled: `${MANATEE_GREY}`
24
28
  };
25
29
 
26
30
  export const fallbackValues = {
27
- background,
28
- color
31
+ background: background,
32
+ color: color
29
33
  };
@@ -81,6 +81,7 @@ const ButtonWithAction = forwardRef(
81
81
  },
82
82
  ref
83
83
  ) => {
84
+ const isGhostVariant = variant === "ghost" || variant === "smallGhost";
84
85
  const themeContext = useContext(ThemeContext);
85
86
  const themeValues = createThemeValues(
86
87
  themeContext,
@@ -110,9 +111,9 @@ const ButtonWithAction = forwardRef(
110
111
  };
111
112
  `;
112
113
  const disabledStyles = `
113
- background-color: #6D717E;
114
- border-color: #6D717E;
115
- color: #FFFFFF;
114
+ background-color: ${isGhostVariant ? "transparent;" : "#6D717E;"};
115
+ border-color: ${isGhostVariant ? "transparent;" : "#6D717E;"};
116
+ color: ${isGhostVariant ? "#6D717E;" : "#FFFFFF"};
116
117
  cursor: default;
117
118
  &:focus {
118
119
  outline: 3px solid #6D717E;
@@ -155,7 +156,9 @@ const ButtonWithAction = forwardRef(
155
156
  variant={themeValues.fontSizeVariant}
156
157
  color={themeValues.color}
157
158
  textWrap={textWrap}
158
- extraStyles={textExtraStyles}
159
+ extraStyles={
160
+ disabled ? textExtraStyles + disabledStyles : textExtraStyles
161
+ }
159
162
  >
160
163
  {text}
161
164
  </Text>
@@ -1,7 +1,7 @@
1
1
  import React from "react";
2
2
 
3
3
  // Fill color based on default "success" variant color
4
- const AutopayIcon = ({ fill = "#317D4F" }) => (
4
+ const AutopayIcon = ({ fill = "#317D4F", color = "#317D4F" }) => (
5
5
  <svg
6
6
  width="16"
7
7
  height="16"
@@ -24,7 +24,7 @@ const AutopayIcon = ({ fill = "#317D4F" }) => (
24
24
  />
25
25
  </mask>
26
26
  <g mask="url(#mask0_5560_39870)">
27
- <path d="M0 0H16V16H0V0Z" fill={fill} />
27
+ <path d="M0 0H16V16H0V0Z" fill={fill || color} />
28
28
  </g>
29
29
  </svg>
30
30
  );
@@ -45,6 +45,7 @@ const Box = forwardRef(
45
45
  extraStyles,
46
46
  srOnly = false,
47
47
  dataQa,
48
+ disabled = false,
48
49
  children,
49
50
  ...rest
50
51
  },
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
- import { text, radios, select } from "@storybook/addon-knobs";
2
+ import { boolean, text, radios, select } from "@storybook/addon-knobs";
3
3
 
4
4
  import page from "../../../../../../.storybook/page";
5
5
  import Box from "../../Box";
@@ -47,6 +47,7 @@ export const box = () => (
47
47
  onFocus={text("onFocus", () => {}, groupId)}
48
48
  onBlur={text("onBlur", () => {}, groupId)}
49
49
  onTouchEnd={text("onTouchEnd", () => {}, groupId)}
50
+ disabled={boolean("disabled", false, groupId)}
50
51
  >
51
52
  Text Child
52
53
  <LayoutContentBlock
@@ -41,8 +41,12 @@ const PlaceholderContentWrapper = ({
41
41
  disabled = false
42
42
  }) =>
43
43
  isLink ? (
44
- <Link to={destination} data-qa={dataQa} disabled={disabled}>
45
- <Box padding="0" minHeight="100%" extraStyles={`cursor: pointer;`}>
44
+ <Link to={destination} data-qa={dataQa} aria-disabled={disabled}>
45
+ <Box
46
+ padding="0"
47
+ minHeight="100%"
48
+ extraStyles={disabled ? `cursor: default;` : `cursor: pointer;`}
49
+ >
46
50
  {children}
47
51
  </Box>
48
52
  </Link>
@@ -53,11 +57,7 @@ const PlaceholderContentWrapper = ({
53
57
  minHeight="100%"
54
58
  dataQa={dataQa}
55
59
  aria-disabled={disabled}
56
- extraStyles={
57
- disabled
58
- ? "cursor: default; opacity: 0.7;"
59
- : "cursor: pointer; opacity: 1;"
60
- }
60
+ extraStyles={disabled ? "cursor: default;" : "cursor: pointer;"}
61
61
  >
62
62
  {children}
63
63
  </Box>
@@ -74,21 +74,24 @@ const Placeholder = ({
74
74
  themeValues,
75
75
  dataQa,
76
76
  disabled = false
77
- }) => (
78
- <PlaceholderContentWrapper
79
- isLink={isLink}
80
- action={action}
81
- destination={destination}
82
- dataQa={dataQa}
83
- disabled={disabled}
84
- >
85
- <Box
86
- padding="0"
87
- borderRadius="4px"
88
- border="none"
89
- minHeight={themeValues.height}
90
- hiddenStyles={!visible}
91
- extraStyles={`
77
+ }) => {
78
+ const tintedColor = `${tint(0.9, themeValues.color)}`;
79
+
80
+ return (
81
+ <PlaceholderContentWrapper
82
+ isLink={isLink}
83
+ action={action}
84
+ destination={destination}
85
+ dataQa={dataQa}
86
+ disabled={disabled}
87
+ >
88
+ <Box
89
+ padding="0"
90
+ borderRadius="4px"
91
+ border="none"
92
+ minHeight={themeValues.height}
93
+ hiddenStyles={!visible}
94
+ extraStyles={`
92
95
  background: linear-gradient(
93
96
  to right,
94
97
  ${variant === "large" ? STORM_GREY : themeValues.color} 40%,
@@ -109,22 +112,22 @@ const Placeholder = ({
109
112
  display: flex;
110
113
  justify-content: center;
111
114
  align-items:center;`}
112
- hoverStyles={`background-color: ${
113
- variant === "large" ? GRECIAN_GREY : tint(0.9, themeValues.color)
114
- };`}
115
- >
116
- <Center maxWidth="300px">
117
- <Box
118
- padding="0"
119
- tabIndex="0"
120
- onKeyPress={e => e.key === "Enter" && !disabled && action()}
121
- >
122
- <Cluster justify="center" align="center" minHeight="100%">
123
- <Switcher maxChildren={2} childGap="0">
124
- {variant === "large" && <div></div>}
125
- <Box
126
- padding="0"
127
- extraStyles={`.fill {
115
+ hoverStyles={`background-color: ${
116
+ variant === "large" ? GRECIAN_GREY : tintedColor
117
+ };`}
118
+ >
119
+ <Center maxWidth="300px">
120
+ <Box
121
+ padding="0"
122
+ tabIndex="0"
123
+ onKeyPress={e => e.key === "Enter" && !disabled && action()}
124
+ >
125
+ <Cluster justify="center" align="center" minHeight="100%">
126
+ <Switcher maxChildren={2} childGap="0">
127
+ {variant === "large" && <div></div>}
128
+ <Box
129
+ padding="0"
130
+ extraStyles={`.fill {
128
131
  fill: ${
129
132
  variant === "large" ? CHARADE_GREY : themeValues.color
130
133
  };
@@ -133,44 +136,45 @@ const Placeholder = ({
133
136
  variant === "large" ? CHARADE_GREY : themeValues.color
134
137
  };
135
138
  }`}
136
- >
137
- {variant === "large" ? (
138
- <Center intrinsic>
139
- {getLargeIcon(largeIcon)}
140
- <Text
141
- variant="pS"
142
- color={themeValues.color}
143
- weight={FONT_WEIGHT_REGULAR}
144
- extraStyles={`text-align: center;`}
145
- >
146
- {text}
147
- </Text>
148
- </Center>
149
- ) : (
150
- <Cover singleChild minHeight="100%">
151
- <Cluster justify="center" align="center">
152
- <IconAdd />
153
- <Center intrinsic>
154
- <Text
155
- variant="pS"
156
- color={themeValues.color}
157
- weight={FONT_WEIGHT_REGULAR}
158
- extraStyles={`padding: 0 0 0 8px; text-align: center;`}
159
- >
160
- {text}
161
- </Text>
162
- </Center>
163
- </Cluster>
164
- </Cover>
165
- )}
166
- </Box>
167
- </Switcher>
168
- </Cluster>
169
- </Box>
170
- </Center>
171
- </Box>
172
- </PlaceholderContentWrapper>
173
- );
139
+ >
140
+ {variant === "large" ? (
141
+ <Center intrinsic>
142
+ {getLargeIcon(largeIcon)}
143
+ <Text
144
+ variant="pS"
145
+ color={themeValues.color}
146
+ weight={FONT_WEIGHT_REGULAR}
147
+ extraStyles={`text-align: center;`}
148
+ >
149
+ {text}
150
+ </Text>
151
+ </Center>
152
+ ) : (
153
+ <Cover singleChild minHeight="100%">
154
+ <Cluster justify="center" align="center">
155
+ <IconAdd />
156
+ <Center intrinsic>
157
+ <Text
158
+ variant="pS"
159
+ color={themeValues.color}
160
+ weight={FONT_WEIGHT_REGULAR}
161
+ extraStyles={`padding: 0 0 0 8px; text-align: center;`}
162
+ >
163
+ {text}
164
+ </Text>
165
+ </Center>
166
+ </Cluster>
167
+ </Cover>
168
+ )}
169
+ </Box>
170
+ </Switcher>
171
+ </Cluster>
172
+ </Box>
173
+ </Center>
174
+ </Box>
175
+ </PlaceholderContentWrapper>
176
+ );
177
+ };
174
178
 
175
179
  export default themeComponent(
176
180
  Placeholder,
@@ -4,8 +4,10 @@ import { themeComponent } from "../../../util/themeUtils";
4
4
  import { fallbackValues } from "./LinkCard.theme";
5
5
  import { ThemeContext } from "styled-components";
6
6
  import * as Styled from "./LinkCard.styled";
7
+ import { noop } from "../../../util/general";
7
8
 
8
9
  const LinkCard = ({
10
+ variant = "primary", // "primary" | "disabled"
9
11
  title = "Test Workflow",
10
12
  subtitle = "Link your benefit plan",
11
13
  showLeft,
@@ -17,7 +19,8 @@ const LinkCard = ({
17
19
  extraHoverStyles = "",
18
20
  extraActiveStyles = "",
19
21
  themeValues,
20
- titleVariant = "h3"
22
+ titleVariant = "h3",
23
+ disabled = false
21
24
  }) => {
22
25
  const { isMobile } = useContext(ThemeContext);
23
26
  const regex = /\W/g;
@@ -36,7 +39,8 @@ const LinkCard = ({
36
39
  extraStyles={extraStyles}
37
40
  hoverStyles={extraHoverStyles}
38
41
  activeStyles={extraActiveStyles}
39
- onClick={onClick}
42
+ onClick={disabled ? noop : onClick}
43
+ aria-disabled={disabled}
40
44
  >
41
45
  <Stack
42
46
  childGap={0}
@@ -63,9 +67,12 @@ const LinkCard = ({
63
67
  >
64
68
  <Styled.Footer direction="row" childGap="6px" justify="space-between">
65
69
  {/* To keep rightContent aligned right, use an empty Box as leftContent if none is provided */}
66
- {showLeft && !leftContent && <Box />}
67
- {showLeft && leftContent}
68
- {showRight && rightContent}
70
+ {showLeft && !!leftContent ? (
71
+ leftContent
72
+ ) : (
73
+ <Box extraStyles="margin-right: auto;" />
74
+ )}
75
+ {showRight && !!rightContent && rightContent}
69
76
  </Styled.Footer>
70
77
  </Box>
71
78
  </Stack>
@@ -73,4 +80,4 @@ const LinkCard = ({
73
80
  );
74
81
  };
75
82
 
76
- export default themeComponent(LinkCard, "LinkCard", fallbackValues);
83
+ export default themeComponent(LinkCard, "LinkCard", fallbackValues, "primary");
@@ -1,49 +1,79 @@
1
+ import page from "../../../../.storybook/page";
2
+ import { boolean, select, text } from "@storybook/addon-knobs";
1
3
  import React from "react";
2
4
  import LinkCard from "./LinkCard";
3
5
  import Box from "../../atoms/layouts/Box";
4
6
  import Stack from "../../atoms/layouts/Stack";
5
7
  import Text from "../../atoms/text/Text";
6
- import page from "../../../../.storybook/page";
7
- import { text } from "@storybook/addon-knobs";
8
8
  import Badge from "../../atoms/badge/Badge";
9
9
  import PlusCircleIcon from "../../atoms/icons/PlusCircleIcon";
10
10
  import AutopayIcon from "../../atoms/icons/AutopayIcon";
11
- import { CORNFLOWER_BLUE, ROYAL_BLUE_VIVID } from "../../../constants/colors";
11
+ import {
12
+ CORNFLOWER_BLUE,
13
+ ROYAL_BLUE_VIVID,
14
+ MANATEE_GREY,
15
+ TRANSPARENT
16
+ } from "../../../constants/colors";
17
+
12
18
  const groupId = "props";
19
+ const variant = "primary";
20
+ const variants = { primary: "primary", disabled: "disabled" };
21
+ const disabled = false;
22
+ const showLeft = true;
13
23
 
14
- export const linkCard = () => (
15
- <LinkCard
16
- title={text("title", "Link Card Title", "props")}
17
- subtitle={text("subtitle", "Link card description", groupId)}
18
- path={text("path", "/service/animal-care-and-control", "props")}
19
- showLeft={true}
20
- leftContent={
21
- <Box background="transparent" borderWidthOverride="0 0 0 0" padding="0">
22
- <Badge label="Autopay Available" Icon={AutopayIcon} />
23
- </Box>
24
- }
25
- showRight={true}
26
- rightContent={
27
- <Stack direction="row" childGap="6px">
28
- <Text
29
- variant="pS"
30
- color={ROYAL_BLUE_VIVID}
31
- extraStyles="text-align: right; color: transparent;"
32
- className="show-on-hover"
33
- >
34
- Find
35
- </Text>
36
- <PlusCircleIcon color={ROYAL_BLUE_VIVID} />
37
- </Stack>
38
- }
39
- extraHoverStyles={`
40
- .show-on-hover {color: ${ROYAL_BLUE_VIVID};}
24
+ const renderLeftContent = ({ disabled }) => {
25
+ return (
26
+ <Box background="transparent" borderWidthOverride="0 0 0 0" padding="0">
27
+ <Badge
28
+ label="Autopay Available"
29
+ Icon={AutopayIcon}
30
+ variant={disabled ? "disabled" : "success"}
31
+ />
32
+ </Box>
33
+ );
34
+ };
35
+ const renderRightContent = ({ disabled }) => {
36
+ return (
37
+ <Stack direction="row" childGap="6px">
38
+ <Text
39
+ variant="pS"
40
+ disabled={disabled || variant === "disabled"}
41
+ className="show-on-hover"
42
+ color={disabled ? MANATEE_GREY : ROYAL_BLUE_VIVID}
43
+ extraStyles={`text-align: right; color: transparent; ${
44
+ !showLeft ? "margin-left: auto;" : ""
45
+ }`}
46
+ >
47
+ Find
48
+ </Text>
49
+ <PlusCircleIcon color={disabled ? MANATEE_GREY : ROYAL_BLUE_VIVID} />
50
+ </Stack>
51
+ );
52
+ };
53
+ export const linkCard = () => {
54
+ return (
55
+ <LinkCard
56
+ disabled={boolean("disabled", false, groupId)}
57
+ variant={select("variant", variants, variant, groupId)}
58
+ title={text("title", "Link Card Title", groupId)}
59
+ subtitle={text("subtitle", "Link card description", groupId)}
60
+ path={text("path", "/service/animal-care-and-control", groupId)}
61
+ showLeft={boolean("showLeft", showLeft, groupId)}
62
+ onClick={() => window.alert("Click event!")}
63
+ leftContent={renderLeftContent({ disabled })}
64
+ showRight={boolean("showRight", true, groupId)}
65
+ rightContent={renderRightContent({ disabled })}
66
+ extraHoverStyles={`
67
+ .show-on-hover {
68
+ color: ${disabled ? MANATEE_GREY : ROYAL_BLUE_VIVID};
69
+ }
41
70
  `}
42
- extraActiveStyles={`
43
- background-color: ${CORNFLOWER_BLUE};
71
+ extraActiveStyles={`
72
+ background-color: ${disabled ? TRANSPARENT : CORNFLOWER_BLUE};
44
73
  `}
45
- />
46
- );
74
+ />
75
+ );
76
+ };
47
77
 
48
78
  const story = page({
49
79
  title: "Components|Molecules/LinkCard",
@@ -2,13 +2,28 @@ import {
2
2
  CORNFLOWER_BLUE,
3
3
  LINK_WATER,
4
4
  MOON_RAKER,
5
- ROYAL_BLUE_VIVID
5
+ ROYAL_BLUE_VIVID,
6
+ MANATEE_GREY,
7
+ ATHENS_GREY,
8
+ GHOST_GREY
6
9
  } from "../../../constants/colors";
7
10
 
8
- const activeBackgroundColor = CORNFLOWER_BLUE;
9
- const backgroundColor = LINK_WATER;
10
- const borderColor = MOON_RAKER;
11
- const color = ROYAL_BLUE_VIVID;
11
+ const activeBackgroundColor = {
12
+ primary: `${CORNFLOWER_BLUE}`,
13
+ disabled: `${ATHENS_GREY}`
14
+ };
15
+ const backgroundColor = {
16
+ primary: `${LINK_WATER}`,
17
+ disabled: `${ATHENS_GREY}`
18
+ };
19
+ const borderColor = {
20
+ primary: `${MOON_RAKER}`,
21
+ disabled: `${GHOST_GREY}`
22
+ };
23
+ const color = {
24
+ primary: `${ROYAL_BLUE_VIVID}`,
25
+ disabled: `${MANATEE_GREY}`
26
+ };
12
27
 
13
28
  export const fallbackValues = {
14
29
  activeBackgroundColor,