@thecb/components 11.8.0-beta.3 → 11.8.0-beta.5
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 +68 -69
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +68 -69
- package/dist/index.esm.js.map +1 -1
- package/package.json +3 -3
- package/src/components/atoms/alert/Alert.theme.js +5 -5
- package/src/components/molecules/payment-button-bar/PaymentButtonBar.js +9 -4
- package/src/components/molecules/popover/Popover.js +1 -15
- package/src/components/molecules/tooltip/Tooltip.js +34 -37
- package/src/components/molecules/tooltip/Tooltip.mdx +1 -1
- package/src/components/molecules/tooltip/Tooltip.stories.js +19 -20
- package/src/components/molecules/tooltip/index.d.ts +6 -5
- package/src/components/templates/sidebar-stack-content/SidebarStackContent.js +1 -1
- package/src/deprecated/icons/AlertInfoIcon.js +1 -1
- package/src/util/general.js +14 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thecb/components",
|
|
3
|
-
"version": "11.8.0-beta.
|
|
3
|
+
"version": "11.8.0-beta.5",
|
|
4
4
|
"description": "Common lib for CityBase react components",
|
|
5
5
|
"main": "dist/index.cjs.js",
|
|
6
6
|
"typings": "dist/index.d.ts",
|
|
@@ -81,8 +81,8 @@
|
|
|
81
81
|
"vite": "^5.2.11"
|
|
82
82
|
},
|
|
83
83
|
"peerDependencies": {
|
|
84
|
-
"react": "^16.13.1",
|
|
85
|
-
"react-dom": "^16.13.1",
|
|
84
|
+
"react": "^16.13.1 || ^17.0.0",
|
|
85
|
+
"react-dom": "^16.13.1 || ^17.0.0",
|
|
86
86
|
"react-router-dom": "^6.3.0",
|
|
87
87
|
"styled-components": "^5.1.1",
|
|
88
88
|
"styled-theming": "^2.2.0"
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
APRICOT_ORANGE,
|
|
3
|
+
INFO_BLUE,
|
|
3
4
|
BLUSH_RED,
|
|
4
5
|
HINT_GREEN,
|
|
5
6
|
ZEST_ORANGE,
|
|
7
|
+
MATISSE_BLUE,
|
|
6
8
|
RAZZMATAZZ_RED,
|
|
7
9
|
EMERALD_GREEN,
|
|
8
10
|
MUSTARD_YELLOW,
|
|
@@ -14,20 +16,18 @@ import {
|
|
|
14
16
|
THUNDERBIRD_RED,
|
|
15
17
|
HAZE_GREEN,
|
|
16
18
|
ZODIAC_BLUE,
|
|
17
|
-
SCIENCE_BLUE
|
|
18
|
-
LUCKY_POINT,
|
|
19
|
-
HAWKES_BLUE
|
|
19
|
+
SCIENCE_BLUE
|
|
20
20
|
} from "../../../constants/colors";
|
|
21
21
|
|
|
22
22
|
const background = {
|
|
23
|
-
info: `${
|
|
23
|
+
info: `${INFO_BLUE}`,
|
|
24
24
|
warn: `${APRICOT_ORANGE}`,
|
|
25
25
|
error: `${BLUSH_RED}`,
|
|
26
26
|
success: `${HINT_GREEN}`
|
|
27
27
|
};
|
|
28
28
|
|
|
29
29
|
const border = {
|
|
30
|
-
info: `${
|
|
30
|
+
info: `${MATISSE_BLUE}`,
|
|
31
31
|
warn: `${ZEST_ORANGE}`,
|
|
32
32
|
error: `${RAZZMATAZZ_RED}`,
|
|
33
33
|
success: `${EMERALD_GREEN}`
|
|
@@ -31,15 +31,20 @@ const PaymentButtonBar = ({
|
|
|
31
31
|
}) => {
|
|
32
32
|
const { isMobile } = useContext(ThemeContext);
|
|
33
33
|
|
|
34
|
+
// cancel URLs are external (back to client system)
|
|
35
|
+
const handleCancel = () => {
|
|
36
|
+
window.location.href = cancelURL;
|
|
37
|
+
};
|
|
38
|
+
|
|
34
39
|
const backButton =
|
|
35
40
|
!!cancelURL && !!cancelText ? (
|
|
36
|
-
<
|
|
41
|
+
<ButtonWithAction
|
|
37
42
|
text={cancelText}
|
|
38
|
-
|
|
43
|
+
action={handleCancel}
|
|
39
44
|
variant={backButtonVariant}
|
|
40
45
|
extraStyles={isMobile && "flex-grow: 1"}
|
|
41
46
|
dataQa={backButtonTestId || cancelText}
|
|
42
|
-
aria-
|
|
47
|
+
aria-label={`${cancelText}, navigate back to previous site`}
|
|
43
48
|
role="link"
|
|
44
49
|
/>
|
|
45
50
|
) : (
|
|
@@ -50,7 +55,7 @@ const PaymentButtonBar = ({
|
|
|
50
55
|
action={backButtonAction}
|
|
51
56
|
extraStyles={isMobile && "flex-grow: 1"}
|
|
52
57
|
dataQa="Back"
|
|
53
|
-
aria-
|
|
58
|
+
aria-label={"Back, navigate to previous page"}
|
|
54
59
|
role="link"
|
|
55
60
|
/>
|
|
56
61
|
)
|
|
@@ -5,24 +5,10 @@ import Paragraph from "../../atoms/paragraph";
|
|
|
5
5
|
import { Box } from "../../atoms/layouts";
|
|
6
6
|
import ButtonWithAction from "../../atoms/button-with-action";
|
|
7
7
|
import { useOutsideClick } from "../../../hooks";
|
|
8
|
-
import { noop } from "../../../util/general";
|
|
8
|
+
import { noop, arrowBorder } from "../../../util/general";
|
|
9
9
|
import { ESCAPE } from "../../../constants/keyboard";
|
|
10
10
|
import { fallbackValues } from "./Popover.theme";
|
|
11
11
|
|
|
12
|
-
const arrowBorder = (borderColor, direction, width = "8px") => {
|
|
13
|
-
const angle = `${width} solid transparent`;
|
|
14
|
-
const straight = `${width} solid ${borderColor}`;
|
|
15
|
-
if (direction == "down") {
|
|
16
|
-
return `border-left: ${angle}; border-right: ${angle}; border-top: ${straight}`;
|
|
17
|
-
} else if (direction == "up") {
|
|
18
|
-
return `border-left: ${angle}; border-right: ${angle}; border-bottom: ${straight}`;
|
|
19
|
-
} else if (direction == "left") {
|
|
20
|
-
return `border-top: ${angle}; border-bottom: ${angle}; border-right: ${straight}`;
|
|
21
|
-
} else if (direction == "right") {
|
|
22
|
-
return `border-top: ${angle}; border-bottom: ${angle}; border-left: ${straight}`;
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
|
|
26
12
|
const Popover = ({
|
|
27
13
|
themeValues,
|
|
28
14
|
triggerText = "",
|
|
@@ -4,57 +4,47 @@ import Text from "../../atoms/text";
|
|
|
4
4
|
import Paragraph from "../../atoms/paragraph";
|
|
5
5
|
import { Box } from "../../atoms/layouts";
|
|
6
6
|
import ButtonWithAction from "../../atoms/button-with-action";
|
|
7
|
-
import { noop } from "../../../util/general";
|
|
7
|
+
import { noop, arrowBorder } from "../../../util/general";
|
|
8
8
|
import { ESCAPE } from "../../../constants/keyboard";
|
|
9
9
|
import { fallbackValues } from "./Tooltip.theme";
|
|
10
|
-
import
|
|
11
|
-
import {
|
|
12
|
-
|
|
13
|
-
const arrowBorder = (borderColor, direction, width = "8px") => {
|
|
14
|
-
const angle = `${width} solid transparent`;
|
|
15
|
-
const straight = `${width} solid ${borderColor}`;
|
|
16
|
-
if (direction == "down") {
|
|
17
|
-
return `border-left: ${angle}; border-right: ${angle}; border-top: ${straight}`;
|
|
18
|
-
} else if (direction == "up") {
|
|
19
|
-
return `border-left: ${angle}; border-right: ${angle}; border-bottom: ${straight}`;
|
|
20
|
-
} else if (direction == "left") {
|
|
21
|
-
return `border-top: ${angle}; border-bottom: ${angle}; border-right: ${straight}`;
|
|
22
|
-
} else if (direction == "right") {
|
|
23
|
-
return `border-top: ${angle}; border-bottom: ${angle}; border-left: ${straight}`;
|
|
24
|
-
}
|
|
25
|
-
};
|
|
10
|
+
import WarningIconXS from "../../atoms/icons/WarningIconXS";
|
|
11
|
+
import { SELECTIVE_YELLOW } from "../../../constants/colors";
|
|
26
12
|
|
|
27
13
|
const Tooltip = ({
|
|
28
14
|
themeValues,
|
|
29
15
|
triggerText = "",
|
|
30
16
|
content = "",
|
|
31
17
|
hasIconTrigger = false,
|
|
32
|
-
IconTrigger =
|
|
18
|
+
IconTrigger = WarningIconXS,
|
|
33
19
|
iconHelpText = "",
|
|
34
|
-
tooltipID =
|
|
35
|
-
extraStyles,
|
|
20
|
+
tooltipID = "tooltip-content",
|
|
21
|
+
extraStyles = "",
|
|
36
22
|
textExtraStyles = "",
|
|
37
23
|
minWidth = "250px",
|
|
38
24
|
maxWidth = "300px",
|
|
39
25
|
height = "auto",
|
|
40
|
-
position,
|
|
41
|
-
arrowPosition,
|
|
42
26
|
arrowDirection = "down",
|
|
43
|
-
|
|
27
|
+
arrowPosition = {
|
|
28
|
+
arrowTop: "auto",
|
|
29
|
+
arrowRight: "10px",
|
|
30
|
+
arrowBottom: "-8px",
|
|
31
|
+
arrowLeft: "auto"
|
|
32
|
+
},
|
|
33
|
+
position = {
|
|
34
|
+
top: "-110px",
|
|
35
|
+
right: "auto",
|
|
36
|
+
bottom: "auto",
|
|
37
|
+
left: "-225px"
|
|
38
|
+
},
|
|
39
|
+
iconColor = SELECTIVE_YELLOW,
|
|
44
40
|
buttonExtraStyles,
|
|
45
41
|
backgroundColor = "white",
|
|
46
42
|
borderColor = "rgba(255, 255, 255, 0.85)",
|
|
47
|
-
|
|
43
|
+
tooltipContentExtraStyles
|
|
48
44
|
}) => {
|
|
49
45
|
const { hoverColor, activeColor, tooltipTriggerColor } = themeValues;
|
|
50
|
-
const { top
|
|
51
|
-
|
|
52
|
-
const {
|
|
53
|
-
arrowTop = "auto",
|
|
54
|
-
arrowRight = "10px",
|
|
55
|
-
arrowBottom = "-8px",
|
|
56
|
-
arrowLeft = "auto"
|
|
57
|
-
} = arrowPosition ?? {};
|
|
46
|
+
const { top, right, bottom, left } = position ?? {};
|
|
47
|
+
const { arrowTop, arrowRight, arrowBottom, arrowLeft } = arrowPosition ?? {};
|
|
58
48
|
|
|
59
49
|
const [tooltipOpen, setTooltipOpen] = useState(false);
|
|
60
50
|
|
|
@@ -65,7 +55,7 @@ const Tooltip = ({
|
|
|
65
55
|
};
|
|
66
56
|
|
|
67
57
|
const handleKeyboardEvent = e => {
|
|
68
|
-
if (e.
|
|
58
|
+
if (e.key === ESCAPE) {
|
|
69
59
|
handleToggleTooltip(false);
|
|
70
60
|
}
|
|
71
61
|
};
|
|
@@ -89,14 +79,21 @@ const Tooltip = ({
|
|
|
89
79
|
>
|
|
90
80
|
{hasIconTrigger && (
|
|
91
81
|
<>
|
|
92
|
-
<
|
|
82
|
+
<Box aria-label="Open tooltip">
|
|
83
|
+
<IconTrigger color={iconColor} />
|
|
84
|
+
</Box>
|
|
93
85
|
<Box padding="0" srOnly>
|
|
94
86
|
<Text>{iconHelpText}</Text>
|
|
95
87
|
</Box>
|
|
96
88
|
</>
|
|
97
89
|
)}
|
|
98
90
|
{!hasIconTrigger && (
|
|
99
|
-
<Text
|
|
91
|
+
<Text
|
|
92
|
+
extraStyles={`color: ${tooltipTriggerColor}; &:hover {
|
|
93
|
+
${hoverColor}; &:active ${activeColor}; ${textExtraStyles}`}
|
|
94
|
+
>
|
|
95
|
+
{triggerText}
|
|
96
|
+
</Text>
|
|
100
97
|
)}
|
|
101
98
|
</ButtonWithAction>
|
|
102
99
|
<Box
|
|
@@ -107,6 +104,7 @@ const Tooltip = ({
|
|
|
107
104
|
role="tooltip"
|
|
108
105
|
minWidth={minWidth}
|
|
109
106
|
maxWidth={maxWidth}
|
|
107
|
+
aria-hidden={!tooltipOpen}
|
|
110
108
|
extraStyles={`
|
|
111
109
|
display: ${tooltipOpen ? "block" : "none"};
|
|
112
110
|
position: absolute;
|
|
@@ -115,8 +113,7 @@ const Tooltip = ({
|
|
|
115
113
|
bottom: ${bottom};
|
|
116
114
|
left: ${left};
|
|
117
115
|
height: ${height};
|
|
118
|
-
|
|
119
|
-
${tooltipExtraStyles};
|
|
116
|
+
${tooltipContentExtraStyles};
|
|
120
117
|
`}
|
|
121
118
|
>
|
|
122
119
|
<Paragraph>{content}</Paragraph>
|
|
@@ -6,7 +6,7 @@ import * as TooltipStories from './Tooltip.stories.js';
|
|
|
6
6
|
|
|
7
7
|
<Title />
|
|
8
8
|
|
|
9
|
-
The Tooltip is a fully accessible tooltip widget that displays additional information when a user hovers over or focuses on a specified trigger element. The trigger can either be text supplied using the `triggerText` prop, or a custom Icon component supplied using the `
|
|
9
|
+
The Tooltip is a fully accessible tooltip widget that displays additional information when a user hovers over or focuses on a specified trigger element. The trigger can either be text supplied using the `triggerText` prop, or a custom Icon component supplied using the `IconTrigger` prop. The trigger is rendered as a `ButtonWithAction` with the `smallGhost` variant.
|
|
10
10
|
|
|
11
11
|
The Tooltip uses the WAI-ARIA tooltip pattern (`role="tooltip"` and `aria-describedby`) for accessibility. It can be positioned anywhere around the trigger element using the position props. Content and style of the tooltip are customizable.
|
|
12
12
|
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import Tooltip from "./Tooltip";
|
|
2
|
-
import
|
|
3
|
-
|
|
2
|
+
import WarningIconXS from "../../atoms/icons/WarningIconXS";
|
|
4
3
|
export default {
|
|
5
4
|
title: "Molecules/Tooltip",
|
|
6
5
|
component: Tooltip,
|
|
@@ -13,9 +12,10 @@ export default {
|
|
|
13
12
|
triggerText: "",
|
|
14
13
|
content: "",
|
|
15
14
|
hasIconTrigger: false,
|
|
16
|
-
IconTrigger:
|
|
15
|
+
IconTrigger: WarningIconXS,
|
|
17
16
|
iconHelpText: "",
|
|
18
|
-
|
|
17
|
+
iconColor: undefined,
|
|
18
|
+
tooltipID: "tooltip-content",
|
|
19
19
|
extraStyles: undefined,
|
|
20
20
|
textExtraStyles: undefined,
|
|
21
21
|
minWidth: "250px",
|
|
@@ -24,16 +24,15 @@ export default {
|
|
|
24
24
|
position: undefined,
|
|
25
25
|
arrowPosition: undefined,
|
|
26
26
|
arrowDirection: "down",
|
|
27
|
-
transform: "none",
|
|
28
27
|
buttonExtraStyles: undefined,
|
|
29
28
|
backgroundColor: "white",
|
|
30
29
|
borderColor: "rgba(255, 255, 255, 0.85)",
|
|
31
|
-
|
|
30
|
+
tooltipContentExtraStyles: undefined
|
|
32
31
|
},
|
|
33
32
|
argTypes: {
|
|
34
33
|
triggerText: {
|
|
35
34
|
description:
|
|
36
|
-
"Text element that tooltip is anchored to. Only used if
|
|
35
|
+
"Text element that tooltip is anchored to. Only used if hasIconTrigger is false.",
|
|
37
36
|
table: {
|
|
38
37
|
type: { summary: "string" },
|
|
39
38
|
defaultValue: { summary: "" }
|
|
@@ -59,7 +58,7 @@ export default {
|
|
|
59
58
|
"The icon component to display. Requires hasIcon to be true.",
|
|
60
59
|
table: {
|
|
61
60
|
type: { summary: "React Component" },
|
|
62
|
-
defaultValue: { summary: "
|
|
61
|
+
defaultValue: { summary: "WarningIconXS" }
|
|
63
62
|
}
|
|
64
63
|
},
|
|
65
64
|
iconHelpText: {
|
|
@@ -69,12 +68,19 @@ export default {
|
|
|
69
68
|
defaultValue: { summary: undefined }
|
|
70
69
|
}
|
|
71
70
|
},
|
|
71
|
+
iconColor: {
|
|
72
|
+
description: "Color of the icon trigger",
|
|
73
|
+
table: {
|
|
74
|
+
type: { summary: "string" },
|
|
75
|
+
defaultValue: { summary: undefined }
|
|
76
|
+
}
|
|
77
|
+
},
|
|
72
78
|
tooltipID: {
|
|
73
79
|
description:
|
|
74
80
|
"ID value for tooltip. Use if displaying multiple tooltips on the same page.",
|
|
75
81
|
table: {
|
|
76
|
-
type: { summary: "
|
|
77
|
-
defaultValue: { summary:
|
|
82
|
+
type: { summary: "string" },
|
|
83
|
+
defaultValue: { summary: "tooltip-content" }
|
|
78
84
|
}
|
|
79
85
|
},
|
|
80
86
|
extraStyles: {
|
|
@@ -136,13 +142,6 @@ export default {
|
|
|
136
142
|
defaultValue: { summary: "down" }
|
|
137
143
|
}
|
|
138
144
|
},
|
|
139
|
-
transform: {
|
|
140
|
-
description: "CSS transform to apply to tooltip",
|
|
141
|
-
table: {
|
|
142
|
-
type: { summary: "string" },
|
|
143
|
-
defaultValue: { summary: undefined }
|
|
144
|
-
}
|
|
145
|
-
},
|
|
146
145
|
buttonExtraStyles: {
|
|
147
146
|
description:
|
|
148
147
|
"Extra styles to apply to the button that wraps tooltip trigger",
|
|
@@ -165,8 +164,8 @@ export default {
|
|
|
165
164
|
defaultValue: { summary: "rgba(255, 255, 255, 0.85)" }
|
|
166
165
|
}
|
|
167
166
|
},
|
|
168
|
-
|
|
169
|
-
description: "Extra styles to apply to the tooltip",
|
|
167
|
+
tooltipContentExtraStyles: {
|
|
168
|
+
description: "Extra styles to apply to the tooltip content box",
|
|
170
169
|
table: {
|
|
171
170
|
type: { summary: "string" },
|
|
172
171
|
defaultValue: { summary: undefined }
|
|
@@ -186,7 +185,7 @@ export const BasicTooltip = {
|
|
|
186
185
|
export const IconTooltip = {
|
|
187
186
|
args: {
|
|
188
187
|
hasIconTrigger: true,
|
|
189
|
-
IconTrigger:
|
|
188
|
+
IconTrigger: WarningIconXS,
|
|
190
189
|
content:
|
|
191
190
|
"Contact support at 1-800-CTY-VILL for help with your account balance."
|
|
192
191
|
}
|
|
@@ -4,9 +4,6 @@ import Expand from "../../../util/expand";
|
|
|
4
4
|
export interface TooltipProps {
|
|
5
5
|
triggerText?: string | JSX.Element;
|
|
6
6
|
content?: string | JSX.Element;
|
|
7
|
-
hasIcon?: boolean;
|
|
8
|
-
iconHelpText?: string;
|
|
9
|
-
tooltipID?: number;
|
|
10
7
|
extraStyles?: string;
|
|
11
8
|
textExtraStyles?: string;
|
|
12
9
|
minWidth?: string;
|
|
@@ -20,11 +17,15 @@ export interface TooltipProps {
|
|
|
20
17
|
arrowLeft: string;
|
|
21
18
|
};
|
|
22
19
|
arrowDirection?: "left" | "right" | "top" | "bottom";
|
|
23
|
-
transform?: string;
|
|
24
20
|
buttonExtraStyles?: string;
|
|
25
21
|
borderColor?: string;
|
|
26
22
|
backgroundColor?: string;
|
|
27
|
-
|
|
23
|
+
hasIconTrigger?: boolean;
|
|
24
|
+
IconTrigger?: React.FC<React.SVGProps<SVGSVGElement>>;
|
|
25
|
+
iconHelpText?: string;
|
|
26
|
+
iconColor?: string;
|
|
27
|
+
tooltipID: string;
|
|
28
|
+
tooltipContentExtraStyles?: string;
|
|
28
29
|
}
|
|
29
30
|
|
|
30
31
|
export const Tooltip: React.FC<Expand<TooltipProps> &
|
|
@@ -36,7 +36,7 @@ const SidebarStackContent = ({
|
|
|
36
36
|
>
|
|
37
37
|
<Cover centerOverride={!sidebarVerticalCenter} key="page-cover">
|
|
38
38
|
{header ? header : <Box padding="0" key="header-box" />}
|
|
39
|
-
<Box padding="0" minWidth="100%" key="content-box"
|
|
39
|
+
<Box padding="0" minWidth="100%" key="content-box">
|
|
40
40
|
{subHeader && !(isMobile && hideMobileSubHeader) ? (
|
|
41
41
|
subHeader
|
|
42
42
|
) : (
|
package/src/util/general.js
CHANGED
|
@@ -222,3 +222,17 @@ export const adjustHexColor = (hex, percent, action) => {
|
|
|
222
222
|
.slice(1)
|
|
223
223
|
.padStart(6, "0")}`;
|
|
224
224
|
};
|
|
225
|
+
|
|
226
|
+
export const arrowBorder = (borderColor, direction, width = "8px") => {
|
|
227
|
+
const angle = `${width} solid transparent`;
|
|
228
|
+
const straight = `${width} solid ${borderColor}`;
|
|
229
|
+
if (direction == "down") {
|
|
230
|
+
return `border-left: ${angle}; border-right: ${angle}; border-top: ${straight}`;
|
|
231
|
+
} else if (direction == "up") {
|
|
232
|
+
return `border-left: ${angle}; border-right: ${angle}; border-bottom: ${straight}`;
|
|
233
|
+
} else if (direction == "left") {
|
|
234
|
+
return `border-top: ${angle}; border-bottom: ${angle}; border-right: ${straight}`;
|
|
235
|
+
} else if (direction == "right") {
|
|
236
|
+
return `border-top: ${angle}; border-bottom: ${angle}; border-left: ${straight}`;
|
|
237
|
+
}
|
|
238
|
+
};
|