@thecb/components 12.0.2-beta.1 → 12.0.2-beta.2
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/dist/index.cjs.js +38 -46
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +38 -46
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/molecules/link-card/LinkCard.js +68 -92
- package/src/components/molecules/link-card/LinkCard.stories.js +13 -17
- package/src/components/molecules/link-card/LinkCard.styled.js +45 -45
- package/src/components/molecules/link-card/LinkCard.theme.js +1 -2
- package/src/components/molecules/link-card/index.d.ts +1 -4
package/package.json
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { Box, Stack } from "../../atoms/layouts";
|
|
3
|
-
import { ExternalLink, InternalLink } from "../../atoms/link";
|
|
4
3
|
import { themeComponent } from "../../../util/themeUtils";
|
|
5
4
|
import { fallbackValues } from "./LinkCard.theme";
|
|
6
5
|
import * as Styled from "./LinkCard.styled";
|
|
@@ -26,102 +25,79 @@ const LinkCard = ({
|
|
|
26
25
|
const regex = /\W/g;
|
|
27
26
|
const locatorSlug = title?.toLowerCase?.()?.replaceAll?.(regex, "-");
|
|
28
27
|
|
|
29
|
-
const baseStyles = Styled.getCardBaseStyles(
|
|
30
|
-
themeValues,
|
|
31
|
-
disabled,
|
|
32
|
-
extraStyles
|
|
33
|
-
);
|
|
34
|
-
const hoverActiveStyles = Styled.getCardHoverActiveStyles(
|
|
35
|
-
themeValues,
|
|
36
|
-
disabled,
|
|
37
|
-
extraHoverStyles,
|
|
38
|
-
extraActiveStyles
|
|
39
|
-
);
|
|
40
|
-
|
|
41
|
-
const cardContent = (
|
|
42
|
-
<Stack
|
|
43
|
-
childGap={0}
|
|
44
|
-
bottomItem={3}
|
|
45
|
-
justify="space-between"
|
|
46
|
-
style={{ width: "100%" }}
|
|
47
|
-
fullHeight
|
|
48
|
-
>
|
|
49
|
-
<Stack
|
|
50
|
-
direction="row"
|
|
51
|
-
childGap="0.5rem"
|
|
52
|
-
extraStyles={`align-items: center;`}
|
|
53
|
-
>
|
|
54
|
-
<Styled.Title
|
|
55
|
-
variant={titleVariant}
|
|
56
|
-
$theme={themeValues}
|
|
57
|
-
margin={0}
|
|
58
|
-
$disabled={disabled}
|
|
59
|
-
>
|
|
60
|
-
{title}
|
|
61
|
-
</Styled.Title>
|
|
62
|
-
{isExternalLink && (
|
|
63
|
-
<ExternalLinkIcon
|
|
64
|
-
linkColor={themeValues.color}
|
|
65
|
-
text={locatorSlug}
|
|
66
|
-
style={{ height: "1.125rem", width: "1.125rem" }}
|
|
67
|
-
/>
|
|
68
|
-
)}
|
|
69
|
-
</Stack>
|
|
70
|
-
<Box padding={subtitlePadding} width="100%">
|
|
71
|
-
<Styled.Subtitle variant="pS" $theme={themeValues} $disabled={disabled}>
|
|
72
|
-
{subtitle}
|
|
73
|
-
</Styled.Subtitle>
|
|
74
|
-
</Box>
|
|
75
|
-
<Box
|
|
76
|
-
background="transparent"
|
|
77
|
-
borderWidthOverride="0 0 0 0"
|
|
78
|
-
padding="0"
|
|
79
|
-
width="100%"
|
|
80
|
-
>
|
|
81
|
-
<Styled.Footer direction="row" childGap="6px" justify="space-between">
|
|
82
|
-
{/* To keep rightContent aligned right, use an empty Box as leftContent if none is provided */}
|
|
83
|
-
{showLeft && !!leftContent ? (
|
|
84
|
-
leftContent
|
|
85
|
-
) : (
|
|
86
|
-
<Box extraStyles="margin-right: auto;" />
|
|
87
|
-
)}
|
|
88
|
-
{showRight && !!rightContent && rightContent}
|
|
89
|
-
</Styled.Footer>
|
|
90
|
-
</Box>
|
|
91
|
-
</Stack>
|
|
92
|
-
);
|
|
93
|
-
|
|
94
|
-
if (isExternalLink) {
|
|
95
|
-
return (
|
|
96
|
-
<ExternalLink
|
|
97
|
-
key={`link-card-${locatorSlug}`}
|
|
98
|
-
href={disabled ? undefined : href}
|
|
99
|
-
newTab={true}
|
|
100
|
-
isUnderlined={false}
|
|
101
|
-
tabIndex={disabled ? "-1" : "0"}
|
|
102
|
-
ariaLabel={`${title}, ${subtitle}`}
|
|
103
|
-
dataQa={`link-card-${locatorSlug}`}
|
|
104
|
-
extraStyles={`${baseStyles} ${hoverActiveStyles}`}
|
|
105
|
-
>
|
|
106
|
-
{cardContent}
|
|
107
|
-
</ExternalLink>
|
|
108
|
-
);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
28
|
return (
|
|
112
|
-
<
|
|
29
|
+
<Styled.StyledAnchor
|
|
113
30
|
key={`link-card-${locatorSlug}`}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
tabIndex={disabled ?
|
|
118
|
-
aria-label={`${title}, ${subtitle}`}
|
|
31
|
+
href={disabled ? undefined : href}
|
|
32
|
+
rel={isExternalLink ? "noopener noreferrer" : undefined}
|
|
33
|
+
target={isExternalLink ? "_blank" : undefined}
|
|
34
|
+
tabIndex={disabled ? -1 : 0}
|
|
119
35
|
aria-disabled={disabled}
|
|
36
|
+
$disabled={disabled}
|
|
37
|
+
aria-label={`${title}, ${subtitle}`}
|
|
120
38
|
data-qa={`link-card-${locatorSlug}`}
|
|
121
|
-
|
|
39
|
+
$theme={themeValues}
|
|
40
|
+
$extraStyles={
|
|
41
|
+
disabled ? `pointer-events: none; ${extraStyles}` : extraStyles
|
|
42
|
+
}
|
|
43
|
+
$hoverStyles={extraHoverStyles}
|
|
44
|
+
$activeStyles={extraActiveStyles}
|
|
122
45
|
>
|
|
123
|
-
|
|
124
|
-
|
|
46
|
+
<Stack
|
|
47
|
+
childGap={0}
|
|
48
|
+
bottomItem={3}
|
|
49
|
+
justify="space-between"
|
|
50
|
+
style={{ width: "100%" }}
|
|
51
|
+
fullHeight
|
|
52
|
+
>
|
|
53
|
+
<Stack
|
|
54
|
+
direction="row"
|
|
55
|
+
childGap="0.5rem"
|
|
56
|
+
extraStyles={`align-items: center;`}
|
|
57
|
+
>
|
|
58
|
+
<Styled.Title
|
|
59
|
+
variant={titleVariant}
|
|
60
|
+
$theme={themeValues}
|
|
61
|
+
margin={0}
|
|
62
|
+
$disabled={disabled}
|
|
63
|
+
>
|
|
64
|
+
{title}
|
|
65
|
+
</Styled.Title>
|
|
66
|
+
{isExternalLink && (
|
|
67
|
+
<ExternalLinkIcon
|
|
68
|
+
linkColor={themeValues.color}
|
|
69
|
+
text={locatorSlug}
|
|
70
|
+
style={{ height: "1.125rem", width: "1.125rem" }}
|
|
71
|
+
/>
|
|
72
|
+
)}
|
|
73
|
+
</Stack>
|
|
74
|
+
<Box padding={subtitlePadding} width="100%">
|
|
75
|
+
<Styled.Subtitle
|
|
76
|
+
variant="pS"
|
|
77
|
+
$theme={themeValues}
|
|
78
|
+
$disabled={disabled}
|
|
79
|
+
>
|
|
80
|
+
{subtitle}
|
|
81
|
+
</Styled.Subtitle>
|
|
82
|
+
</Box>
|
|
83
|
+
<Box
|
|
84
|
+
background="transparent"
|
|
85
|
+
borderWidthOverride="0 0 0 0"
|
|
86
|
+
padding="0"
|
|
87
|
+
width="100%"
|
|
88
|
+
>
|
|
89
|
+
<Styled.Footer direction="row" childGap="6px" justify="space-between">
|
|
90
|
+
{/* To keep rightContent aligned right, use an empty Box as leftContent if none is provided */}
|
|
91
|
+
{showLeft && !!leftContent ? (
|
|
92
|
+
leftContent
|
|
93
|
+
) : (
|
|
94
|
+
<Box extraStyles="margin-right: auto;" />
|
|
95
|
+
)}
|
|
96
|
+
{showRight && !!rightContent && rightContent}
|
|
97
|
+
</Styled.Footer>
|
|
98
|
+
</Box>
|
|
99
|
+
</Stack>
|
|
100
|
+
</Styled.StyledAnchor>
|
|
125
101
|
);
|
|
126
102
|
};
|
|
127
103
|
|
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
import { Box } from "../../atoms/layouts";
|
|
9
9
|
import LinkCard from "./LinkCard";
|
|
10
10
|
import Badge from "../../atoms/badge/Badge";
|
|
11
|
+
import { fn } from "@storybook/test";
|
|
11
12
|
import AutopayIcon from "../../atoms/icons/AutopayIcon";
|
|
12
13
|
import ArrowRightIcon from "../../atoms/icons/ArrowRightIcon";
|
|
13
14
|
import PlusCircleIcon from "../../atoms/icons/PlusCircleIcon";
|
|
@@ -23,11 +24,11 @@ const meta = {
|
|
|
23
24
|
args: {
|
|
24
25
|
title: "Test Workflow",
|
|
25
26
|
subtitle: "Link your benefit plan",
|
|
26
|
-
href: "/test-workflow",
|
|
27
27
|
showLeft: undefined,
|
|
28
28
|
leftContent: undefined,
|
|
29
29
|
showRight: undefined,
|
|
30
30
|
rightContent: undefined,
|
|
31
|
+
onClick: fn(),
|
|
31
32
|
extraStyles: "",
|
|
32
33
|
extraActiveStyles: "",
|
|
33
34
|
extraHoverStyles: "",
|
|
@@ -50,14 +51,6 @@ const meta = {
|
|
|
50
51
|
defaultValue: { summary: "Link your benefit plan" }
|
|
51
52
|
}
|
|
52
53
|
},
|
|
53
|
-
href: {
|
|
54
|
-
description:
|
|
55
|
-
"URL or path for the LinkCard. Internal path for InternalLink, full URL for ExternalLink",
|
|
56
|
-
table: {
|
|
57
|
-
type: { summary: "string" },
|
|
58
|
-
defaultValue: { summary: undefined }
|
|
59
|
-
}
|
|
60
|
-
},
|
|
61
54
|
showLeft: {
|
|
62
55
|
description: "Whether to show the LinkCard's left content",
|
|
63
56
|
table: {
|
|
@@ -86,6 +79,13 @@ const meta = {
|
|
|
86
79
|
defaultValue: { summary: undefined }
|
|
87
80
|
}
|
|
88
81
|
},
|
|
82
|
+
onClick: {
|
|
83
|
+
description: "Function to execute on click of LinkCard",
|
|
84
|
+
table: {
|
|
85
|
+
type: { summary: "function" },
|
|
86
|
+
defaultValue: { summary: undefined }
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
89
|
extraStyles: {
|
|
90
90
|
description: "Extra styles to apply to the LinkCard",
|
|
91
91
|
table: {
|
|
@@ -139,8 +139,7 @@ export default meta;
|
|
|
139
139
|
export const BasicLinkCard = {
|
|
140
140
|
args: {
|
|
141
141
|
title: "Construction Permits",
|
|
142
|
-
subtitle: "Cityville Department of Building Inspection"
|
|
143
|
-
href: "/permits/construction"
|
|
142
|
+
subtitle: "Cityville Department of Building Inspection"
|
|
144
143
|
},
|
|
145
144
|
render: args => {
|
|
146
145
|
return (
|
|
@@ -197,8 +196,7 @@ export const BasicLinkCard = {
|
|
|
197
196
|
export const ExternalLinkCard = {
|
|
198
197
|
args: {
|
|
199
198
|
title: "Construction Permits",
|
|
200
|
-
subtitle: "Cityville Department of Building Inspection"
|
|
201
|
-
href: "https://example.com/permits/construction"
|
|
199
|
+
subtitle: "Cityville Department of Building Inspection"
|
|
202
200
|
},
|
|
203
201
|
render: args => {
|
|
204
202
|
return (
|
|
@@ -256,8 +254,7 @@ export const ExternalLinkCard = {
|
|
|
256
254
|
export const CompleteLinkCard = {
|
|
257
255
|
args: {
|
|
258
256
|
title: "Water Bills - Autopay",
|
|
259
|
-
subittle: "Cityville Water Management"
|
|
260
|
-
href: "/water-bills/autopay"
|
|
257
|
+
subittle: "Cityville Water Management"
|
|
261
258
|
},
|
|
262
259
|
render: args => {
|
|
263
260
|
return (
|
|
@@ -315,8 +312,7 @@ export const CompleteLinkCard = {
|
|
|
315
312
|
export const DisabledLinkCard = {
|
|
316
313
|
args: {
|
|
317
314
|
title: "Property Tax - Autopay",
|
|
318
|
-
subtitle: ""
|
|
319
|
-
href: "/property-tax/autopay"
|
|
315
|
+
subtitle: ""
|
|
320
316
|
},
|
|
321
317
|
render: args => {
|
|
322
318
|
return (
|
|
@@ -7,7 +7,16 @@ import {
|
|
|
7
7
|
FONT_WEIGHT_REGULAR
|
|
8
8
|
} from "../../../constants/style_constants";
|
|
9
9
|
|
|
10
|
-
export const
|
|
10
|
+
export const StyledAnchor = styled("a")`
|
|
11
|
+
${({
|
|
12
|
+
$disabled: disabled,
|
|
13
|
+
$theme: theme,
|
|
14
|
+
$extraStyles: extraStyles,
|
|
15
|
+
$disabledStyles: disabledStyles,
|
|
16
|
+
$hoverStyles: hoverStyles,
|
|
17
|
+
$activeStyles: activeStyles
|
|
18
|
+
}) => `
|
|
19
|
+
display: flex;
|
|
11
20
|
flex-direction: column;
|
|
12
21
|
align-items: flex-start;
|
|
13
22
|
gap: 40px;
|
|
@@ -16,60 +25,51 @@ export const getCardBaseStyles = (theme, disabled, extraStyles) => `
|
|
|
16
25
|
align-self: stretch;
|
|
17
26
|
border-radius: 8px;
|
|
18
27
|
text-decoration: none;
|
|
19
|
-
font-size: inherit;
|
|
20
|
-
color: inherit;
|
|
21
|
-
font-weight: inherit;
|
|
22
|
-
line-height: inherit;
|
|
23
28
|
background-color: ${
|
|
24
29
|
disabled ? theme.disabledBackgroundColor : theme.backgroundColor
|
|
25
30
|
};
|
|
26
31
|
border: 1px solid
|
|
27
32
|
${disabled ? theme.disabledBorderColor : theme.borderColor};
|
|
28
33
|
transition: all 0.2s ease-in-out;
|
|
29
|
-
${disabled ? `pointer-events: none;` : ""}
|
|
30
34
|
${extraStyles || ""}
|
|
31
|
-
`;
|
|
32
35
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
0px 27px 26px 0px rgba(41, 42, 51, 0.05),
|
|
57
|
-
0px 56px 31px 0px rgba(41, 42, 51, 0.01),
|
|
58
|
-
0px 80px 33px 0px rgba(41, 42, 51, 0);
|
|
59
|
-
}
|
|
60
|
-
${hoverStyles || ""}
|
|
36
|
+
${
|
|
37
|
+
disabled
|
|
38
|
+
? `
|
|
39
|
+
&:hover,
|
|
40
|
+
&:active {
|
|
41
|
+
cursor: default;
|
|
42
|
+
box-shadow: none;
|
|
43
|
+
border: 1px solid ${theme.disabledBorderColor};
|
|
44
|
+
${disabledStyles || ""}
|
|
45
|
+
}
|
|
46
|
+
`
|
|
47
|
+
: `
|
|
48
|
+
&:hover,
|
|
49
|
+
&:active {
|
|
50
|
+
cursor: pointer;
|
|
51
|
+
box-shadow: 0px 0px 0px 0px rgba(41, 42, 51, 0.1),
|
|
52
|
+
0px 5px 11px 0px rgba(41, 42, 51, 0.1),
|
|
53
|
+
0px 4px 19px 0px rgba(41, 42, 51, 0.09),
|
|
54
|
+
0px 27px 26px 0px rgba(41, 42, 51, 0.05),
|
|
55
|
+
0px 56px 31px 0px rgba(41, 42, 51, 0.01),
|
|
56
|
+
0px 80px 33px 0px rgba(41, 42, 51, 0);
|
|
57
|
+
}
|
|
58
|
+
${hoverStyles || ""}
|
|
61
59
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
60
|
+
&:hover:not(:active) {
|
|
61
|
+
border: 1px solid ${theme.borderColor};
|
|
62
|
+
}
|
|
65
63
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}
|
|
64
|
+
&:active {
|
|
65
|
+
background-color: ${theme.activeBackgroundColor};
|
|
66
|
+
border: 1px solid ${theme.borderColor};
|
|
67
|
+
${activeStyles || ""}
|
|
68
|
+
}
|
|
69
|
+
`
|
|
70
|
+
}
|
|
71
|
+
`}
|
|
72
|
+
`;
|
|
73
73
|
|
|
74
74
|
export const Title = styled(Heading)`
|
|
75
75
|
display: -webkit-box;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
CORNFLOWER_BLUE,
|
|
3
3
|
LINK_WATER,
|
|
4
|
-
MOON_RAKER,
|
|
5
4
|
ROYAL_BLUE_VIVID,
|
|
6
5
|
MANATEE_GREY,
|
|
7
6
|
GHOST_GREY,
|
|
@@ -14,7 +13,7 @@ const disabledBorderColor = GHOST_GREY;
|
|
|
14
13
|
const disabledColor = MANATEE_GREY;
|
|
15
14
|
const activeBackgroundColor = CORNFLOWER_BLUE;
|
|
16
15
|
const backgroundColor = LINK_WATER;
|
|
17
|
-
const borderColor =
|
|
16
|
+
const borderColor = MANATEE_GREY;
|
|
18
17
|
const color = ROYAL_BLUE_VIVID;
|
|
19
18
|
const textColor = BRIGHT_GREY;
|
|
20
19
|
|
|
@@ -5,19 +5,16 @@ export interface LinkCardProps {
|
|
|
5
5
|
variant?: string; // "default" is only one
|
|
6
6
|
title?: string; // title
|
|
7
7
|
subtitle?: string; // beneath title
|
|
8
|
-
subtitlePadding?: string;
|
|
9
8
|
themeValues?: any;
|
|
10
9
|
showLeft?: boolean;
|
|
11
10
|
leftContent?: JSX.Element;
|
|
12
11
|
showRight?: boolean;
|
|
13
12
|
rightContent?: JSX.Element;
|
|
14
|
-
|
|
13
|
+
onClick: () => void;
|
|
15
14
|
extraHoverStyles?: string;
|
|
16
15
|
extraStyles?: string;
|
|
17
16
|
extraActiveStyles?: string;
|
|
18
17
|
titleVariant?: string;
|
|
19
|
-
disabled?: boolean;
|
|
20
|
-
isExternalLink?: boolean;
|
|
21
18
|
}
|
|
22
19
|
|
|
23
20
|
export const LinkCard: React.FC<Expand<LinkCardProps> &
|