-
Notifications
You must be signed in to change notification settings - Fork 841
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 EuiBottomBar
to Emotion
#5823
Conversation
Merge Changes from EUI Main
Merging in the latest code from eui/main
Merging in the latest code from main
Merging in the latest code from the main branch
Pulling in the latest code from the main branch
…ottom_bar Pulling in code from main
…ottom_bar Merging in the latest code from the main branch
Preview documentation changes for this PR: https://eui.elastic.co/pr_5823/ |
EuiBottomBar
to Emotion
… that wraps the original inside of EuiThemeProvider to pass the dark theme to the entire component. Removed the shouldRenderCustomStyles test utility
// Base | ||
euiBottomBar: css` | ||
${euiShadowFlat(euiTheme, undefined, colorMode)}; | ||
background: ${euiTheme.colors.lightShade}; |
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.
We still need this background color to render as it did previously. The sass variable is:
$euiHeaderDarkBackgroundColor: lightOrDarkTheme(shade($euiColorDarkestShade, 28%), shade($euiColorLightestShade, 50%)) !default;
But since we're only ever in dark
theme, we just need to apply the second parameter as the color:
background: ${euiTheme.colors.lightShade}; | |
background: ${shade(euiTheme.colors.lightestShade, .5)}; |
color: ${euiTheme.colors.text}; | ||
animation: ${euiBottomBarAppear} ${euiTheme.animation.slow} | ||
${euiTheme.animation.resistance}; | ||
z-index: ${_euiBottomBarZHeader - 2}; |
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 just pushed the z-index layering global theme vars to main.
z-index: ${_euiBottomBarZHeader - 2}; | |
z-index: ${euiTheme.levels.header - 2}; |
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.
Hm, it looks like this z-index should also only apply if the position is fixed
or sticky
.
//const _euiBottomBarColor = '#131317'; | ||
const _euiBottomBarZHeader = 1000; |
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.
So neither of these should be needed anymore.
//const _euiBottomBarColor = '#131317'; | |
const _euiBottomBarZHeader = 1000; |
} | ||
|
||
100% { | ||
transform: translateY(00%); |
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.
transform: translateY(00%); | |
transform: translateY(0%); |
@@ -156,6 +161,13 @@ export const EuiBottomBar = forwardRef< | |||
className | |||
); | |||
|
|||
const cssStyles = [ |
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 added styles[position]
back to the cssStyles
array because I need to access the position to determine if the z-index
should be added to the bottom bar. Since I already need it for that purpose, should we just attach the position
styling in those style blocks instead of passing it in directly here?
Jenkins, test this |
Preview documentation changes for this PR: https://eui.elastic.co/pr_5823/ |
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.
🙌 Our first dark-theme only component!
Just to compare using already converted components (Avatar, HR, LoadingChart) rendered inside the bottom bar:
LGTM. I tested in the 3 browsers and mobile. Gonna tag @thompsongl in on this one to ensure the wrapping component stuff is all what he expected.
export const EuiBottomBar = forwardRef<HTMLElement, EuiBottomBarProps>( | ||
(props, ref) => { | ||
const BottomBar = _EuiBottomBar; | ||
return ( | ||
<EuiThemeProvider colorMode={'dark'}> | ||
<BottomBar ref={ref} {...props} /> | ||
</EuiThemeProvider> | ||
); | ||
} | ||
); |
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.
Can you document this as a pattern for color-mode specific components in the Emotion styling wiki???
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.
Just a couple nits. Nice work!
|
||
export const euiBottomBarStyles = ({ euiTheme, colorMode }: UseEuiTheme) => ({ | ||
// Base | ||
//Text color needs to be reapplied to properly scope the forced `colorMode` |
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.
//Text color needs to be reapplied to properly scope the forced `colorMode` | |
// Text color needs to be reapplied to properly scope the forced `colorMode` |
import { UseEuiTheme } from '../../services'; | ||
import { shade } from '../../services/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.
Can these be combined?
Preview documentation changes for this PR: https://eui.elastic.co/pr_5823/ |
Preview documentation changes for this PR: https://eui.elastic.co/pr_5823/ |
Preview documentation changes for this PR: https://eui.elastic.co/pr_5823/ |
Co-authored-by: Caroline Horn <[email protected]>
Co-authored-by: Caroline Horn <[email protected]>
Preview documentation changes for this PR: https://eui.elastic.co/pr_5823/ |
Summary
Converts
EuiBottomBar
to EmotionAdditional changes include converting the original
EuiBottomBar
function into an internal utility component that is nested inside of a new component that wraps the the bottom bar in anEuiThemeProvider
. This was done to lay the ground work for future enhancements.Future enhancements include resolving #4158 by using
colorMode: inverse
on the bottom bar. This will ensure that the bottom bar always stands out in light mode and in dark mode because the background color of the bar will always be in contrast to the color mode.This will also include adding a prop to
EuiBottomBar
that will consumers to chooselight
ordark
as thecolorMode
for the bottom bar. If this prop is in use, thecolorMode: inverse
enhancement (mentioned above) will not take affect.These enhancements will come at a later time to reduce the amount of disruption for consumers. The
colorMode
changes will affect the background color of the bottom bar, but until other components have been converted to Emotion, these changes will be out of sync.Testing Note
With the changes made, the background color of
EuiBottomBar
should be a dark gray (euiTheme.colors.lightShade
) in both light and dark mode. Previous, the background color was white.Things to look out for when moving styles
Use gap property to add margin between items if using flexCan any still existing .js files be converted to TS?QA
Checklist