@thecb/components 10.2.4-beta.2 → 10.2.4-beta.4

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.2",
3
+ "version": "10.2.4-beta.4",
4
4
  "description": "Common lib for CityBase react components",
5
5
  "main": "dist/index.cjs.js",
6
6
  "typings": "dist/index.d.ts",
@@ -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
  },
@@ -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,6 +4,8 @@ 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";
8
+ import { ATHENS_GREY } from "../../../constants/colors";
7
9
 
8
10
  const LinkCard = ({
9
11
  title = "Test Workflow",
@@ -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;
@@ -33,10 +36,16 @@ const LinkCard = ({
33
36
  minHeight="141px"
34
37
  padding="24px"
35
38
  theme={themeValues}
36
- extraStyles={extraStyles}
37
- hoverStyles={extraHoverStyles}
38
- activeStyles={extraActiveStyles}
39
- onClick={onClick}
39
+ extraStyles={
40
+ disabled
41
+ ? extraStyles +
42
+ `background-color: ${ATHENS_GREY} !important; cursor: default;`
43
+ : extraStyles
44
+ }
45
+ hoverStyles={disabled ? "" : extraHoverStyles}
46
+ activeStyles={disabled ? "" : extraActiveStyles}
47
+ onClick={disabled ? noop : onClick}
48
+ aria-disabled={disabled}
40
49
  >
41
50
  <Stack
42
51
  childGap={0}
@@ -45,12 +54,20 @@ const LinkCard = ({
45
54
  style={{ width: "100%" }}
46
55
  fullHeight
47
56
  >
48
- <Box padding={0} width="100%">
57
+ <Box
58
+ padding={0}
59
+ width="100%"
60
+ extraStyles={disabled ? "opacity: 0.5;" : ""}
61
+ >
49
62
  <Styled.Title variant={titleVariant} theme={themeValues} margin={0}>
50
63
  {title}
51
64
  </Styled.Title>
52
65
  </Box>
53
- <Box padding={"0 0 40px"} width="100%">
66
+ <Box
67
+ padding={"0 0 40px"}
68
+ width="100%"
69
+ extraStyles={disabled ? "opacity: 0.5;" : ""}
70
+ >
54
71
  <Styled.Subtitle variant="pS" theme={themeValues}>
55
72
  {subtitle}
56
73
  </Styled.Subtitle>
@@ -60,6 +77,7 @@ const LinkCard = ({
60
77
  borderWidthOverride="0 0 0 0"
61
78
  padding="0"
62
79
  width="100%"
80
+ extraStyles={disabled ? "opacity: 0.5;" : ""}
63
81
  >
64
82
  <Styled.Footer direction="row" childGap="6px" justify="space-between">
65
83
  {/* To keep rightContent aligned right, use an empty Box as leftContent if none is provided */}
@@ -4,7 +4,7 @@ import Box from "../../atoms/layouts/Box";
4
4
  import Stack from "../../atoms/layouts/Stack";
5
5
  import Text from "../../atoms/text/Text";
6
6
  import page from "../../../../.storybook/page";
7
- import { text } from "@storybook/addon-knobs";
7
+ import { boolean, 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";
@@ -13,16 +13,18 @@ const groupId = "props";
13
13
 
14
14
  export const linkCard = () => (
15
15
  <LinkCard
16
- title={text("title", "Link Card Title", "props")}
16
+ disabled={boolean("disabled", false, groupId)}
17
+ title={text("title", "Link Card Title", groupId)}
17
18
  subtitle={text("subtitle", "Link card description", groupId)}
18
- path={text("path", "/service/animal-care-and-control", "props")}
19
- showLeft={true}
19
+ path={text("path", "/service/animal-care-and-control", groupId)}
20
+ showLeft={boolean("showLeft", true, groupId)}
21
+ onClick={() => window.alert("Click event!")}
20
22
  leftContent={
21
23
  <Box background="transparent" borderWidthOverride="0 0 0 0" padding="0">
22
24
  <Badge label="Autopay Available" Icon={AutopayIcon} />
23
25
  </Box>
24
26
  }
25
- showRight={true}
27
+ showRight={boolean("showRight", true, groupId)}
26
28
  rightContent={
27
29
  <Stack direction="row" childGap="6px">
28
30
  <Text