-
Notifications
You must be signed in to change notification settings - Fork 840
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
[Emotion] Convert EuiCallOut #5870
Conversation
// Kibana's Ace Editor uses this function, can't remove yet | ||
// https://github.com/elastic/kibana/blob/main/src/core/public/styles/_ace_overrides.scss | ||
// As well as deprecation notices | ||
// https://github.com/elastic/kibana/blob/main/x-pack/plugins/upgrade_assistant/public/application/components/es_deprecations/deprecation_types/reindex/flyout/_step_progress.scss | ||
@function euiCallOutColor($type: 'primary', $returnBackgroundOrForeground: 'background') { |
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.
I don't know if we want to leave comments specifically pointing to Kibana files, but figured since I found them anyway?
return { | ||
euiCallOutHeader: css` | ||
font-weight: ${euiTheme.font.weight.medium}; | ||
margin-bottom: 0 !important; // In case it's nested inside EuiText |
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.
Specificity shot me on this one
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.
Sometimes an !important
tag is what's needed.
headerStyles.euiCallOutHeader, | ||
headerStyles[color], | ||
]; | ||
|
||
const classes = classNames( | ||
'euiCallOut', | ||
colorToClassNameMap[color], |
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.
Unfortunately I couldn't get rid of the color class name because a lot of tests were specifically pointing to these
src/components/call_out/call_out.tsx
Outdated
{children} | ||
</EuiText> | ||
); | ||
} | ||
|
||
const H: any = heading ? `${heading}` : 'span'; | ||
const H: any = heading ? `${heading}` : 'p'; |
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.
I changed the default heading here to p
because it felt odd to not have text in something text-like especially if it's then followed by more text.
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.
Instead of doing this, you can just pick heading = 'p',
as the default prop. The same way we're doing with color = 'primary'
:
eui/src/components/call_out/call_out.tsx
Lines 46 to 57 in f209dd4
export const EuiCallOut = forwardRef<HTMLDivElement, EuiCallOutProps>( | |
( | |
{ | |
title, | |
color = 'primary', | |
size = 'm', | |
iconType, | |
children, | |
className, | |
heading, | |
...rest | |
}, |
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.
Done in 8cde1f1
<H className="euiCallOutHeader__title">{title}</H> | ||
</div> | ||
<EuiTitle size={size === 's' ? 'xxs' : 'xs'} css={cssHeaderStyles}> | ||
<H className="euiCallOutHeader__title"> |
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.
This className too is targeted a lot in tests
src/components/call_out/call_out.tsx
Outdated
// @ts-expect-error Help with forward ref | ||
ref={ref} |
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.
🙏
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.
Nightmaref! 😆
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.
😦 @thompsongl Maybe you can help?
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.
Fixed in 6a85444
EuiPanel
takes panelRef
instead of ref
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 boy... TY!!!
Preview documentation changes for this PR: https://eui.elastic.co/pr_5870/ |
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, @cchaos. The icon inline with the heading text looks much better! 😍
Tested in Chrome, Safari, Edge, and Firefox. LGTM! 🎉
src/components/call_out/call_out.tsx
Outdated
{children} | ||
</EuiText> | ||
); | ||
} | ||
|
||
const H: any = heading ? `${heading}` : 'span'; | ||
const H: any = heading ? `${heading}` : 'p'; |
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.
Instead of doing this, you can just pick heading = 'p',
as the default prop. The same way we're doing with color = 'primary'
:
eui/src/components/call_out/call_out.tsx
Lines 46 to 57 in f209dd4
export const EuiCallOut = forwardRef<HTMLDivElement, EuiCallOutProps>( | |
( | |
{ | |
title, | |
color = 'primary', | |
size = 'm', | |
iconType, | |
children, | |
className, | |
heading, | |
...rest | |
}, |
src/components/call_out/call_out.tsx
Outdated
// @ts-expect-error Help with forward ref | ||
ref={ref} |
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.
Nightmaref! 😆
Preview documentation changes for this PR: https://eui.elastic.co/pr_5870/ |
Flakey? Jenkins, test this |
Preview documentation changes for this PR: https://eui.elastic.co/pr_5870/ |
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.
LGTM! One suggested change with a case for why, but I'm okay leaving as is.
return { | ||
euiCallOutHeader: css` | ||
font-weight: ${euiTheme.font.weight.medium}; | ||
margin-bottom: 0 !important; // In case it's nested inside EuiText |
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.
Sometimes an !important
tag is what's needed.
@@ -52,15 +52,26 @@ export const EuiCallOut = forwardRef<HTMLDivElement, EuiCallOutProps>( | |||
iconType, | |||
children, | |||
className, | |||
heading, | |||
heading = 'p', |
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.
What do you think about defaulting this heading to h2
? If it won't cause a style break, I'd like to consider it for accessibility. Screen reader users often navigate pages asynchronously using headings and it'd be a nice addition. If p
is the best default, I'm good leaving as is.
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.
The problem is context. We have no idea where this will be placed (what if it came after an h3
?). They're all over the place and my guess that could be a big breaking change in a11y tests.
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.
But I agree p
is not as good here and a heading. Can you make an issue to address this specifically. I don't want to make that call in a conversion PR.
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.
Strong point about context. You're right, we don't know where it'll be used and we do not want to accidentally start nesting H2s inside H3, H4, etc. That'd be worse than no heading. I'll add a ticket to address this. Maybe as simple as an ahem, callout in our docs page that the consuming app should look at heading structure and use that as a guide for the prop value.
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.
++ That and/or we can eventually make that property required by the consumer. That way they always have to make the consideration.
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.
Filed #5884 for future work.
Preview documentation changes for this PR: https://eui.elastic.co/pr_5870/ |
Summary
Converts EuiCallOut to remove custom styles but instead directly use EuiPanel as the parent component, and EuiTitle for the heading. I'll make in-code comments about the rest of the changes.
Also fixes callout portion of #5111 by moving the icon inline with the heading text and just letting the text wrap:
Also increased the default contrast ratio to
4.85
This is a very slight change mainly to fix our primary text which was not getting calculated high enough to be able to display on top of the primary panel background:
So instead of trying to do specific calculations for callout, I opted for just increasing the minimum contrast for all text calculations since we'll likely see more and more uses of theses shaded backgrounds. The visible changes are very minimal and have most effect on the primary color:
The good news is that now we can be pretty certain that if anyone uses these background colors and the text colors together, they'll pretty much all work.
Checklist
[ ] Props have proper autodocs and playground toggles[ ] Checked Code Sandbox works for any docs examples[ ] Checked for breaking changes and labeled appropriatelyThings to look out for when moving styles
QA