@thecb/components 11.10.1-beta.1 → 11.11.0-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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thecb/components",
3
- "version": "11.10.1-beta.1",
3
+ "version": "11.11.0-beta.0",
4
4
  "description": "Common lib for CityBase react components",
5
5
  "main": "dist/index.cjs.js",
6
6
  "typings": "dist/index.d.ts",
@@ -148,7 +148,7 @@ const FormInput = ({
148
148
  <Stack childGap="0.25rem">
149
149
  <Box padding="0">
150
150
  {helperModal ? (
151
- <Cluster justify="space-between" align="center">
151
+ <Cluster justify="space-between" align="center" overflow>
152
152
  {labelDisplayOverride ? (
153
153
  labelDisplayOverride
154
154
  ) : (
@@ -1,11 +1,11 @@
1
1
  import React, { useContext, useEffect, useRef, useState } from "react";
2
- import { createThemeValues } from "../../../util/themeUtils";
2
+ import { createThemeValues, themeComponent } from "../../../util/themeUtils";
3
3
  import { ThemeContext } from "styled-components";
4
4
  import Text from "../../atoms/text";
5
5
  import { Box } from "../../atoms/layouts";
6
6
  import ButtonWithAction from "../../atoms/button-with-action";
7
7
  import { noop, arrowBorder } from "../../../util/general";
8
- import { TOOLTIP_THEME_SOURCE, fallbackValues } from "./Tooltip.theme";
8
+ import { fallbackValues } from "./Tooltip.theme";
9
9
 
10
10
  const Tooltip = ({
11
11
  tooltipID,
@@ -19,19 +19,21 @@ const Tooltip = ({
19
19
  minWidth = "250px",
20
20
  maxWidth = "100%",
21
21
  height = "auto",
22
+ arrowDirection = "down",
22
23
  contentPosition = {
23
- top: "-110px",
24
+ top: "auto",
24
25
  right: "auto",
25
- bottom: "auto",
26
- left: "-225px"
26
+ bottom: "calc(100% + 8px)", // always sits above the trigger + 8px gap for arrow
27
+ left: "50%", // anchors to horizontal center of trigger
28
+ transform: "translateX(-50%)" // shifts left by half tooltip's own width → centered
27
29
  },
28
- arrowDirection = "down",
29
30
  arrowPosition = {
30
31
  arrowTop: "auto",
31
- arrowRight: "10px",
32
+ arrowRight: "auto",
32
33
  arrowBottom: "-8px",
33
- arrowLeft: "auto"
34
- }
34
+ arrowLeft: "calc(50% - 8px)" // centers the 0-width arrow element (16px wide border)
35
+ },
36
+ arrowColor
35
37
  }) => {
36
38
  const closeTimeoutRef = useRef(null);
37
39
  const [tooltipOpen, setTooltipOpen] = useState(false);
@@ -39,7 +41,7 @@ const Tooltip = ({
39
41
  const themeValues = createThemeValues(
40
42
  themeContext,
41
43
  fallbackValues,
42
- TOOLTIP_THEME_SOURCE
44
+ "Tooltip"
43
45
  );
44
46
 
45
47
  const { top, right, bottom, left } = contentPosition;
@@ -81,12 +83,21 @@ const Tooltip = ({
81
83
 
82
84
  const renderTrigger = () => {
83
85
  if (hasCustomTrigger && 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
- });
86
+ return (
87
+ <Box
88
+ padding="0"
89
+ extraStyles="cursor: pointer;"
90
+ tabIndex="0"
91
+ role="button"
92
+ data-qa={`tooltip-trigger-${tooltipID}`}
93
+ aria-describedby={tooltipID}
94
+ onFocus={() => handleToggleTooltip(true)}
95
+ onBlur={() => handleToggleTooltip(false)}
96
+ onKeyDown={handleKeyDown}
97
+ >
98
+ {children}
99
+ </Box>
100
+ );
90
101
  }
91
102
 
92
103
  return (
@@ -102,9 +113,10 @@ const Tooltip = ({
102
113
  text={triggerText}
103
114
  extraStyles={`
104
115
  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; }
116
+ cursor: pointer;
117
+ &:hover { color: ${themeValues.hoverColor}; text-decoration: none; }
118
+ &:active, &:focus { color: ${themeValues.activeColor}; text-decoration: none; }
119
+ button, span, &:hover span { text-decoration: none; }
108
120
  `}
109
121
  />
110
122
  );
@@ -153,7 +165,11 @@ const Tooltip = ({
153
165
  content: "";
154
166
  width: 0;
155
167
  height: 0;
156
- ${arrowBorder(themeValues.borderColor, arrowDirection, "8px")};
168
+ ${arrowBorder(
169
+ arrowColor || themeValues.borderColor,
170
+ arrowDirection,
171
+ "8px"
172
+ )};
157
173
  filter: drop-shadow(2px 8px 14px black);
158
174
  bottom: ${arrowBottom};
159
175
  right: ${arrowRight};
@@ -166,4 +182,4 @@ const Tooltip = ({
166
182
  );
167
183
  };
168
184
 
169
- export default Tooltip;
185
+ export default themeComponent(Tooltip, "Tooltip", fallbackValues);
@@ -196,8 +196,9 @@ export const WithChildren = {
196
196
  export const RichTooltipContent = {
197
197
  args: {
198
198
  tooltipID: "tooltip-node-content",
199
- contentBackgroundColor: "#ffffff",
199
+ contentExtraStyles: "background-color: #000000; color: #ffffff;",
200
200
  triggerText: "Rich content",
201
+ arrowColor: "black",
201
202
  contentPosition: {
202
203
  top: "-126px",
203
204
  right: "auto",
@@ -9,8 +9,6 @@ const activeColor = PEACOCK_BLUE;
9
9
  const linkColor = MATISSE_BLUE;
10
10
  const borderColor = "rgba(255, 255, 255, 0.85)";
11
11
 
12
- export const TOOLTIP_THEME_SOURCE = "Button";
13
-
14
12
  export const fallbackValues = {
15
13
  borderColor,
16
14
  linkColor,