@thecb/components 11.8.0-beta.5 → 11.8.0-beta.6

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.8.0-beta.5",
3
+ "version": "11.8.0-beta.6",
4
4
  "description": "Common lib for CityBase react components",
5
5
  "main": "dist/index.cjs.js",
6
6
  "typings": "dist/index.d.ts",
@@ -5,24 +5,26 @@ import Paragraph from "../../atoms/paragraph";
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 { ESCAPE } from "../../../constants/keyboard";
9
8
  import { fallbackValues } from "./Tooltip.theme";
10
9
  import WarningIconXS from "../../atoms/icons/WarningIconXS";
11
- import { SELECTIVE_YELLOW } from "../../../constants/colors";
12
10
 
13
11
  const Tooltip = ({
12
+ tooltipContainerExtraStyles = "",
14
13
  themeValues,
15
- triggerText = "",
16
- content = "",
14
+ tooltipID = "tooltip-content",
17
15
  hasIconTrigger = false,
18
16
  IconTrigger = WarningIconXS,
19
- iconHelpText = "",
20
- tooltipID = "tooltip-content",
21
- extraStyles = "",
22
- textExtraStyles = "",
23
- minWidth = "250px",
24
- maxWidth = "300px",
25
- height = "auto",
17
+ iconHelpText = "Open the tooltip",
18
+ tooltipContent = "",
19
+ tooltipTriggerText = "",
20
+ triggerTextExtraStyles = "",
21
+ contentExtraStyles = "",
22
+ contentPosition = {
23
+ top: "-110px",
24
+ right: "auto",
25
+ bottom: "auto",
26
+ left: "-225px"
27
+ },
26
28
  arrowDirection = "down",
27
29
  arrowPosition = {
28
30
  arrowTop: "auto",
@@ -30,20 +32,15 @@ const Tooltip = ({
30
32
  arrowBottom: "-8px",
31
33
  arrowLeft: "auto"
32
34
  },
33
- position = {
34
- top: "-110px",
35
- right: "auto",
36
- bottom: "auto",
37
- left: "-225px"
38
- },
39
- iconColor = SELECTIVE_YELLOW,
35
+ minWidth = "250px",
36
+ maxWidth = "300px",
37
+ height = "auto",
40
38
  buttonExtraStyles,
41
39
  backgroundColor = "white",
42
- borderColor = "rgba(255, 255, 255, 0.85)",
43
- tooltipContentExtraStyles
40
+ borderColor = "rgba(255, 255, 255, 0.85)"
44
41
  }) => {
45
42
  const { hoverColor, activeColor, tooltipTriggerColor } = themeValues;
46
- const { top, right, bottom, left } = position ?? {};
43
+ const { top, right, bottom, left } = contentPosition ?? {};
47
44
  const { arrowTop, arrowRight, arrowBottom, arrowLeft } = arrowPosition ?? {};
48
45
 
49
46
  const [tooltipOpen, setTooltipOpen] = useState(false);
@@ -55,13 +52,16 @@ const Tooltip = ({
55
52
  };
56
53
 
57
54
  const handleKeyboardEvent = e => {
58
- if (e.key === ESCAPE) {
55
+ if (e.key === "Escape") {
59
56
  handleToggleTooltip(false);
60
57
  }
61
58
  };
62
59
 
63
60
  return (
64
- <Box padding="0" extraStyles={`position: relative; ${extraStyles}`}>
61
+ <Box
62
+ padding="0"
63
+ extraStyles={`position: relative; ${tooltipContainerExtraStyles}`}
64
+ >
65
65
  <ButtonWithAction
66
66
  action={() => noop}
67
67
  onFocus={() => handleToggleTooltip(true)}
@@ -80,7 +80,7 @@ const Tooltip = ({
80
80
  {hasIconTrigger && (
81
81
  <>
82
82
  <Box aria-label="Open tooltip">
83
- <IconTrigger color={iconColor} />
83
+ <IconTrigger color={tooltipTriggerColor} />
84
84
  </Box>
85
85
  <Box padding="0" srOnly>
86
86
  <Text>{iconHelpText}</Text>
@@ -90,9 +90,9 @@ const Tooltip = ({
90
90
  {!hasIconTrigger && (
91
91
  <Text
92
92
  extraStyles={`color: ${tooltipTriggerColor}; &:hover {
93
- ${hoverColor}; &:active ${activeColor}; ${textExtraStyles}`}
93
+ ${hoverColor}; &:active ${activeColor}; ${triggerTextExtraStyles}`}
94
94
  >
95
- {triggerText}
95
+ {tooltipTriggerText}
96
96
  </Text>
97
97
  )}
98
98
  </ButtonWithAction>
@@ -113,10 +113,10 @@ const Tooltip = ({
113
113
  bottom: ${bottom};
114
114
  left: ${left};
115
115
  height: ${height};
116
- ${tooltipContentExtraStyles};
116
+ ${contentExtraStyles};
117
117
  `}
118
118
  >
119
- <Paragraph>{content}</Paragraph>
119
+ <Paragraph>{tooltipContent}</Paragraph>
120
120
  <Box
121
121
  padding="0"
122
122
  extraStyles={`
@@ -9,28 +9,27 @@ export default {
9
9
  controls: { expanded: true }
10
10
  },
11
11
  args: {
12
- triggerText: "",
13
- content: "",
12
+ tooltipTriggerText: "",
13
+ tooltipContent: "",
14
14
  hasIconTrigger: false,
15
15
  IconTrigger: WarningIconXS,
16
- iconHelpText: "",
17
- iconColor: undefined,
16
+ iconHelpText: "Open the tooltip",
18
17
  tooltipID: "tooltip-content",
19
- extraStyles: undefined,
20
- textExtraStyles: undefined,
18
+ tooltipContainerExtraStyles: undefined,
19
+ triggerTextExtraStyles: undefined,
21
20
  minWidth: "250px",
22
21
  maxWidth: "300px",
23
22
  height: "auto",
24
- position: undefined,
23
+ contentPosition: undefined,
25
24
  arrowPosition: undefined,
26
25
  arrowDirection: "down",
27
26
  buttonExtraStyles: undefined,
28
27
  backgroundColor: "white",
29
28
  borderColor: "rgba(255, 255, 255, 0.85)",
30
- tooltipContentExtraStyles: undefined
29
+ contentExtraStyles: undefined
31
30
  },
32
31
  argTypes: {
33
- triggerText: {
32
+ tooltipTriggerText: {
34
33
  description:
35
34
  "Text element that tooltip is anchored to. Only used if hasIconTrigger is false.",
36
35
  table: {
@@ -38,7 +37,7 @@ export default {
38
37
  defaultValue: { summary: "" }
39
38
  }
40
39
  },
41
- content: {
40
+ tooltipContent: {
42
41
  description: "Content of the tooltip",
43
42
  table: {
44
43
  type: { summary: "string" },
@@ -65,14 +64,7 @@ export default {
65
64
  description: "Accessible description of the icon",
66
65
  table: {
67
66
  type: { summary: "string" },
68
- defaultValue: { summary: undefined }
69
- }
70
- },
71
- iconColor: {
72
- description: "Color of the icon trigger",
73
- table: {
74
- type: { summary: "string" },
75
- defaultValue: { summary: undefined }
67
+ defaultValue: { summary: "Open the tooltip" }
76
68
  }
77
69
  },
78
70
  tooltipID: {
@@ -83,7 +75,7 @@ export default {
83
75
  defaultValue: { summary: "tooltip-content" }
84
76
  }
85
77
  },
86
- extraStyles: {
78
+ tooltipContainerExtraStyles: {
87
79
  description:
88
80
  "Extra CSS styles to apply to the wrapper component around the trigger and tooltip",
89
81
  table: {
@@ -91,7 +83,7 @@ export default {
91
83
  defaultValue: { summary: undefined }
92
84
  }
93
85
  },
94
- textExtraStyles: {
86
+ triggerTextExtraStyles: {
95
87
  description: "Extra styles to apply to the text trigger of the tooltip",
96
88
  table: {
97
89
  type: { summary: "CSS string" },
@@ -119,7 +111,7 @@ export default {
119
111
  defaultValue: { summary: "auto" }
120
112
  }
121
113
  },
122
- position: {
114
+ contentPosition: {
123
115
  description:
124
116
  "Object containing values for top/right/bottom/left position of tooltip relative to trigger",
125
117
  table: {
@@ -164,7 +156,7 @@ export default {
164
156
  defaultValue: { summary: "rgba(255, 255, 255, 0.85)" }
165
157
  }
166
158
  },
167
- tooltipContentExtraStyles: {
159
+ contentExtraStyles: {
168
160
  description: "Extra styles to apply to the tooltip content box",
169
161
  table: {
170
162
  type: { summary: "string" },
@@ -176,8 +168,8 @@ export default {
176
168
 
177
169
  export const BasicTooltip = {
178
170
  args: {
179
- triggerText: "Help",
180
- content:
171
+ tooltipTriggerText: "Help",
172
+ tooltipContent:
181
173
  "Contact support at 1-800-CTY-VILL for help with your account balance."
182
174
  }
183
175
  };
@@ -186,17 +178,17 @@ export const IconTooltip = {
186
178
  args: {
187
179
  hasIconTrigger: true,
188
180
  IconTrigger: WarningIconXS,
189
- content:
181
+ tooltipContent:
190
182
  "Contact support at 1-800-CTY-VILL for help with your account balance."
191
183
  }
192
184
  };
193
185
 
194
186
  export const UnderneathTooltip = {
195
187
  args: {
196
- triggerText: "What's this?",
197
- content:
188
+ tooltipTriggerText: "What's this?",
189
+ tooltipContent:
198
190
  "Contact support at 1-800-CTY-VILL for help with your account balance.",
199
- position: { top: "50px", left: "-100px" },
191
+ contentPosition: { top: "50px", left: "-100px" },
200
192
  arrowPosition: { arrowTop: "-8px", arrowLeft: "50%" },
201
193
  arrowDirection: "up"
202
194
  }