@thecb/components 11.10.1-beta.2 → 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.2",
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,18 +19,19 @@ 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
+ arrowLeft: "calc(50% - 8px)" // centers the 0-width arrow element (16px wide border)
34
35
  },
35
36
  arrowColor
36
37
  }) => {
@@ -40,7 +41,7 @@ const Tooltip = ({
40
41
  const themeValues = createThemeValues(
41
42
  themeContext,
42
43
  fallbackValues,
43
- TOOLTIP_THEME_SOURCE
44
+ "Tooltip"
44
45
  );
45
46
 
46
47
  const { top, right, bottom, left } = contentPosition;
@@ -82,12 +83,21 @@ const Tooltip = ({
82
83
 
83
84
  const renderTrigger = () => {
84
85
  if (hasCustomTrigger && children) {
85
- return React.cloneElement(React.Children.only(children), {
86
- "aria-describedby": tooltipID,
87
- onFocus: () => handleToggleTooltip(true),
88
- onBlur: () => handleToggleTooltip(false),
89
- onKeyDown: handleKeyDown
90
- });
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
+ );
91
101
  }
92
102
 
93
103
  return (
@@ -103,9 +113,10 @@ const Tooltip = ({
103
113
  text={triggerText}
104
114
  extraStyles={`
105
115
  color: ${themeValues.linkColor};
106
- &:hover { color: ${themeValues.hoverColor}; text-decoration: none;}
107
- &:active, &:focus { color: ${themeValues.activeColor};text-decoration: none;}
108
- 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; }
109
120
  `}
110
121
  />
111
122
  );
@@ -171,4 +182,4 @@ const Tooltip = ({
171
182
  );
172
183
  };
173
184
 
174
- export default Tooltip;
185
+ export default themeComponent(Tooltip, "Tooltip", fallbackValues);
@@ -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,