Skip to content
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

[CSS-in-JS] Fix EUI media queries to more flexibly account for custom breakpoints #6431

Merged
merged 10 commits into from
Nov 23, 2022

Conversation

cee-chen
Copy link
Contributor

@cee-chen cee-chen commented Nov 23, 2022

Summary

Consumers who have custom breakpoints above and below our xs and xl breakpoints currently will have buggy responsive behavior due to the way our breakpoint mixins are written. When we wrote euiBreakpoint(['m', 'xl']) in our previous CSS, we actually wanted m and above and not just screens m, l, and xl (which breaks when screen on xxl).

To future-proof our current CSS against custom consumer breakpoints, I've added new euiMinBreakpoint() and euiMaxBreakpoint() utils to help us actually capture the "x and below" or "x and above" logic we usually want. These two new utilities treat breakpoint sizes as one-dimensional points rather than two-dimensional screen ranges, which should hopefully be easier to reason about.

This fix must be backported to 8.6 in order for Observability Kibana to not have broken flyouts/media queries in 8.6.

I strongly recommend following along by commit.

Before

After

QA

To reproduce the broken behavior locally:

  1. gh pr checkout 6431
  2. git checkout aff41f9d00017c8ece9a444a4c30fb78c7677457
  3. Go to http://localhost:8030/#/layout/flyout#sizing
  4. Set your window viewport to 2400 px wide
  5. Confirm that the flyout no longer has a width CSS set
  6. Set your window viewport to 1100px wide
  7. Confirm that the flyout now has a width/responsive media query CSS set
  8. gh pr checkout 6431 again to get back the fix

Component responsive smoke test checklist:

  • EuiFlyout
  • EuiDescriptionList
  • EuiFlex
  • EuiImage
  • EuiModal
  • EuiPage
  • EuiToastList

General checklist

- [ ] Checked in both light and dark modes
- [ ] Checked in Chrome, Safari, Edge, and Firefox
- [ ] Props have proper autodocs and playground toggles
- [ ] Checked Code Sandbox works for any docs examples
- [ ] Checked for breaking changes and labeled appropriately
- [ ] Checked for accessibility including keyboard-only and screenreader modes
- [ ] Updated the Figma library counterpart

- for better future-proofing for consumers who add custom (e.g.) `xxl`/`xxs` breakpoints
- set screen size to 2400 px to see bug
+ query organization - move smaller/mobile styles before larger desktop styles
@cee-chen cee-chen requested a review from elizabetdev November 23, 2022 03:06
@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_6431/

Copy link
Contributor

@1Copenut 1Copenut left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 LGTM. One copy-edit change, but that doesn't need another look.

I started the local server and looked at changed components in widescreen, mobile preview (Chrome) and points in between. It's not a perfect proxy for visual regression testing, but seemed like the best way to evaluate the changeset.

src-docs/src/views/theme/breakpoints/_breakpoints_js.tsx Outdated Show resolved Hide resolved
Copy link
Contributor

@elizabetdev elizabetdev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @constancecchen for fixing this issue.

Tested locally following the QA indications in Chrome, Safari, Edge, and Firefox.

LGTM! 🎉

@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_6431/

- base padding is already set on the base CSS, so using min-width means we don't have 2 unnecessary overrides

- use nesting instead of repeating :not:empty selectors

- not even sure what is going on with that euiToastWidth math
@cee-chen cee-chen enabled auto-merge (squash) November 23, 2022 17:53
@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_6431/

@cee-chen cee-chen merged commit 4e77129 into elastic:main Nov 23, 2022
@cee-chen cee-chen deleted the responsive-fixes branch November 23, 2022 18:33
cee-chen pushed a commit to elastic/kibana that referenced this pull request Nov 23, 2022
## Summary
`[email protected]` ⏩ `[email protected]`

This backport fixes EuiFlyout bugs affecting Observability. It is meant
to go directly into 8.6.

## [`67.1.10`](https://github.com/elastic/eui/tree/v67.1.10)

