Skip to content

Commit 23a11c1

Browse files
feat: make highContrast and dropShadow props configurable (#18636)
* feat(Tooltip): make `highContrast` and `dropShadow` props configurable * feat(IconButton): make `highContrast` and `dropShadow` configurable * chore: update snapshots --------- Co-authored-by: Riddhi Bansal <41935566+riddhybansal@users.noreply.github.com>
1 parent 62b5c1e commit 23a11c1

File tree

3 files changed

+60
-3
lines changed

3 files changed

+60
-3
lines changed

packages/react/__tests__/__snapshots__/PublicAPI-test.js.snap

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4231,9 +4231,15 @@ Map {
42314231
"disabled": Object {
42324232
"type": "bool",
42334233
},
4234+
"dropShadow": Object {
4235+
"type": "bool",
4236+
},
42344237
"enterDelayMs": Object {
42354238
"type": "number",
42364239
},
4240+
"highContrast": Object {
4241+
"type": "bool",
4242+
},
42374243
"href": Object {
42384244
"type": "string",
42394245
},
@@ -9587,9 +9593,15 @@ Map {
95879593
"description": Object {
95889594
"type": "node",
95899595
},
9596+
"dropShadow": Object {
9597+
"type": "bool",
9598+
},
95909599
"enterDelayMs": Object {
95919600
"type": "number",
95929601
},
9602+
"highContrast": Object {
9603+
"type": "bool",
9604+
},
95939605
"label": Object {
95949606
"type": "node",
95959607
},

packages/react/src/components/IconButton/index.tsx

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,21 @@ export interface IconButtonProps
107107
*/
108108
disabled?: boolean;
109109

110+
/**
111+
* Specify whether a drop shadow should be rendered on the tooltip
112+
*/
113+
dropShadow?: boolean;
114+
110115
/**
111116
* Specify the duration in milliseconds to delay before displaying the tooltip
112117
*/
113118
enterDelayMs?: number;
114119

120+
/**
121+
* Render the tooltip using the high-contrast theme
122+
*/
123+
highContrast?: boolean;
124+
115125
/**
116126
* Specify whether the IconButton is currently selected
117127
*/
@@ -156,7 +166,9 @@ const IconButton = React.forwardRef(function IconButton(
156166
closeOnActivation = true,
157167
defaultOpen = false,
158168
disabled,
169+
dropShadow = false,
159170
enterDelayMs = 100,
171+
highContrast = true,
160172
kind,
161173
label,
162174
leaveDelayMs = 100,
@@ -180,7 +192,9 @@ const IconButton = React.forwardRef(function IconButton(
180192
closeOnActivation={closeOnActivation}
181193
className={tooltipClasses}
182194
defaultOpen={defaultOpen}
195+
dropShadow={dropShadow}
183196
enterDelayMs={enterDelayMs}
197+
highContrast={highContrast}
184198
label={label}
185199
leaveDelayMs={leaveDelayMs}>
186200
<ButtonBase
@@ -283,6 +297,11 @@ IconButton.propTypes = {
283297
*/
284298
defaultOpen: PropTypes.bool,
285299

300+
/**
301+
* Specify whether a drop shadow should be rendered on the tooltip
302+
*/
303+
dropShadow: PropTypes.bool,
304+
286305
/**
287306
* Specify whether the Button should be disabled, or not
288307
*/
@@ -296,9 +315,13 @@ IconButton.propTypes = {
296315
/**
297316
* Specify whether the IconButton is currently selected
298317
*/
299-
300318
isSelected: PropTypes.bool,
301319

320+
/**
321+
* Render the tooltip using the high-contrast theme
322+
*/
323+
highContrast: PropTypes.bool,
324+
302325
/**
303326
* Specify the type of button to be used as the base for the IconButton
304327
*/

packages/react/src/components/Tooltip/Tooltip.tsx

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,21 @@ interface TooltipBaseProps {
6060
*/
6161
description?: React.ReactNode;
6262

63+
/**
64+
* Specify whether a drop shadow should be rendered
65+
*/
66+
dropShadow?: boolean;
67+
6368
/**
6469
* Specify the duration in milliseconds to delay before displaying the tooltip
6570
*/
6671
enterDelayMs?: number;
6772

73+
/**
74+
* Render the component using the high-contrast theme
75+
*/
76+
highContrast?: boolean;
77+
6878
/**
6979
* Provide the label to be rendered inside of the Tooltip. The label will use
7080
* `aria-labelledby` and will fully describe the child node that is provided.
@@ -97,6 +107,8 @@ function Tooltip<T extends React.ElementType>({
97107
leaveDelayMs = 300,
98108
defaultOpen = false,
99109
closeOnActivation = false,
110+
dropShadow = false,
111+
highContrast = true,
100112
...rest
101113
}: TooltipProps<T>) {
102114
const tooltipRef = useRef<HTMLSpanElement>(null);
@@ -248,8 +260,8 @@ function Tooltip<T extends React.ElementType>({
248260
{...rest}
249261
align={align}
250262
className={cx(`${prefix}--tooltip`, customClassName)}
251-
dropShadow={false}
252-
highContrast
263+
dropShadow={dropShadow}
264+
highContrast={highContrast}
253265
onKeyDown={onKeyDown}
254266
onMouseLeave={onMouseLeave}
255267
open={open}>
@@ -337,11 +349,21 @@ Tooltip.propTypes = {
337349
*/
338350
description: PropTypes.node,
339351

352+
/**
353+
* Specify whether a drop shadow should be rendered
354+
*/
355+
dropShadow: PropTypes.bool,
356+
340357
/**
341358
* Specify the duration in milliseconds to delay before displaying the tooltip
342359
*/
343360
enterDelayMs: PropTypes.number,
344361

362+
/**
363+
* Render the component using the high-contrast theme
364+
*/
365+
highContrast: PropTypes.bool,
366+
345367
/**
346368
* Provide the label to be rendered inside of the Tooltip. The label will use
347369
* `aria-labelledby` and will fully describe the child node that is provided.

0 commit comments

Comments
 (0)