-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SlideTabs improvements #49545
SlideTabs improvements #49545
Conversation
Adds a model-level validation capability to our validation library.
They will be later required in the SlideTabs component
Add support for tooltips and status icons
// property being undefined and not present at all: undefined props would | ||
// override the default ones, but we want it them to interfere at all. | ||
const optionalProps: { color?: string; 'aria-label'?: string } = {}; | ||
if (color != undefined) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (color != undefined) { | |
if (color !== undefined) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it really necessary to be so strict about it? I mean, if somehow color
(and ariaLabel
below) become null
, we're gonna have a bug.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, well, I guess the type system would protect us here in this case. Changing.
if (color != undefined) { | ||
optionalProps.color = color; | ||
} | ||
if (ariaLabel != undefined) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (ariaLabel != undefined) { | |
if (ariaLabel !== undefined) { |
// This is one of these rare cases when there is a difference between | ||
// property being undefined and not present at all: undefined props would | ||
// override the default ones, but we want it them to interfere at all. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for pointing this out.
optionalProps['aria-label'] = ariaLabel; | ||
} | ||
|
||
if (statusKind) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Use an early return instead?
if (!statusKind) {
return null;
}
// This is one of these rare cases when there is a difference between
// property being undefined and not present at all: undefined props would
// override the default ones, but we want it them to interfere at all.
const optionalProps: { color?: string; 'aria-label'?: string } = {};
if (color != undefined) {
optionalProps.color = color;
}
if (ariaLabel != undefined) {
optionalProps['aria-label'] = ariaLabel;
}
return (
<StatusIcon
kind={statusKind}
size={size}
style={{ transition: 'color 0.2s ease-in 0s' }}
{...optionalProps}
/>
);
* Validation Adds a model-level validation capability to our validation library. * Move tooltips to the design package They will be later required in the SlideTabs component * SlideTabs improvements Add support for tooltips and status icons * Review * Also, rename the tooltip directory * Fix an import * Review: status-related props, extract StatusIcon * Also, rename the tooltip component * review * review * Never return undefined from useValidation()
* Validation Adds a model-level validation capability to our validation library. * Move tooltips to the design package They will be later required in the SlideTabs component * SlideTabs improvements Add support for tooltips and status icons * Review * Also, rename the tooltip directory * Fix an import * Review: status-related props, extract StatusIcon * Also, rename the tooltip component * review * review * Never return undefined from useValidation()
Add support for tooltips and status icons
Demo. Note that it demonstrates these features as they are used in a follow-up PR, based on this one.
Requires #49544 (not on its own, but because it's a part of a larger PR train)
Followed up by #49546
Contributes to #46612