Skip to content

Commit d6bb259

Browse files
authored
feat: enable configuration of highcontrast and dropshadow props (#18732)
* feat: enable configuration of highcontrast and dropshadow props * chore: remove test story
1 parent 6f865ed commit d6bb259

File tree

3 files changed

+70
-0
lines changed

3 files changed

+70
-0
lines changed

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -495,6 +495,12 @@ Map {
495495
],
496496
"type": "oneOf",
497497
},
498+
"tooltipDropShadow": Object {
499+
"type": "bool",
500+
},
501+
"tooltipHighContrast": Object {
502+
"type": "bool",
503+
},
498504
"tooltipPosition": Object {
499505
"args": Array [
500506
Array [
@@ -4073,6 +4079,12 @@ Map {
40734079
],
40744080
"type": "oneOf",
40754081
},
4082+
"tooltipDropShadow": Object {
4083+
"type": "bool",
4084+
},
4085+
"tooltipHighContrast": Object {
4086+
"type": "bool",
4087+
},
40764088
},
40774089
"render": [Function],
40784090
},

packages/react/src/components/Button/Button.tsx

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,17 @@ export interface ButtonBaseProps
109109
*/
110110
tooltipAlignment?: ButtonTooltipAlignment;
111111

112+
/**
113+
* Enable drop shadow for tooltips for icon-only buttons.
114+
*/
115+
tooltipDropShadow?: boolean;
116+
117+
/**
118+
* Enable high-contrast theme for tooltips on icon-only buttons.
119+
* Defaults to true.
120+
*/
121+
tooltipHighContrast?: boolean;
122+
112123
/**
113124
* Specify the direction of the tooltip for icon-only buttons.
114125
* Can be either top, right, bottom, or left.
@@ -146,6 +157,8 @@ const Button: ButtonComponent = React.forwardRef(
146157
autoAlign = false,
147158
children,
148159
hasIconOnly = false,
160+
tooltipHighContrast = true,
161+
tooltipDropShadow = false,
149162
iconDescription,
150163
kind = 'primary',
151164
onBlur,
@@ -201,6 +214,8 @@ const Button: ButtonComponent = React.forwardRef(
201214
label={iconDescription}
202215
kind={kind}
203216
size={size}
217+
highContrast={tooltipHighContrast}
218+
dropShadow={tooltipDropShadow}
204219
onMouseEnter={onMouseEnter}
205220
onMouseLeave={onMouseLeave}
206221
onFocus={onFocus}
@@ -375,6 +390,17 @@ const Button: ButtonComponent = React.forwardRef(
375390
*/
376391
tooltipAlignment: PropTypes.oneOf(['start', 'center', 'end']),
377392

393+
/**
394+
* Enable drop shadow for tooltips for icon-only buttons.
395+
*/
396+
tooltipDropShadow: PropTypes.bool,
397+
398+
/**
399+
* Enable high-contrast theme for tooltips for icon-only buttons.
400+
* Defaults to true.
401+
*/
402+
tooltipHighContrast: PropTypes.bool,
403+
378404
/**
379405
* Specify the direction of the tooltip for icon-only buttons.
380406
* Can be either top, right, bottom, or left.

packages/react/src/components/UIShell/HeaderGlobalAction.tsx

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,33 +17,50 @@ export interface HeaderGlobalActionProps {
1717
* Required props for the accessibility label of the button
1818
*/
1919
'aria-label'?: string;
20+
2021
/**
2122
* Required props for the accessibility label of the button
2223
*/
2324
'aria-labelledby'?: string;
25+
2426
/**
2527
* Provide a custom icon for this global action
2628
*/
2729
children: ReactNode;
30+
2831
/**
2932
* Optionally provide a custom class name that is applied to the underlying
3033
* button
3134
*/
3235
className?: string;
36+
3337
/**
3438
* Specify whether the action is currently active
3539
*/
3640
isActive?: boolean;
41+
3742
/**
3843
* Optionally provide an onClick handler that is called when the underlying
3944
* button fires it's onclick event
4045
*/
4146
onClick?: () => void;
47+
4248
/**
4349
* Specify the alignment of the tooltip to the icon-only button.
4450
* Can be one of: start, center, or end.
4551
*/
4652
tooltipAlignment?: 'start' | 'center' | 'end';
53+
54+
/**
55+
* Enable drop shadow for tooltips for icon-only buttons.
56+
*/
57+
tooltipDropShadow?: boolean;
58+
59+
/**
60+
* Render the tooltip using the high-contrast theme
61+
* Default is true
62+
*/
63+
tooltipHighContrast?: boolean;
4764
}
4865

4966
/**
@@ -62,6 +79,8 @@ const HeaderGlobalAction: React.FC<HeaderGlobalActionProps> = React.forwardRef(
6279
children,
6380
className: customClassName,
6481
onClick,
82+
tooltipHighContrast = true,
83+
tooltipDropShadow,
6584
isActive,
6685
tooltipAlignment,
6786
...rest
@@ -89,6 +108,8 @@ const HeaderGlobalAction: React.FC<HeaderGlobalActionProps> = React.forwardRef(
89108
iconDescription={ariaLabel}
90109
tooltipPosition="bottom"
91110
tooltipAlignment={tooltipAlignment}
111+
tooltipDropShadow={tooltipDropShadow}
112+
tooltipHighContrast={tooltipHighContrast}
92113
ref={ref}>
93114
{children}
94115
</Button>
@@ -129,6 +150,17 @@ HeaderGlobalAction.propTypes = {
129150
* Can be one of: start, center, or end.
130151
*/
131152
tooltipAlignment: PropTypes.oneOf(['start', 'center', 'end']),
153+
154+
/**
155+
* Enable drop shadow for tooltips for icon-only buttons.
156+
*/
157+
tooltipDropShadow: PropTypes.bool,
158+
159+
/**
160+
* Render the tooltip using the high-contrast theme
161+
* Default is true
162+
*/
163+
tooltipHighContrast: PropTypes.bool,
132164
};
133165

134166
HeaderGlobalAction.displayName = 'HeaderGlobalAction';

0 commit comments

Comments
 (0)