@thecb/components 11.10.0-beta.2 → 11.10.1-beta.0
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 +86 -109
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +86 -109
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/atoms/card-type/CardType.js +1 -9
- package/src/components/atoms/formatted-credit-card/FormattedCreditCard.js +7 -10
- package/src/components/atoms/icons/AmExSmallIcon.js +0 -2
- package/src/components/atoms/icons/DiscoverSmallIcon.js +0 -2
- package/src/components/atoms/icons/GenericCardLarge.js +1 -1
- package/src/components/atoms/icons/GenericSmallIcon.js +0 -2
- package/src/components/atoms/icons/MasterCardSmallIcon.js +0 -2
- package/src/components/atoms/icons/VisaSmallIcon.js +0 -2
- package/src/components/molecules/radio-section/InnerRadioSection.js +2 -2
- package/src/components/molecules/tooltip/Tooltip.js +61 -94
- package/src/components/molecules/tooltip/Tooltip.mdx +12 -2
- package/src/components/molecules/tooltip/Tooltip.stories.js +79 -71
- package/src/components/molecules/tooltip/Tooltip.theme.js +15 -5
- package/src/components/molecules/tooltip/index.d.ts +4 -7
package/package.json
CHANGED
|
@@ -34,17 +34,9 @@ const cardBrands = {
|
|
|
34
34
|
}
|
|
35
35
|
};
|
|
36
36
|
|
|
37
|
-
const normalizeType = type => {
|
|
38
|
-
if (!type) return undefined;
|
|
39
|
-
const lower = type.toLowerCase();
|
|
40
|
-
if (lower === "mastercard") return "master_card";
|
|
41
|
-
return lower;
|
|
42
|
-
};
|
|
43
|
-
|
|
44
37
|
const CardType = ({ type, size = "small" }) => {
|
|
45
|
-
const normalizedType = normalizeType(type);
|
|
46
38
|
const { label, [size]: IconComponent } =
|
|
47
|
-
cardBrands[
|
|
39
|
+
cardBrands[type] || cardBrands.default;
|
|
48
40
|
return (
|
|
49
41
|
<span role="img" aria-label={label}>
|
|
50
42
|
<IconComponent />
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import React, { Fragment
|
|
2
|
-
import styled
|
|
1
|
+
import React, { Fragment } from "react";
|
|
2
|
+
import styled from "styled-components";
|
|
3
3
|
import CardType from "../card-type";
|
|
4
4
|
import Text from "../text";
|
|
5
5
|
import { Box, Stack } from "../layouts";
|
|
@@ -15,7 +15,7 @@ export const CreditCardWrapper = styled.div`
|
|
|
15
15
|
|
|
16
16
|
export const CCIconWrapper = styled.div`
|
|
17
17
|
margin-right: 16px;
|
|
18
|
-
width:
|
|
18
|
+
width: 30px;
|
|
19
19
|
height: auto;
|
|
20
20
|
display: flex;
|
|
21
21
|
`;
|
|
@@ -27,18 +27,16 @@ const FormattedCreditCard = ({
|
|
|
27
27
|
expireDate,
|
|
28
28
|
expirationStatus,
|
|
29
29
|
themeValues
|
|
30
|
-
}) =>
|
|
31
|
-
const { isMobile } = useContext(ThemeContext);
|
|
32
|
-
return (
|
|
30
|
+
}) => (
|
|
33
31
|
<CreditCardWrapper>
|
|
34
32
|
<CCIconWrapper>
|
|
35
|
-
<CardType type={type}
|
|
33
|
+
<CardType type={type} />
|
|
36
34
|
</CCIconWrapper>
|
|
37
35
|
<Stack childGap="0">
|
|
38
36
|
<Box padding="0">
|
|
39
37
|
<Text
|
|
40
38
|
variant="p"
|
|
41
|
-
padding="0"
|
|
39
|
+
padding="0 0 0 8px"
|
|
42
40
|
color={themeValues.textColor}
|
|
43
41
|
textAlign="left"
|
|
44
42
|
extraStyles={`display: inline-block;`}
|
|
@@ -60,8 +58,7 @@ const FormattedCreditCard = ({
|
|
|
60
58
|
)}
|
|
61
59
|
</Stack>
|
|
62
60
|
</CreditCardWrapper>
|
|
63
|
-
|
|
64
|
-
};
|
|
61
|
+
);
|
|
65
62
|
export default themeComponent(
|
|
66
63
|
FormattedCreditCard,
|
|
67
64
|
"FormattedCreditCard",
|
|
@@ -69,8 +69,8 @@ const InnerRadioSection = ({
|
|
|
69
69
|
`;
|
|
70
70
|
|
|
71
71
|
const RightIcon = styled.img`
|
|
72
|
-
height: ${({ isMobile }) => (isMobile ? "
|
|
73
|
-
width: ${({ isMobile }) => (isMobile ? "
|
|
72
|
+
height: ${({ isMobile }) => (isMobile ? "14px" : "18px")};
|
|
73
|
+
width: ${({ isMobile }) => (isMobile ? "22px" : "28px")};
|
|
74
74
|
${({ fade }) => fade && "opacity: 0.4;"}
|
|
75
75
|
transition: opacity 0.3s ease;
|
|
76
76
|
`;
|
|
@@ -2,34 +2,23 @@ import React, { useContext, useEffect, useRef, useState } from "react";
|
|
|
2
2
|
import { createThemeValues } from "../../../util/themeUtils";
|
|
3
3
|
import { ThemeContext } from "styled-components";
|
|
4
4
|
import Text from "../../atoms/text";
|
|
5
|
-
import Paragraph from "../../atoms/paragraph";
|
|
6
5
|
import { Box } from "../../atoms/layouts";
|
|
7
6
|
import ButtonWithAction from "../../atoms/button-with-action";
|
|
8
7
|
import { noop, arrowBorder } from "../../../util/general";
|
|
9
|
-
import
|
|
10
|
-
import {
|
|
11
|
-
MATISSE_BLUE,
|
|
12
|
-
PEACOCK_BLUE,
|
|
13
|
-
SAPPHIRE_BLUE,
|
|
14
|
-
WHITE
|
|
15
|
-
} from "../../../constants/colors";
|
|
16
|
-
|
|
17
|
-
const TOOLTIP_THEME_SOURCE = "Popover";
|
|
18
|
-
|
|
19
|
-
const fallbackValues = {
|
|
20
|
-
hoverColor: SAPPHIRE_BLUE,
|
|
21
|
-
activeColor: PEACOCK_BLUE,
|
|
22
|
-
popoverTriggerColor: MATISSE_BLUE,
|
|
23
|
-
borderColor: `rgba(255, 255, 255, 0.85)`
|
|
24
|
-
};
|
|
8
|
+
import { TOOLTIP_THEME_SOURCE, fallbackValues } from "./Tooltip.theme";
|
|
25
9
|
|
|
26
10
|
const Tooltip = ({
|
|
27
11
|
tooltipID,
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
12
|
+
children,
|
|
13
|
+
triggerText = "",
|
|
14
|
+
containerExtraStyles = "",
|
|
15
|
+
triggerButtonVariant = "smallGhost",
|
|
16
|
+
content = "",
|
|
17
|
+
contentBackgroundColor = fallbackValues.borderColor,
|
|
18
|
+
contentExtraStyles = "",
|
|
19
|
+
minWidth = "250px",
|
|
20
|
+
maxWidth = "100%",
|
|
21
|
+
height = "auto",
|
|
33
22
|
contentPosition = {
|
|
34
23
|
top: "-110px",
|
|
35
24
|
right: "auto",
|
|
@@ -42,15 +31,7 @@ const Tooltip = ({
|
|
|
42
31
|
arrowRight: "10px",
|
|
43
32
|
arrowBottom: "-8px",
|
|
44
33
|
arrowLeft: "auto"
|
|
45
|
-
}
|
|
46
|
-
minWidth = "250px",
|
|
47
|
-
maxWidth = "300px",
|
|
48
|
-
height = "auto",
|
|
49
|
-
containerExtraStyles = "",
|
|
50
|
-
triggerExtraStyles = "",
|
|
51
|
-
triggerButtonVariant = "smallGhost",
|
|
52
|
-
contentExtraStyles = "",
|
|
53
|
-
contentBackgroundColor = WHITE
|
|
34
|
+
}
|
|
54
35
|
}) => {
|
|
55
36
|
const closeTimeoutRef = useRef(null);
|
|
56
37
|
const [tooltipOpen, setTooltipOpen] = useState(false);
|
|
@@ -61,23 +42,16 @@ const Tooltip = ({
|
|
|
61
42
|
TOOLTIP_THEME_SOURCE
|
|
62
43
|
);
|
|
63
44
|
|
|
64
|
-
const {
|
|
65
|
-
borderColor,
|
|
66
|
-
popoverTriggerColor: tooltipTriggerColor,
|
|
67
|
-
hoverColor,
|
|
68
|
-
activeColor
|
|
69
|
-
} = themeValues;
|
|
70
|
-
|
|
71
45
|
const { top, right, bottom, left } = contentPosition;
|
|
72
46
|
const { arrowTop, arrowRight, arrowBottom, arrowLeft } = arrowPosition;
|
|
73
47
|
|
|
74
|
-
const handleToggleTooltip =
|
|
75
|
-
if (tooltipOpen !==
|
|
76
|
-
setTooltipOpen(
|
|
48
|
+
const handleToggleTooltip = desiredState => {
|
|
49
|
+
if (tooltipOpen !== desiredState) {
|
|
50
|
+
setTooltipOpen(desiredState);
|
|
77
51
|
}
|
|
78
52
|
};
|
|
79
53
|
|
|
80
|
-
const
|
|
54
|
+
const handleKeyDown = e => {
|
|
81
55
|
if (e.key === "Escape") {
|
|
82
56
|
handleToggleTooltip(false);
|
|
83
57
|
}
|
|
@@ -105,80 +79,73 @@ const Tooltip = ({
|
|
|
105
79
|
};
|
|
106
80
|
}, []);
|
|
107
81
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
82
|
+
const renderTrigger = () => {
|
|
83
|
+
if (children) {
|
|
84
|
+
return React.cloneElement(React.Children.only(children), {
|
|
85
|
+
"aria-describedby": tooltipID,
|
|
86
|
+
onFocus: () => handleToggleTooltip(true),
|
|
87
|
+
onBlur: () => handleToggleTooltip(false),
|
|
88
|
+
onKeyDown: handleKeyDown
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return (
|
|
117
93
|
<ButtonWithAction
|
|
94
|
+
action={noop}
|
|
118
95
|
aria-describedby={tooltipID}
|
|
119
|
-
onKeyDown={
|
|
96
|
+
onKeyDown={handleKeyDown}
|
|
120
97
|
variant={triggerButtonVariant}
|
|
121
98
|
onFocus={() => handleToggleTooltip(true)}
|
|
122
99
|
onBlur={() => handleToggleTooltip(false)}
|
|
123
100
|
onTouchStart={() => handleToggleTooltip(true)}
|
|
124
|
-
data-qa=
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
&:hover {
|
|
146
|
-
color: ${hoverColor};
|
|
147
|
-
}
|
|
148
|
-
&:active,
|
|
149
|
-
&:focus {
|
|
150
|
-
color: ${activeColor};
|
|
151
|
-
}
|
|
152
|
-
${triggerExtraStyles};
|
|
153
|
-
`}
|
|
154
|
-
>
|
|
155
|
-
{triggerText}
|
|
156
|
-
</Text>
|
|
157
|
-
)}
|
|
158
|
-
</ButtonWithAction>
|
|
101
|
+
data-qa={`tooltip-trigger-${tooltipID}`}
|
|
102
|
+
text={triggerText}
|
|
103
|
+
extraStyles={`
|
|
104
|
+
color: ${themeValues.linkColor};
|
|
105
|
+
&:hover { color: ${themeValues.hoverColor}; text-decoration: none;}
|
|
106
|
+
&:active, &:focus { color: ${themeValues.activeColor}; text-decoration: none;}
|
|
107
|
+
button, span, &:hover span { text-decoration: none; }
|
|
108
|
+
`}
|
|
109
|
+
/>
|
|
110
|
+
);
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
return (
|
|
114
|
+
<Box
|
|
115
|
+
padding="0"
|
|
116
|
+
extraStyles={`position: relative; ${containerExtraStyles}`}
|
|
117
|
+
onMouseEnter={handleMouseEnter}
|
|
118
|
+
onMouseLeave={handleMouseLeave}
|
|
119
|
+
data-qa={`${tooltipID}-container`}
|
|
120
|
+
>
|
|
121
|
+
{renderTrigger()}
|
|
159
122
|
<Box
|
|
160
123
|
role="tooltip"
|
|
161
124
|
id={tooltipID}
|
|
162
125
|
aria-hidden={!tooltipOpen}
|
|
163
|
-
background={
|
|
126
|
+
background={themeValues.borderColor}
|
|
164
127
|
data-qa="tooltip-contents"
|
|
165
128
|
extraStyles={`
|
|
166
129
|
position: absolute;
|
|
167
130
|
display: ${tooltipOpen ? "block" : "none"};
|
|
168
|
-
top: ${top};
|
|
131
|
+
top: ${top};
|
|
169
132
|
right: ${right};
|
|
170
133
|
bottom: ${bottom};
|
|
171
134
|
left: ${left};
|
|
172
135
|
height: ${height};
|
|
173
136
|
${contentExtraStyles}
|
|
174
|
-
|
|
175
|
-
boxShadow=
|
|
176
|
-
border=
|
|
137
|
+
`}
|
|
138
|
+
boxShadow="0px 2px 14px 0px rgb(246, 246, 249), 0px 3px 8px 0px rgb(202, 206, 216)"
|
|
139
|
+
border="1px solid transparent"
|
|
177
140
|
borderRadius="4px"
|
|
178
141
|
minWidth={minWidth}
|
|
179
142
|
maxWidth={maxWidth}
|
|
180
143
|
>
|
|
181
|
-
|
|
144
|
+
{typeof content === "string" ? (
|
|
145
|
+
<Text color={themeValues.linkColor}>{content}</Text>
|
|
146
|
+
) : (
|
|
147
|
+
content
|
|
148
|
+
)}
|
|
182
149
|
<Box
|
|
183
150
|
padding="0"
|
|
184
151
|
extraStyles={`
|
|
@@ -186,7 +153,7 @@ const Tooltip = ({
|
|
|
186
153
|
content: "";
|
|
187
154
|
width: 0;
|
|
188
155
|
height: 0;
|
|
189
|
-
${arrowBorder(borderColor, arrowDirection, "8px")};
|
|
156
|
+
${arrowBorder(themeValues.borderColor, arrowDirection, "8px")};
|
|
190
157
|
filter: drop-shadow(2px 8px 14px black);
|
|
191
158
|
bottom: ${arrowBottom};
|
|
192
159
|
right: ${arrowRight};
|
|
@@ -6,9 +6,19 @@ import * as TooltipStories from './Tooltip.stories.js';
|
|
|
6
6
|
|
|
7
7
|
<Title />
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
Tooltip is an accessible tooltip component implementing the [WAI-ARIA Tooltip Pattern](https://www.w3.org/WAI/ARIA/apg/patterns/tooltip/). It displays supplemental information when the user hovers over or focuses on a trigger element.
|
|
10
10
|
|
|
11
|
-
The
|
|
11
|
+
The trigger can be either:
|
|
12
|
+
- **Custom children**: Pass any single React element as `children`. It will receive `aria-describedby`, focus, blur, and keyboard handlers automatically.
|
|
13
|
+
- **Default button**: When no `children` are provided, a `ButtonWithAction` is rendered using the `triggerText` prop.
|
|
14
|
+
|
|
15
|
+
The tooltip content (`content` prop) accepts a plain string or a React node for rich content. It is styled similarly to the Popover component, including an arrow pointing toward the trigger.
|
|
16
|
+
|
|
17
|
+
### Accessibility
|
|
18
|
+
- The trigger element has `aria-describedby` referencing the tooltip.
|
|
19
|
+
- The tooltip container has `role="tooltip"`.
|
|
20
|
+
- Pressing **Escape** dismisses the tooltip.
|
|
21
|
+
- Focus stays on the trigger while the tooltip is displayed.
|
|
12
22
|
|
|
13
23
|
<Controls />
|
|
14
24
|
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import Tooltip from "./Tooltip";
|
|
3
|
-
import WarningIconXS from "../../atoms/icons/WarningIconXS";
|
|
4
3
|
|
|
5
4
|
const meta = {
|
|
6
5
|
title: "Molecules/Tooltip",
|
|
@@ -18,11 +17,8 @@ const meta = {
|
|
|
18
17
|
],
|
|
19
18
|
args: {
|
|
20
19
|
tooltipID: "tooltip-id",
|
|
21
|
-
hasIconTrigger: false,
|
|
22
|
-
IconTrigger: WarningIconXS,
|
|
23
|
-
iconHelpText: "Open the tooltip",
|
|
24
20
|
triggerText: "Hover me",
|
|
25
|
-
|
|
21
|
+
content: "This is the tooltip content.",
|
|
26
22
|
contentPosition: {
|
|
27
23
|
top: "-110px",
|
|
28
24
|
right: "auto",
|
|
@@ -40,71 +36,56 @@ const meta = {
|
|
|
40
36
|
maxWidth: "300px",
|
|
41
37
|
height: "auto",
|
|
42
38
|
containerExtraStyles: "",
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
contentBackgroundColor: "",
|
|
46
|
-
contentExtraStyles: ""
|
|
39
|
+
contentExtraStyles: "",
|
|
40
|
+
contentBackgroundColor: ""
|
|
47
41
|
},
|
|
48
42
|
argTypes: {
|
|
49
|
-
|
|
43
|
+
children: {
|
|
50
44
|
description:
|
|
51
|
-
"
|
|
45
|
+
"Optional trigger element. When provided, it replaces the default ButtonWithAction trigger. The child element will receive aria-describedby, focus, blur, and keydown handlers.",
|
|
52
46
|
table: {
|
|
53
|
-
type: { summary: "
|
|
47
|
+
type: { summary: "React.ReactNode" },
|
|
54
48
|
defaultValue: { summary: undefined }
|
|
55
49
|
}
|
|
56
50
|
},
|
|
57
|
-
|
|
51
|
+
content: {
|
|
58
52
|
description:
|
|
59
|
-
"
|
|
60
|
-
control: { type: "boolean" },
|
|
53
|
+
"The content displayed inside the tooltip. Can be a string or a React node/element.",
|
|
61
54
|
table: {
|
|
62
|
-
type: { summary: "
|
|
63
|
-
defaultValue: { summary:
|
|
55
|
+
type: { summary: "string | React.ReactNode" },
|
|
56
|
+
defaultValue: { summary: '""' }
|
|
64
57
|
}
|
|
65
58
|
},
|
|
66
|
-
|
|
59
|
+
tooltipID: {
|
|
67
60
|
description:
|
|
68
|
-
"
|
|
69
|
-
table: {
|
|
70
|
-
type: { summary: "React Component" },
|
|
71
|
-
defaultValue: { summary: "WarningIconXS" }
|
|
72
|
-
}
|
|
73
|
-
},
|
|
74
|
-
iconHelpText: {
|
|
75
|
-
description: "Screen reader text for the icon trigger",
|
|
61
|
+
"Unique ID for the tooltip content element. Used as the aria-describedby value on the trigger.",
|
|
76
62
|
table: {
|
|
77
63
|
type: { summary: "string" },
|
|
78
|
-
defaultValue: { summary:
|
|
64
|
+
defaultValue: { summary: undefined }
|
|
79
65
|
}
|
|
80
66
|
},
|
|
81
67
|
triggerText: {
|
|
82
68
|
description:
|
|
83
|
-
"Text
|
|
84
|
-
table: {
|
|
85
|
-
type: { summary: "string | JSX.Element" },
|
|
86
|
-
defaultValue: { summary: "Open the tooltip" }
|
|
87
|
-
}
|
|
88
|
-
},
|
|
89
|
-
tooltipContent: {
|
|
90
|
-
description: "The content displayed inside the tooltip",
|
|
69
|
+
"Text shown in the default ButtonWithAction trigger. Not needed when children are provided.",
|
|
91
70
|
table: {
|
|
92
71
|
type: { summary: "string" },
|
|
93
|
-
defaultValue: { summary: "
|
|
72
|
+
defaultValue: { summary: '""' }
|
|
94
73
|
}
|
|
95
74
|
},
|
|
96
75
|
contentPosition: {
|
|
97
76
|
description:
|
|
98
|
-
"CSS position values (top, right, bottom, left) for the tooltip content box relative to the trigger",
|
|
77
|
+
"CSS position values (top, right, bottom, left) for the tooltip content box relative to the trigger.",
|
|
99
78
|
table: {
|
|
100
79
|
type: { summary: "object" },
|
|
101
80
|
defaultValue: {
|
|
102
|
-
summary:
|
|
81
|
+
summary:
|
|
82
|
+
'{ top: "-110px", right: "auto", bottom: "auto", left: "-225px" }'
|
|
103
83
|
}
|
|
104
84
|
}
|
|
105
85
|
},
|
|
106
86
|
arrowDirection: {
|
|
107
|
-
description:
|
|
87
|
+
description:
|
|
88
|
+
"Direction the tooltip arrow points (up, down, left, right).",
|
|
108
89
|
control: { type: "select" },
|
|
109
90
|
options: ["up", "down", "left", "right"],
|
|
110
91
|
table: {
|
|
@@ -114,30 +95,31 @@ const meta = {
|
|
|
114
95
|
},
|
|
115
96
|
arrowPosition: {
|
|
116
97
|
description:
|
|
117
|
-
"CSS position values (arrowTop, arrowRight, arrowBottom, arrowLeft) for the arrow element",
|
|
98
|
+
"CSS position values (arrowTop, arrowRight, arrowBottom, arrowLeft) for the arrow element.",
|
|
118
99
|
table: {
|
|
119
100
|
type: { summary: "object" },
|
|
120
101
|
defaultValue: {
|
|
121
|
-
summary:
|
|
102
|
+
summary:
|
|
103
|
+
'{ arrowTop: "auto", arrowRight: "10px", arrowBottom: "-8px", arrowLeft: "auto" }'
|
|
122
104
|
}
|
|
123
105
|
}
|
|
124
106
|
},
|
|
125
107
|
minWidth: {
|
|
126
|
-
description: "Minimum width of the tooltip content box",
|
|
108
|
+
description: "Minimum width of the tooltip content box.",
|
|
127
109
|
table: {
|
|
128
110
|
type: { summary: "string" },
|
|
129
111
|
defaultValue: { summary: "250px" }
|
|
130
112
|
}
|
|
131
113
|
},
|
|
132
114
|
maxWidth: {
|
|
133
|
-
description: "Maximum width of the tooltip content box",
|
|
115
|
+
description: "Maximum width of the tooltip content box.",
|
|
134
116
|
table: {
|
|
135
117
|
type: { summary: "string" },
|
|
136
118
|
defaultValue: { summary: "300px" }
|
|
137
119
|
}
|
|
138
120
|
},
|
|
139
121
|
height: {
|
|
140
|
-
description: "Height of the tooltip content box",
|
|
122
|
+
description: "Height of the tooltip content box.",
|
|
141
123
|
table: {
|
|
142
124
|
type: { summary: "string" },
|
|
143
125
|
defaultValue: { summary: "auto" }
|
|
@@ -145,25 +127,25 @@ const meta = {
|
|
|
145
127
|
},
|
|
146
128
|
containerExtraStyles: {
|
|
147
129
|
description:
|
|
148
|
-
"Additional CSS string applied to the tooltip container element",
|
|
130
|
+
"Additional CSS string applied to the tooltip container element.",
|
|
149
131
|
table: {
|
|
150
132
|
type: { summary: "string" },
|
|
151
133
|
defaultValue: { summary: '""' }
|
|
152
134
|
}
|
|
153
135
|
},
|
|
154
|
-
|
|
155
|
-
description:
|
|
136
|
+
contentExtraStyles: {
|
|
137
|
+
description:
|
|
138
|
+
"Additional CSS string applied to the tooltip content element.",
|
|
156
139
|
table: {
|
|
157
140
|
type: { summary: "string" },
|
|
158
141
|
defaultValue: { summary: '""' }
|
|
159
142
|
}
|
|
160
143
|
},
|
|
161
|
-
|
|
162
|
-
description:
|
|
163
|
-
"Button variant applied to the trigger ButtonWithAction element",
|
|
144
|
+
contentBackgroundColor: {
|
|
145
|
+
description: "Background color of the tooltip content box.",
|
|
164
146
|
table: {
|
|
165
147
|
type: { summary: "string" },
|
|
166
|
-
defaultValue: { summary: "
|
|
148
|
+
defaultValue: { summary: "white" }
|
|
167
149
|
}
|
|
168
150
|
}
|
|
169
151
|
}
|
|
@@ -174,15 +156,57 @@ export default meta;
|
|
|
174
156
|
export const Basic = {
|
|
175
157
|
args: {
|
|
176
158
|
tooltipID: "tooltip-basic",
|
|
177
|
-
triggerText: "
|
|
178
|
-
|
|
159
|
+
triggerText: "What is this?",
|
|
160
|
+
content:
|
|
179
161
|
"This is a detailed explanation of a feature or term that the user may need more context about."
|
|
180
162
|
}
|
|
181
163
|
};
|
|
182
164
|
|
|
165
|
+
export const WithChildren = {
|
|
166
|
+
args: {
|
|
167
|
+
tooltipID: "tooltip-children",
|
|
168
|
+
content: "Extra information about this label.",
|
|
169
|
+
contentPosition: {
|
|
170
|
+
top: "-84px",
|
|
171
|
+
right: "auto",
|
|
172
|
+
bottom: "auto",
|
|
173
|
+
left: "-225px"
|
|
174
|
+
}
|
|
175
|
+
},
|
|
176
|
+
render: args => (
|
|
177
|
+
<Tooltip {...args}>
|
|
178
|
+
<button type="button">Custom trigger</button>
|
|
179
|
+
</Tooltip>
|
|
180
|
+
)
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
export const RichTooltipContent = {
|
|
184
|
+
args: {
|
|
185
|
+
tooltipID: "tooltip-node-content",
|
|
186
|
+
contentBackgroundColor: "#ffffff",
|
|
187
|
+
triggerText: "Rich content",
|
|
188
|
+
contentPosition: {
|
|
189
|
+
top: "-126px",
|
|
190
|
+
right: "auto",
|
|
191
|
+
bottom: "auto",
|
|
192
|
+
left: "-225px"
|
|
193
|
+
},
|
|
194
|
+
content: (
|
|
195
|
+
<div style={{ padding: "8px" }}>
|
|
196
|
+
<strong>Bold title</strong>
|
|
197
|
+
<p>
|
|
198
|
+
With <em>an italic text detail</em> below.
|
|
199
|
+
</p>
|
|
200
|
+
</div>
|
|
201
|
+
)
|
|
202
|
+
}
|
|
203
|
+
};
|
|
204
|
+
|
|
183
205
|
export const TooltipBelow = {
|
|
184
206
|
args: {
|
|
185
207
|
tooltipID: "tooltip-below",
|
|
208
|
+
triggerText: "Hover for info",
|
|
209
|
+
content: "This tooltip appears below the trigger.",
|
|
186
210
|
contentPosition: {
|
|
187
211
|
top: "50px",
|
|
188
212
|
right: "auto",
|
|
@@ -202,6 +226,8 @@ export const TooltipBelow = {
|
|
|
202
226
|
export const TooltipRight = {
|
|
203
227
|
args: {
|
|
204
228
|
tooltipID: "tooltip-right",
|
|
229
|
+
triggerText: "Hover for info",
|
|
230
|
+
content: "This tooltip appears to the right.",
|
|
205
231
|
contentPosition: {
|
|
206
232
|
top: "-40px",
|
|
207
233
|
right: "auto",
|
|
@@ -217,21 +243,3 @@ export const TooltipRight = {
|
|
|
217
243
|
}
|
|
218
244
|
}
|
|
219
245
|
};
|
|
220
|
-
|
|
221
|
-
export const CustomContent = {
|
|
222
|
-
args: {
|
|
223
|
-
tooltipID: "tooltip-custom-content",
|
|
224
|
-
triggerText: "What is this?",
|
|
225
|
-
tooltipContent:
|
|
226
|
-
"This is a detailed explanation of a feature or term that the user may need more context about."
|
|
227
|
-
}
|
|
228
|
-
};
|
|
229
|
-
|
|
230
|
-
export const CustomWidth = {
|
|
231
|
-
args: {
|
|
232
|
-
tooltipID: "tooltip-custom-width",
|
|
233
|
-
minWidth: "150px",
|
|
234
|
-
maxWidth: "200px",
|
|
235
|
-
tooltipContent: "A narrower tooltip."
|
|
236
|
-
}
|
|
237
|
-
};
|