@thecb/components 11.11.0-beta.0 → 11.11.0-beta.2

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.11.0-beta.0",
3
+ "version": "11.11.0-beta.2",
4
4
  "description": "Common lib for CityBase react components",
5
5
  "main": "dist/index.cjs.js",
6
6
  "typings": "dist/index.d.ts",
@@ -1,11 +1,11 @@
1
1
  import React, { useContext, useEffect, useRef, useState } from "react";
2
- import { createThemeValues, themeComponent } from "../../../util/themeUtils";
2
+ import { createThemeValues } 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 { fallbackValues } from "./Tooltip.theme";
8
+ import { TOOLTIP_THEME_SOURCE, fallbackValues } from "./Tooltip.theme";
9
9
 
10
10
  const Tooltip = ({
11
11
  tooltipID,
@@ -19,19 +19,18 @@ const Tooltip = ({
19
19
  minWidth = "250px",
20
20
  maxWidth = "100%",
21
21
  height = "auto",
22
- arrowDirection = "down",
23
22
  contentPosition = {
24
- top: "auto",
23
+ top: "-110px",
25
24
  right: "auto",
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
25
+ bottom: "auto",
26
+ left: "-225px"
29
27
  },
28
+ arrowDirection = "down",
30
29
  arrowPosition = {
31
30
  arrowTop: "auto",
32
- arrowRight: "auto",
31
+ arrowRight: "10px",
33
32
  arrowBottom: "-8px",
34
- arrowLeft: "calc(50% - 8px)" // centers the 0-width arrow element (16px wide border)
33
+ arrowLeft: "auto"
35
34
  },
36
35
  arrowColor
37
36
  }) => {
@@ -41,7 +40,7 @@ const Tooltip = ({
41
40
  const themeValues = createThemeValues(
42
41
  themeContext,
43
42
  fallbackValues,
44
- "Tooltip"
43
+ TOOLTIP_THEME_SOURCE
45
44
  );
46
45
 
47
46
  const { top, right, bottom, left } = contentPosition;
@@ -83,21 +82,12 @@ const Tooltip = ({
83
82
 
84
83
  const renderTrigger = () => {
85
84
  if (hasCustomTrigger && children) {
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
- );
85
+ return React.cloneElement(React.Children.only(children), {
86
+ "aria-describedby": tooltipID,
87
+ onFocus: () => handleToggleTooltip(true),
88
+ onBlur: () => handleToggleTooltip(false),
89
+ onKeyDown: handleKeyDown
90
+ });
101
91
  }
102
92
 
103
93
  return (
@@ -113,10 +103,9 @@ const Tooltip = ({
113
103
  text={triggerText}
114
104
  extraStyles={`
115
105
  color: ${themeValues.linkColor};
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; }
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; }
120
109
  `}
121
110
  />
122
111
  );
@@ -182,4 +171,4 @@ const Tooltip = ({
182
171
  );
183
172
  };
184
173
 
185
- export default themeComponent(Tooltip, "Tooltip", fallbackValues);
174
+ export default Tooltip;
@@ -9,6 +9,8 @@ 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
+
12
14
  export const fallbackValues = {
13
15
  borderColor,
14
16
  linkColor,