@thecb/components 11.7.0-beta.0 → 11.8.0-beta.1
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 +299 -122
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +299 -123
- 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/atoms/display-card/DisplayCard.js +30 -0
- package/src/components/atoms/display-card/DisplayCard.stories.js +75 -0
- package/src/components/atoms/icons/IconAdd.js +2 -2
- package/src/components/molecules/index.js +1 -0
- package/src/components/molecules/payment-button-bar/PaymentButtonBar.js +4 -9
- package/src/components/molecules/tooltip/Tooltip.js +143 -0
- package/src/components/molecules/tooltip/Tooltip.mdx +15 -0
- package/src/components/molecules/tooltip/Tooltip.stories.js +204 -0
- package/src/components/molecules/tooltip/Tooltip.theme.js +9 -0
- package/src/components/molecules/tooltip/index.d.ts +31 -0
- package/src/components/molecules/tooltip/index.js +3 -0
- package/src/deprecated/icons/AlertInfoIcon.js +1 -1
- package/src/components/.DS_Store +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thecb/components",
|
|
3
|
-
"version": "11.
|
|
3
|
+
"version": "11.8.0-beta.1",
|
|
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",
|
|
85
|
+
"react-dom": "^16.13.1",
|
|
86
86
|
"react-router-dom": "^6.3.0",
|
|
87
87
|
"styled-components": "^5.1.1",
|
|
88
88
|
"styled-theming": "^2.2.0"
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
APRICOT_ORANGE,
|
|
3
|
-
INFO_BLUE,
|
|
4
3
|
BLUSH_RED,
|
|
5
4
|
HINT_GREEN,
|
|
6
5
|
ZEST_ORANGE,
|
|
7
|
-
MATISSE_BLUE,
|
|
8
6
|
RAZZMATAZZ_RED,
|
|
9
7
|
EMERALD_GREEN,
|
|
10
8
|
MUSTARD_YELLOW,
|
|
@@ -16,18 +14,20 @@ import {
|
|
|
16
14
|
THUNDERBIRD_RED,
|
|
17
15
|
HAZE_GREEN,
|
|
18
16
|
ZODIAC_BLUE,
|
|
19
|
-
SCIENCE_BLUE
|
|
17
|
+
SCIENCE_BLUE,
|
|
18
|
+
LUCKY_POINT,
|
|
19
|
+
HAWKES_BLUE
|
|
20
20
|
} from "../../../constants/colors";
|
|
21
21
|
|
|
22
22
|
const background = {
|
|
23
|
-
info: `${
|
|
23
|
+
info: `${HAWKES_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: `${LUCKY_POINT}`,
|
|
31
31
|
warn: `${ZEST_ORANGE}`,
|
|
32
32
|
error: `${RAZZMATAZZ_RED}`,
|
|
33
33
|
success: `${EMERALD_GREEN}`
|
|
@@ -8,6 +8,7 @@ import ButtonWithAction from "../button-with-action";
|
|
|
8
8
|
import ButtonWithLink from "../button-with-link";
|
|
9
9
|
import { WHITE, CHARADE_GREY, STORM_GREY } from "../../../constants/colors";
|
|
10
10
|
import Popover from "../../molecules/popover";
|
|
11
|
+
import Tooltip from "../../molecules/tooltip";
|
|
11
12
|
|
|
12
13
|
const DisplayCard = ({
|
|
13
14
|
title,
|
|
@@ -17,6 +18,24 @@ const DisplayCard = ({
|
|
|
17
18
|
url,
|
|
18
19
|
link = false,
|
|
19
20
|
helpText,
|
|
21
|
+
hasTooltip = false,
|
|
22
|
+
tooltipTriggerText = "",
|
|
23
|
+
tooltipContent = "",
|
|
24
|
+
tooltipPosition = {
|
|
25
|
+
top: "auto",
|
|
26
|
+
bottom: "calc(100% + 0.25rem)",
|
|
27
|
+
left: "auto",
|
|
28
|
+
right: "0"
|
|
29
|
+
},
|
|
30
|
+
tooltipArrowPosition = {
|
|
31
|
+
arrowBottom: "-0.5rem",
|
|
32
|
+
arrowRight: "0.625rem",
|
|
33
|
+
arrowTop: "auto",
|
|
34
|
+
arrowLeft: "auto"
|
|
35
|
+
},
|
|
36
|
+
tooltipArrowDirection,
|
|
37
|
+
tooltipExtraStyles,
|
|
38
|
+
tooltipTextExtraStyles = `max-width: 300px;`,
|
|
20
39
|
hasPopover = false,
|
|
21
40
|
popoverTriggerText = "",
|
|
22
41
|
popoverContent = "",
|
|
@@ -42,6 +61,17 @@ const DisplayCard = ({
|
|
|
42
61
|
popoverTextExtraStyles={popoverTextExtraStyles}
|
|
43
62
|
/>
|
|
44
63
|
)}
|
|
64
|
+
{hasTooltip && (
|
|
65
|
+
<Tooltip
|
|
66
|
+
triggerText={tooltipTriggerText}
|
|
67
|
+
content={tooltipContent}
|
|
68
|
+
textExtraStyles={tooltipTextExtraStyles}
|
|
69
|
+
position={tooltipPosition}
|
|
70
|
+
arrowPosition={tooltipArrowPosition}
|
|
71
|
+
arrowDirection={tooltipArrowDirection}
|
|
72
|
+
tooltipExtraStyles={tooltipExtraStyles}
|
|
73
|
+
/>
|
|
74
|
+
)}
|
|
45
75
|
</Cluster>
|
|
46
76
|
</Box>
|
|
47
77
|
<Box padding="0">
|
|
@@ -18,6 +18,14 @@ const meta = {
|
|
|
18
18
|
url: undefined,
|
|
19
19
|
link: false,
|
|
20
20
|
helpText: undefined,
|
|
21
|
+
hasTooltip: false,
|
|
22
|
+
tooltipTriggerText: "",
|
|
23
|
+
tooltipContent: "",
|
|
24
|
+
tooltipPosition: undefined,
|
|
25
|
+
tooltipArrowPosition: undefined,
|
|
26
|
+
tooltipArrowDirection: undefined,
|
|
27
|
+
tooltipExtraStyles: undefined,
|
|
28
|
+
tooltipTextExtraStyles: undefined,
|
|
21
29
|
hasPopover: false,
|
|
22
30
|
popoverTriggerText: "",
|
|
23
31
|
popoverContent: "",
|
|
@@ -76,6 +84,64 @@ const meta = {
|
|
|
76
84
|
defaultValue: { summary: undefined }
|
|
77
85
|
}
|
|
78
86
|
},
|
|
87
|
+
hasTooltip: {
|
|
88
|
+
description: "Whether or not to render Tooltip component",
|
|
89
|
+
table: {
|
|
90
|
+
type: { summary: "boolean" },
|
|
91
|
+
defaultValue: { summary: false }
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
tooltipTriggerText: {
|
|
95
|
+
description: "Text that triggers the tooltip",
|
|
96
|
+
table: {
|
|
97
|
+
type: { summary: "string" },
|
|
98
|
+
defaultValue: { summary: "" }
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
tooltipContent: {
|
|
102
|
+
description: "Content displayed inside the tooltip",
|
|
103
|
+
table: {
|
|
104
|
+
type: { summary: "string" },
|
|
105
|
+
defaultValue: { summary: "" }
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
tooltipPosition: {
|
|
109
|
+
description:
|
|
110
|
+
"Object with top/right/bottom/left values for tooltip position relative to trigger",
|
|
111
|
+
table: {
|
|
112
|
+
type: { summary: "Object" },
|
|
113
|
+
defaultValue: { summary: undefined }
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
tooltipArrowPosition: {
|
|
117
|
+
description:
|
|
118
|
+
"Object with arrowTop/arrowRight/arrowBottom/arrowLeft values for the tooltip arrow",
|
|
119
|
+
table: {
|
|
120
|
+
type: { summary: "Object" },
|
|
121
|
+
defaultValue: { summary: undefined }
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
tooltipArrowDirection: {
|
|
125
|
+
description: "Direction the tooltip arrow points",
|
|
126
|
+
table: {
|
|
127
|
+
type: { summary: "string" },
|
|
128
|
+
defaultValue: { summary: undefined }
|
|
129
|
+
}
|
|
130
|
+
},
|
|
131
|
+
tooltipExtraStyles: {
|
|
132
|
+
description: "Extra CSS styles to apply to the tooltip",
|
|
133
|
+
table: {
|
|
134
|
+
type: { summary: "string" },
|
|
135
|
+
defaultValue: { summary: undefined }
|
|
136
|
+
}
|
|
137
|
+
},
|
|
138
|
+
tooltipTextExtraStyles: {
|
|
139
|
+
description: "Extra CSS styles for the tooltip trigger text",
|
|
140
|
+
table: {
|
|
141
|
+
type: { summary: "string" },
|
|
142
|
+
defaultValue: { summary: "max-width: 300px;" }
|
|
143
|
+
}
|
|
144
|
+
},
|
|
79
145
|
hasPopover: {
|
|
80
146
|
description: "Whether or not to render Popover component",
|
|
81
147
|
table: {
|
|
@@ -154,6 +220,15 @@ export const WithPopover = {
|
|
|
154
220
|
render: args => <DisplayCard {...args} />
|
|
155
221
|
};
|
|
156
222
|
|
|
223
|
+
export const WithTooltip = {
|
|
224
|
+
args: {
|
|
225
|
+
hasTooltip: true,
|
|
226
|
+
tooltipTriggerText: "What's this?",
|
|
227
|
+
tooltipContent: "This is example tooltip content!"
|
|
228
|
+
},
|
|
229
|
+
render: args => <DisplayCard {...args} />
|
|
230
|
+
};
|
|
231
|
+
|
|
157
232
|
export const WithPopoverAndExtraStyles = {
|
|
158
233
|
args: {
|
|
159
234
|
hasPopover: true,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
|
|
3
|
-
const IconAdd = ({ strokeWidth = 1 }) => (
|
|
3
|
+
const IconAdd = ({ stroke = "none", strokeWidth = 1 }) => (
|
|
4
4
|
<svg
|
|
5
5
|
xmlns="http://www.w3.org/2000/svg"
|
|
6
6
|
xmlnsXlink="http://www.w3.org/1999/xlink"
|
|
@@ -15,7 +15,7 @@ const IconAdd = ({ strokeWidth = 1 }) => (
|
|
|
15
15
|
d="M7.91666623 4.78508747L4.78508747 4.78508747 4.78508747 7.91666623 3.74122788 7.91666623 3.74122788 4.78508747 0.609649123 4.78508747 0.609649123 3.74122788 3.74122788 3.74122788 3.74122788 0.609649123 4.78508747 0.609649123 4.78508747 3.74122788 7.91666623 3.74122788z"
|
|
16
16
|
></path>
|
|
17
17
|
</defs>
|
|
18
|
-
<g fill="none" fillRule="evenodd" stroke=
|
|
18
|
+
<g fill="none" fillRule="evenodd" stroke={stroke} strokeWidth={strokeWidth}>
|
|
19
19
|
<g transform="translate(-407 -563)">
|
|
20
20
|
<g transform="translate(408 562)">
|
|
21
21
|
<g transform="translate(0 2)">
|
|
@@ -47,3 +47,4 @@ export { default as MultipleSelectFilter } from "./multiple-select-filter";
|
|
|
47
47
|
export { default as ContactCard } from "./contact-card";
|
|
48
48
|
export { default as HeroImage } from "./hero-image";
|
|
49
49
|
export { default as TurnstileWidget } from "./turnstile-widget/TurnstileWidget";
|
|
50
|
+
export { default as Tooltip } from "./tooltip";
|
|
@@ -31,20 +31,15 @@ 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
|
-
|
|
39
34
|
const backButton =
|
|
40
35
|
!!cancelURL && !!cancelText ? (
|
|
41
|
-
<
|
|
36
|
+
<ButtonWithLink
|
|
42
37
|
text={cancelText}
|
|
43
|
-
|
|
38
|
+
url={cancelURL}
|
|
44
39
|
variant={backButtonVariant}
|
|
45
40
|
extraStyles={isMobile && "flex-grow: 1"}
|
|
46
41
|
dataQa={backButtonTestId || cancelText}
|
|
47
|
-
aria-
|
|
42
|
+
aria-labelledby={`${kebabCaseString(cancelText)}-button`}
|
|
48
43
|
role="link"
|
|
49
44
|
/>
|
|
50
45
|
) : (
|
|
@@ -55,7 +50,7 @@ const PaymentButtonBar = ({
|
|
|
55
50
|
action={backButtonAction}
|
|
56
51
|
extraStyles={isMobile && "flex-grow: 1"}
|
|
57
52
|
dataQa="Back"
|
|
58
|
-
aria-
|
|
53
|
+
aria-labelledby="back-button"
|
|
59
54
|
role="link"
|
|
60
55
|
/>
|
|
61
56
|
)
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import React, { useState } from "react";
|
|
2
|
+
import { themeComponent } from "../../../util/themeUtils";
|
|
3
|
+
import Text from "../../atoms/text";
|
|
4
|
+
import Paragraph from "../../atoms/paragraph";
|
|
5
|
+
import { Box } from "../../atoms/layouts";
|
|
6
|
+
import ButtonWithAction from "../../atoms/button-with-action";
|
|
7
|
+
import { noop } from "../../../util/general";
|
|
8
|
+
import { ESCAPE } from "../../../constants/keyboard";
|
|
9
|
+
import { fallbackValues } from "./Tooltip.theme";
|
|
10
|
+
import IconAdd from "../../atoms/icons/IconAdd";
|
|
11
|
+
import { BLACK } from "../../../constants/colors";
|
|
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
|
+
};
|
|
26
|
+
|
|
27
|
+
const Tooltip = ({
|
|
28
|
+
themeValues,
|
|
29
|
+
triggerText = "",
|
|
30
|
+
content = "",
|
|
31
|
+
hasIconTrigger = false,
|
|
32
|
+
IconTrigger = IconAdd,
|
|
33
|
+
iconHelpText = "",
|
|
34
|
+
tooltipID = 0,
|
|
35
|
+
extraStyles,
|
|
36
|
+
textExtraStyles = "",
|
|
37
|
+
minWidth = "250px",
|
|
38
|
+
maxWidth = "300px",
|
|
39
|
+
height = "auto",
|
|
40
|
+
position,
|
|
41
|
+
arrowPosition,
|
|
42
|
+
arrowDirection = "down",
|
|
43
|
+
transform = "none",
|
|
44
|
+
buttonExtraStyles,
|
|
45
|
+
backgroundColor = "white",
|
|
46
|
+
borderColor = "rgba(255, 255, 255, 0.85)",
|
|
47
|
+
tooltipExtraStyles
|
|
48
|
+
}) => {
|
|
49
|
+
const { hoverColor, activeColor, tooltipTriggerColor } = themeValues;
|
|
50
|
+
const { top = "-110px", right = "auto", bottom = "auto", left = "-225px" } =
|
|
51
|
+
position ?? {};
|
|
52
|
+
const {
|
|
53
|
+
arrowTop = "auto",
|
|
54
|
+
arrowRight = "10px",
|
|
55
|
+
arrowBottom = "-8px",
|
|
56
|
+
arrowLeft = "auto"
|
|
57
|
+
} = arrowPosition ?? {};
|
|
58
|
+
|
|
59
|
+
const [tooltipOpen, setTooltipOpen] = useState(false);
|
|
60
|
+
|
|
61
|
+
const handleToggleTooltip = tooltipState => {
|
|
62
|
+
if (tooltipOpen !== tooltipState) {
|
|
63
|
+
setTooltipOpen(tooltipState);
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
const handleKeyboardEvent = e => {
|
|
68
|
+
if (e.keyCode === ESCAPE || e.keyCode === 9) {
|
|
69
|
+
handleToggleTooltip(false);
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
return (
|
|
74
|
+
<Box padding="0" extraStyles={`position: relative; ${extraStyles}`}>
|
|
75
|
+
<ButtonWithAction
|
|
76
|
+
action={() => noop}
|
|
77
|
+
onFocus={() => handleToggleTooltip(true)}
|
|
78
|
+
onBlur={() => handleToggleTooltip(false)}
|
|
79
|
+
onKeyDown={handleKeyboardEvent}
|
|
80
|
+
onTouchStart={() => handleToggleTooltip(true)}
|
|
81
|
+
onTouchEnd={() => handleToggleTooltip(false)}
|
|
82
|
+
onMouseEnter={() => handleToggleTooltip(true)}
|
|
83
|
+
onMouseLeave={() => handleToggleTooltip(false)}
|
|
84
|
+
contentOverride
|
|
85
|
+
variant="smallGhost"
|
|
86
|
+
tabIndex="0"
|
|
87
|
+
aria-describedby={tooltipID}
|
|
88
|
+
extraStyles={buttonExtraStyles}
|
|
89
|
+
>
|
|
90
|
+
{hasIconTrigger && (
|
|
91
|
+
<>
|
|
92
|
+
<IconTrigger stroke={BLACK} />
|
|
93
|
+
<Box padding="0" srOnly>
|
|
94
|
+
<Text>{iconHelpText}</Text>
|
|
95
|
+
</Box>
|
|
96
|
+
</>
|
|
97
|
+
)}
|
|
98
|
+
{!hasIconTrigger && (
|
|
99
|
+
<Text extraStyles={textExtraStyles}>{triggerText}</Text>
|
|
100
|
+
)}
|
|
101
|
+
</ButtonWithAction>
|
|
102
|
+
<Box
|
|
103
|
+
background={backgroundColor}
|
|
104
|
+
borderRadius="4px"
|
|
105
|
+
boxShadow="0px 2px 14px 0px rgb(246, 246, 249), 0px 3px 8px 0px rgb(202, 206, 216)"
|
|
106
|
+
id={tooltipID}
|
|
107
|
+
role="tooltip"
|
|
108
|
+
minWidth={minWidth}
|
|
109
|
+
maxWidth={maxWidth}
|
|
110
|
+
extraStyles={`
|
|
111
|
+
display: ${tooltipOpen ? "block" : "none"};
|
|
112
|
+
position: absolute;
|
|
113
|
+
top: ${top};
|
|
114
|
+
right: ${right};
|
|
115
|
+
bottom: ${bottom};
|
|
116
|
+
left: ${left};
|
|
117
|
+
height: ${height};
|
|
118
|
+
transform: ${transform};
|
|
119
|
+
${tooltipExtraStyles};
|
|
120
|
+
`}
|
|
121
|
+
>
|
|
122
|
+
<Paragraph>{content}</Paragraph>
|
|
123
|
+
<Box
|
|
124
|
+
padding="0"
|
|
125
|
+
extraStyles={`
|
|
126
|
+
position: absolute;
|
|
127
|
+
content: "";
|
|
128
|
+
width: 0;
|
|
129
|
+
height: 0;
|
|
130
|
+
${arrowBorder(borderColor, arrowDirection, "8px")};
|
|
131
|
+
filter: drop-shadow(2px 8px 14px black);
|
|
132
|
+
bottom: ${arrowBottom};
|
|
133
|
+
right: ${arrowRight};
|
|
134
|
+
top: ${arrowTop};
|
|
135
|
+
left: ${arrowLeft};
|
|
136
|
+
`}
|
|
137
|
+
/>
|
|
138
|
+
</Box>
|
|
139
|
+
</Box>
|
|
140
|
+
);
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
export default themeComponent(Tooltip, "Tooltip", fallbackValues);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Canvas, Meta, Title, Story, Controls } from '@storybook/blocks';
|
|
2
|
+
|
|
3
|
+
import * as TooltipStories from './Tooltip.stories.js';
|
|
4
|
+
|
|
5
|
+
<Meta of={TooltipStories} />
|
|
6
|
+
|
|
7
|
+
<Title />
|
|
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 `icon` prop. The trigger is rendered as a `ButtonWithAction` with the `smallGhost` variant.
|
|
10
|
+
|
|
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
|
+
|
|
13
|
+
<Controls />
|
|
14
|
+
|
|
15
|
+
<Story />
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import Tooltip from "./Tooltip";
|
|
2
|
+
import IconAdd from "../../atoms/icons/IconAdd";
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
title: "Molecules/Tooltip",
|
|
6
|
+
component: Tooltip,
|
|
7
|
+
tags: ["!autodocs"],
|
|
8
|
+
parameters: {
|
|
9
|
+
layout: "centered",
|
|
10
|
+
controls: { expanded: true }
|
|
11
|
+
},
|
|
12
|
+
args: {
|
|
13
|
+
triggerText: "",
|
|
14
|
+
content: "",
|
|
15
|
+
hasIconTrigger: false,
|
|
16
|
+
IconTrigger: IconAdd,
|
|
17
|
+
iconHelpText: "",
|
|
18
|
+
tooltipID: 0,
|
|
19
|
+
extraStyles: undefined,
|
|
20
|
+
textExtraStyles: undefined,
|
|
21
|
+
minWidth: "250px",
|
|
22
|
+
maxWidth: "300px",
|
|
23
|
+
height: "auto",
|
|
24
|
+
position: undefined,
|
|
25
|
+
arrowPosition: undefined,
|
|
26
|
+
arrowDirection: "down",
|
|
27
|
+
transform: "none",
|
|
28
|
+
buttonExtraStyles: undefined,
|
|
29
|
+
backgroundColor: "white",
|
|
30
|
+
borderColor: "rgba(255, 255, 255, 0.85)",
|
|
31
|
+
tooltipExtraStyles: undefined
|
|
32
|
+
},
|
|
33
|
+
argTypes: {
|
|
34
|
+
triggerText: {
|
|
35
|
+
description:
|
|
36
|
+
"Text element that tooltip is anchored to. Only used if hasIcon is false.",
|
|
37
|
+
table: {
|
|
38
|
+
type: { summary: "string" },
|
|
39
|
+
defaultValue: { summary: "" }
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
content: {
|
|
43
|
+
description: "Content of the tooltip",
|
|
44
|
+
table: {
|
|
45
|
+
type: { summary: "string" },
|
|
46
|
+
defaultValue: { summary: "" }
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
hasIconTrigger: {
|
|
50
|
+
description:
|
|
51
|
+
"Whether an icon is the trigger for the tooltip, instead of text",
|
|
52
|
+
table: {
|
|
53
|
+
type: { summary: "boolean" },
|
|
54
|
+
defaultValue: { summary: false }
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
IconTrigger: {
|
|
58
|
+
description:
|
|
59
|
+
"The icon component to display. Requires hasIcon to be true.",
|
|
60
|
+
table: {
|
|
61
|
+
type: { summary: "React Component" },
|
|
62
|
+
defaultValue: { summary: "IconAdd" }
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
iconHelpText: {
|
|
66
|
+
description: "Accessible description of the icon",
|
|
67
|
+
table: {
|
|
68
|
+
type: { summary: "string" },
|
|
69
|
+
defaultValue: { summary: undefined }
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
tooltipID: {
|
|
73
|
+
description:
|
|
74
|
+
"ID value for tooltip. Use if displaying multiple tooltips on the same page.",
|
|
75
|
+
table: {
|
|
76
|
+
type: { summary: "number" },
|
|
77
|
+
defaultValue: { summary: 0 }
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
extraStyles: {
|
|
81
|
+
description:
|
|
82
|
+
"Extra CSS styles to apply to the wrapper component around the trigger and tooltip",
|
|
83
|
+
table: {
|
|
84
|
+
type: { summary: "CSS string" },
|
|
85
|
+
defaultValue: { summary: undefined }
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
textExtraStyles: {
|
|
89
|
+
description: "Extra styles to apply to the text trigger of the tooltip",
|
|
90
|
+
table: {
|
|
91
|
+
type: { summary: "CSS string" },
|
|
92
|
+
defaultValue: { summary: undefined }
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
minWidth: {
|
|
96
|
+
description: "Minimum width of the tooltip component",
|
|
97
|
+
table: {
|
|
98
|
+
type: { summary: "string" },
|
|
99
|
+
defaultValue: { summary: "250px" }
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
maxWidth: {
|
|
103
|
+
description: "Maximum width of the tooltip component",
|
|
104
|
+
table: {
|
|
105
|
+
type: { summary: "string" },
|
|
106
|
+
defaultValue: { summary: "300px" }
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
height: {
|
|
110
|
+
description: "Height of the tooltip component. Default sizes to content.",
|
|
111
|
+
table: {
|
|
112
|
+
type: { summary: "string" },
|
|
113
|
+
defaultValue: { summary: "auto" }
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
position: {
|
|
117
|
+
description:
|
|
118
|
+
"Object containing values for top/right/bottom/left position of tooltip relative to trigger",
|
|
119
|
+
table: {
|
|
120
|
+
type: { summary: "Object" },
|
|
121
|
+
defaultValue: { summary: undefined }
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
arrowPosition: {
|
|
125
|
+
description:
|
|
126
|
+
"Object containing values for arrowTop/arrowRight/arrowBottom/arrowLeft position of arrow on tooltip",
|
|
127
|
+
table: {
|
|
128
|
+
type: { summary: "Object" },
|
|
129
|
+
defaultValue: { summary: undefined }
|
|
130
|
+
}
|
|
131
|
+
},
|
|
132
|
+
arrowDirection: {
|
|
133
|
+
description: "Direction the tooltip arrow points",
|
|
134
|
+
table: {
|
|
135
|
+
type: { summary: "string" },
|
|
136
|
+
defaultValue: { summary: "down" }
|
|
137
|
+
}
|
|
138
|
+
},
|
|
139
|
+
transform: {
|
|
140
|
+
description: "CSS transform to apply to tooltip",
|
|
141
|
+
table: {
|
|
142
|
+
type: { summary: "string" },
|
|
143
|
+
defaultValue: { summary: undefined }
|
|
144
|
+
}
|
|
145
|
+
},
|
|
146
|
+
buttonExtraStyles: {
|
|
147
|
+
description:
|
|
148
|
+
"Extra styles to apply to the button that wraps tooltip trigger",
|
|
149
|
+
table: {
|
|
150
|
+
type: { summary: "string" },
|
|
151
|
+
defaultValue: { summary: undefined }
|
|
152
|
+
}
|
|
153
|
+
},
|
|
154
|
+
backgroundColor: {
|
|
155
|
+
description: "Background color of the tooltip",
|
|
156
|
+
table: {
|
|
157
|
+
type: { summary: "string" },
|
|
158
|
+
defaultValue: { summary: "white" }
|
|
159
|
+
}
|
|
160
|
+
},
|
|
161
|
+
borderColor: {
|
|
162
|
+
description: "Color of the tooltip arrow",
|
|
163
|
+
table: {
|
|
164
|
+
type: { summary: "string" },
|
|
165
|
+
defaultValue: { summary: "rgba(255, 255, 255, 0.85)" }
|
|
166
|
+
}
|
|
167
|
+
},
|
|
168
|
+
tooltipExtraStyles: {
|
|
169
|
+
description: "Extra styles to apply to the tooltip",
|
|
170
|
+
table: {
|
|
171
|
+
type: { summary: "string" },
|
|
172
|
+
defaultValue: { summary: undefined }
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
export const BasicTooltip = {
|
|
179
|
+
args: {
|
|
180
|
+
triggerText: "Help",
|
|
181
|
+
content:
|
|
182
|
+
"Contact support at 1-800-CTY-VILL for help with your account balance."
|
|
183
|
+
}
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
export const IconTooltip = {
|
|
187
|
+
args: {
|
|
188
|
+
hasIconTrigger: true,
|
|
189
|
+
IconTrigger: IconAdd,
|
|
190
|
+
content:
|
|
191
|
+
"Contact support at 1-800-CTY-VILL for help with your account balance."
|
|
192
|
+
}
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
export const UnderneathTooltip = {
|
|
196
|
+
args: {
|
|
197
|
+
triggerText: "What's this?",
|
|
198
|
+
content:
|
|
199
|
+
"Contact support at 1-800-CTY-VILL for help with your account balance.",
|
|
200
|
+
position: { top: "50px", left: "-100px" },
|
|
201
|
+
arrowPosition: { arrowTop: "-8px", arrowLeft: "50%" },
|
|
202
|
+
arrowDirection: "up"
|
|
203
|
+
}
|
|
204
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import Expand from "../../../util/expand";
|
|
3
|
+
|
|
4
|
+
export interface TooltipProps {
|
|
5
|
+
triggerText?: string | JSX.Element;
|
|
6
|
+
content?: string | JSX.Element;
|
|
7
|
+
hasIcon?: boolean;
|
|
8
|
+
iconHelpText?: string;
|
|
9
|
+
tooltipID?: number;
|
|
10
|
+
extraStyles?: string;
|
|
11
|
+
textExtraStyles?: string;
|
|
12
|
+
minWidth?: string;
|
|
13
|
+
maxWidth?: string;
|
|
14
|
+
height?: string;
|
|
15
|
+
position?: { top: string; right: string; bottom: string; left: string };
|
|
16
|
+
arrowPosition?: {
|
|
17
|
+
arrowTop: string;
|
|
18
|
+
arrowRight: string;
|
|
19
|
+
arrowBottom: string;
|
|
20
|
+
arrowLeft: string;
|
|
21
|
+
};
|
|
22
|
+
arrowDirection?: "left" | "right" | "top" | "bottom";
|
|
23
|
+
transform?: string;
|
|
24
|
+
buttonExtraStyles?: string;
|
|
25
|
+
borderColor?: string;
|
|
26
|
+
backgroundColor?: string;
|
|
27
|
+
tooltipExtraStyles?: string;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export const Tooltip: React.FC<Expand<TooltipProps> &
|
|
31
|
+
React.HTMLAttributes<HTMLElement>>;
|
package/src/components/.DS_Store
DELETED
|
Binary file
|