- Added the `euiMaxBreakpoint` and `euiMinBreakpoint` CSS-in-JS
utilities for creating min/max-width media queries
([#6431](elastic/eui#6431))

**Bug fixes**

- Fixed missing slide-in animation on `EuiCollapsibleNav`s and left-side
`EuiFlyout`s ([#6422](elastic/eui#6422))
- Fixed multiple component media queries for consumers with custom theme
breakpoints ([#6431](elastic/eui#6431))
1Copenut added a commit to elastic/kibana that referenced this pull request Dec 2, 2022
`[email protected]` ⏩ `[email protected]`

- "Fixed EuiButtonGroup firing onChange twice" required changing some
tests from `click` to `change`
___

## [`70.4.0`](https://github.com/elastic/eui/tree/v70.4.0)

- Updated `EuiTourStep.footerAction` type to accept `ReactNode[]`
([#6384](elastic/eui#6384))
- Vertically aligned all footer content so that `euiTourStepIndicator`
is always centered ([#6384](elastic/eui#6384))
- Added `filterInCircle` glyph to `EuiIcon`
([#6385](elastic/eui#6385))
- Added `color` prop to `EuiBeacon`
([#6420](elastic/eui#6420))
- Added the `euiMaxBreakpoint` and `euiMinBreakpoint` CSS-in-JS
utilities for creating min/max-width media queries
([#6431](elastic/eui#6431))

**Bug fixes**

- Restores the previous match operator behaviour when the query value is
split into multiple terms after analysis.
([#6409](elastic/eui#6409))
- Fixed missing slide-in animation on `EuiCollapsibleNav`s and left-side
`EuiFlyout`s ([#6422](elastic/eui#6422))
- Fix bug in `EuiCard` where footer were not aligned to the bottom of
the card ([#6424](elastic/eui#6424))
- Fixed multiple component media queries for consumers with custom theme
breakpoints ([#6431](elastic/eui#6431))

## [`70.3.0`](https://github.com/elastic/eui/tree/v70.3.0)

- `EuiSearchBar` now automatically wraps special characters not used by
query syntax in quotes
([#6356](elastic/eui#6356))
- Added `alignment` prop to `EuiBetaBadge`
([#6361](elastic/eui#6361))
- `EuiButton` now accepts `minWidth={false}`
([#6373](elastic/eui#6373))

**Bug fixes**

- Fixed `EuiPageTemplate` not correctly passing the `component` prop to
the inner main content wrapper.
([#6352](elastic/eui#6352))
- `EuiSkipLink` now correctly calls `onClick` even when
`fallbackDestination` is invalid
([#6355](elastic/eui#6355))
- Permanently fixed `EuiModal` to not cause scroll-jumping issues on
modal open ([#6360](elastic/eui#6360))
- Re-fixed `EuiPageSection` not correctly merging `contentProps.css`
([#6365](elastic/eui#6365))
- Fixed `EuiTab` not defaulting to size `m`
([#6366](elastic/eui#6366))
- Fixed the shadow sizes of `.eui-yScrollWithShadows` and
`.eui-xScrollWithShadows`
([#6374](elastic/eui#6374))
- Fixed bug in `EuiCard` where the inner content in vertical cards was
not growing 100% in width
([#6377](elastic/eui#6377))
- Fixed incorrect margins in `EuiSuperDatePicker` caused by `EuiFlex`
CSS gap change ([#6380](elastic/eui#6380))
- Fixed visual bug in nested `EuiFlexGroup`s, where the parent
`EuiFlexGroup` is responsive but a child `EuiFlexGroup` is not
([#6381](elastic/eui#6381))

**CSS-in-JS conversions**

- Converted `EuiModal` to Emotion
([#6321](elastic/eui#6321))

**Fixes**

- `EuiButton` no longer outputs unnecessary inline styles for
`minWidth={0}` or `minWidth={false}`
([#6373](elastic/eui#6373))
- `EuiFacetButton` no longer reports type issues when passing props
accepted by `EuiButton`
([#6373](elastic/eui#6373))

Co-authored-by: Constance Chen <[email protected]>
edmarmoretti pushed a commit to edmarmoretti/eui-pt-br that referenced this pull request May 3, 2023
… breakpoints (elastic#6431)

* Create `euiMinBreakpoint` and `euiMaxBreakpoint` utilities

- for better future-proofing for consumers who add custom (e.g.) `xxl`/`xxs` breakpoints

* [Docs] Add docs example

* Update simple components to use new min/max breakpoint util

* [REVERT ME] Test observability app use case w/ flyouts

- set screen size to 2400 px to see bug

* [EuiFlyout] Fix responsive media queries to work with custom breakpoints

+ query organization - move smaller/mobile styles before larger desktop styles

* changelog

* wording is hard

* Revert "[REVERT ME] Test observability app use case w/ flyouts"

This reverts commit aff41f9.

* Fix incorrect mobile margins on `responsiveColumn` `EuiDescriptionList`s

* [EuiToastList] Clean up unnecessarily convoluted CSS

- base padding is already set on the base CSS, so using min-width means we don't have 2 unnecessary overrides

- use nesting instead of repeating :not:empty selectors

- not even sure what is going on with that euiToastWidth math
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants