[EuiSuperDatePicker] Convert form control styles to Emotion#7904
[EuiSuperDatePicker] Convert form control styles to Emotion#7904cee-chen merged 11 commits intoelastic:mainfrom
Conversation
- some shenanigans rquired because of existing render fn
+ delete width Sass variables
- `noUpdateButton` requires a few per-width-type tweaks to get this working as before in prod, due to changed CSS delcaration order - `isAutoRefreshOnly` is not correctly responding to width prop on prod, this fixes that
- flatten CSS where possible (in the case of `.euiFormControlLayout__childrenWrapper`'s border-radius it is sadly not possible) - un-DRY prettyFormat CSS for now, DRY out with popover buttons later - `!important` on `.euiSuperDatePicker__rangeInput` required to offset the CSS added by `fullWidth: true` on the form control layout
+ simplify `.euiDatePopoverButton` to inherit from the form wrapper instead of reusing the static variable
- use flex for compressed height instead of static form variables - keep modifier classes for Kibana usage
- [opinionated cleanup/change] set background colors on the layout wrapper div instead of the button where possible - reuse the CSS variable and form Emotion mixins where possible as well
426d8cb to
8146a82
Compare
| component.setProps({ isPaused: true, refreshInterval: 0 }); | ||
| jest.advanceTimersByTime(10); | ||
| await instanceRefresh.asyncInterval!.__pendingFn; | ||
| await jest.runAllTicks(); |
There was a problem hiding this comment.
@mgadewoll Your Jest upgrade PR allowed me to use this new handy util!! 🎉
8146a82 to
3abb05a
Compare
+ fix test describe name
3abb05a to
1583a79
Compare
💚 Build Succeeded
History
|
mgadewoll
left a comment
There was a problem hiding this comment.
I left two small comments for clarification purposes on changes but apart from that the changes look good to me!
|
|
||
| widths: { | ||
| restricted: css` | ||
| ${logicalCSS('width', restrictedWidth)} |
There was a problem hiding this comment.
Just for clarification: I noticed there is a tiny change in width here now, that I assume is expected? I see that previously the EuiSuperDatePicker had a restricted width of 606px and now 600px which seems more sensible.
Screen.Recording.2024-07-23.at.14.22.37.mov
There was a problem hiding this comment.
Yeah I think the math was off with the previous Sass calculations (possibly due to flex gap?). Agreed that 600px seems more correct than 606px!
|
|
||
| &:disabled { | ||
| background-color: ${forms.backgroundDisabledColor}; | ||
| color: ${forms.controlDisabledColor}; |
There was a problem hiding this comment.
IMO it's more correct as it matches our existing form controls/fields:
It's also worth noting that there are no WCAG color contrast requirements for disabled elements/buttons: https://sean-elliott.medium.com/a11y-tips-disabled-buttons-and-colour-contrast-f8824d5e9610
There was a problem hiding this comment.
Agreed, that overall this change makes sense to align with other form controls. I was just wondering if we consider the contrast, but if that would be the case it's anyway a question on a broader level for forms I guess.
There was a problem hiding this comment.
Yes, and this way/with this change, if we change contrast levels for all form components, this component will also update automatically :)
| expect(componentUpdatedRefresh.prop('isPaused')).toBe(false); | ||
| const refreshButton = container.querySelector('.euiAutoRefreshButton'); | ||
|
|
||
| expect(refreshButton).toBeInTheDocument(); |
There was a problem hiding this comment.
Much cleanup, much nice 🧹
|
Going to go ahead and merge this PR to move ahead on more EuiSuperDatePicker emotion work. If you have any other change requests that I didn't fully address I can grab it in a follow-up PR! |
`v95.4.0` ⏩ `v95.5.0` _[Questions? Please see our Kibana upgrade FAQ.](https://github.com/elastic/eui/blob/main/wiki/eui-team-processes/upgrading-kibana.md#faq-for-kibana-teams)_ --- ## [`v95.5.0`](https://github.com/elastic/eui/releases/v95.5.0) - Added `minusInSquare` and `plusInSquare` glyphs to `EuiIcon`. ([#7875](elastic/eui#7875)) **Bug fixes** - Fixed `EuiSuperDatePicker` not correctly passing `refreshMinInterval` from the quick select popover ([#7905](elastic/eui#7905)) **CSS-in-JS conversions** - Converted `EuiSuperDatePicker`'s form control to Emotion; ([#7904](elastic/eui#7904)) - Removed `$euiSuperDatePickerWidth` - Removed `$euiSuperDatePickerButtonWidth` - Removed `$euiSuperDatePickerNeedsUpdatingBackgroundColor` - Removed `$euiSuperDatePickerNeedsUpdatingTextColor` - Removed `@euiSuperDatePickerText` mixin - Converted `EuiSuperDatePicker`'s date popover content to Emotion ([#7908](elastic/eui#7908)) - Converted `EuiSuperDatePicker`'s quick select to Emotion ([#7909](elastic/eui#7909)) --------- Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>


Summary
This PR converts EuiSuperDatePicker's form control UI to Emotion. It does not convert any of EuiSuperDatePicker's popover styles to Emotion (for ease of review - plus to help separate some extra groundwork with EuiDatePicker's variables).
QA
https://eui.elastic.co/pr_7904/#/templates/super-date-picker should look the same as production with the following permutations:
Last 30 minutestext then click between~30 minutes agoandnow)Last 30 minutestext, then~30 minutes ago, then change tominutes from now)Last 30 minutestext, then~30 minutes ago, then change toseconds ago from now)trueto theisDisabledcontrol)General checklist
and screenreader modes- [ ] Added or updated jest and cypress tests[ ] If applicable, added the breaking change issue label (and filled out the breaking change checklist)Emotion checklist
General
className(s)read as expected in snapshots and browsersUnit tests
shouldRenderCustomStyles()test was added and passes with parent component and any nestedchildProps(e.g.tooltipProps)Sass/Emotion conversion process
$euiSizetoeuiTheme.size.base)[ ] Ranyarn compile-scssto update var/mixin JSON files[ ] Simplifiedcalc()tomathWithUnitsif possible (if mixing different unit types, this may not be possible)[ ] Added an@warndeprecation message within theglobal_styling/mixins/{component}.scssfile[ ] Removed component from- Not yetsrc/components/index.scss[ ] Deleted anysrc/amsterdam/overrides/{component}.scssfiles (styles within should have been converted to the baseline Emotion styles)CSS tech debt
euiCanAnimategapproperty to add margin between items if using flex-inlineand-blocklogical properties (check inline styles as well as CSS)DOM Cleanup
euiComponent,euiComponent__child)Kibana due diligence
**/target, **/*.snap, **/*.storyshotfor less noise) foreui{Component}(case sensitive) to find:euiBadgeclass on a div instead of simply using theEuiBadgecomponent) - None{euiComponent}-(case sensitive) to check for usage of modifier classes - None for EuiSuperDatePicker, 2 for EuiDatePopoverButton[ ] If usage exists, consider converting to adataattribute so that consumers still have something to hook intoExtras/nice-to-have
[ ] Documentation pass:[ ] Check for issues in the backlog that could be a quick fix for that component[ ] Optional component/code cleanup: consider splitting up the component into multiple children if it's overly verbose or difficult to reason about