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

[Emotion] Convert EuiSteps #6555

Merged
merged 25 commits into from
Feb 14, 2023
Merged

Conversation

elizabetdev
Copy link
Contributor

@elizabetdev elizabetdev commented Jan 26, 2023

Summary

This PR converts EuiSteps to Emotion (closes #6413) and closes #5847.

Design enhancements

image

QA

Remove or strikethrough items that do not apply to your PR.

General checklist

  • Checked in both light and dark modes
  • Checked in mobile
  • Checked in Chrome, Safari, Edge, and Firefox
  • Props have proper autodocs (using @default if default values are missing) and playground toggles
    - [ ] Added documentation
    - [ ] Checked Code Sandbox works for any docs examples
  • Added or updated jest and cypress tests
    - [ ] Checked for breaking changes and labeled appropriately
  • Checked for accessibility including keyboard-only and screenreader modes
  • Updated the Figma library counterpart
  • A changelog entry exists and is marked appropriately

Emotion conversion checklist

  • Does it work?
  • Output CSS matches the previous CSS / as expected in browsers
  • Rendered className reads as expected in snapshots and in browsers
  • Checked component playground (class components wrapped in withEuiTheme need to pass true as the second argument to its propUtilityForPlayground in src-docs/src/views/{component}/playground.js)
     
  • Unit tests
  • shouldRenderCustomStyles() test was added and passes with parent component and any nested childProps (e.g. tooltipProps)
    - [ ] Removed any mount()ed snapshots in favor of render() or a more specific assertion
     
  • Sass/Emotion conversion process
  • Converted all global Sass vars/mixins to JS (e.g. $euiSize to euiTheme.size.base)
  • Removed or converted component-specific Sass vars/mixins to exported JS versions, listed removals in changelog, and manually updated our theme JSON files
  • Simplified calc() to mathWithUnits if possible (if mixing different unit types, this may not be possible)
    - [ ] Added an @warn deprecation message within the global_styling/mixins/{component}.scss file
  • Removed component from src/components/index.scss
  • Deleted any src/amsterdam/overrides/{component}.scss files (styles within should have been converted to the baseline Emotion styles)
     
  • CSS tech debt
  • Reduced specificity where possible (usually by reducing nesting and class name chaining)
  • Wrapped all animations or transitions in euiCanAnimate
  • Used gap property to add margin between items if using flex
  • Converted side specific padding, margin, and position to -inline and -block logical properties (check inline styles as well as CSS)
     
  • DOM cleanup
  • Did not remove any block/element classNames (e.g. euiComponent, euiComponent__child)
  • Deleted any modifier classNames or maps if not being used in Kibana. Before doing this step:
    • Search/grep through Kibana's codebase for {euiComponent}- (case sensitive) to check for source code usage of modifier classes
    • If usages exist, consider converting to a data attribute so that consumers still have something to hook into
       
  • Kibana due diligence
  • Pre-emptively check how your conversion will impact the next Kibana upgrade. This entails searching/grepping through Kibana (excluding **/target, **/*.snap, **/*.storyshot for less noise) for eui{Component} (case sensitive) to find:
  • Any test/query selectors that will need to be updated
  • Any Sass or CSS that will need to be updated, particularly if a component Sass var was deleted
  • Any direct className usages that will need to be refactored (e.g. someone calling the euiBadge class on a div instead of simply using the EuiBadge component)
     
  • Extras/nice-to-have
  • Documentation pass:
    • Converted any remaining .js docs files to TS
    • Misc cleanup of docs code (e.g. combine imports to single from '../src', replace <React.Fragment> with <>)
  • 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

@kibanamachine
Copy link

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

@kibanamachine
Copy link

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

@kibanamachine
Copy link

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

@kibanamachine
Copy link

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

@kibanamachine
Copy link

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

@kibanamachine
Copy link

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

@kibanamachine
Copy link

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

@elizabetdev elizabetdev marked this pull request as ready for review February 9, 2023 16:23
@kibanamachine
Copy link

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

Copy link
Contributor

@cee-chen cee-chen left a comment

Choose a reason for hiding this comment

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

Hey Elizabet! Huge apologies, my EuiDataGrid work ended up taking most of my time today and I didn't end up being able to pull this PR down after all. I skimmed it super briefly and did notice a small bug with the titleSize="xs" example.

I'm out tomorrow but will be back on Monday to help address/clean up any code feedback etc before Tuesday's release. Am I cool to push up to this PR?

src/components/steps/step.styles.ts Outdated Show resolved Hide resolved
src/components/steps/step.styles.ts Outdated Show resolved Hide resolved
src/components/steps/step.styles.ts Outdated Show resolved Hide resolved
@kibanamachine
Copy link

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

@elizabetdev
Copy link
Contributor Author

@cee-chen I went through your review and pushed some changes.

Am I cool to push up to this PR?

Yes, no problem at all.

@kibanamachine
Copy link

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

- remove unnecessary `isDisabled` style - it's not doing anything

- clean up lineGradient readability

- add `euiStepTitleStyles` to avoid nesting CSS selectors

- Remove ambiguous `small` vs `medium` sizes: pass the equivalent props instead, and rename the size variable to be clear that it's referring to the `xs` size, not the `s` size

- use more logicalCSS (easier to read) and less logicalShorthandCSS (it's getting overridden anyway)

+ fix `medium` sized titles getting padding that they should not have been
+ bump up padding-top on `s` titles to center text a bit more

- fix EuiStepNumber not actually having the default size that its props documentation claims it does
- remove unnecessary repeated `makeLineProgress` - it's defined once in `euiStepHorizontal` and it doesn't need to be redefined again

- remove `:not` isDisabled class selector in favor of an `enabled` style

- remove unused isComplete/isIncomplete styles

- pull out separate euiStepHorizontalNumberStyles fn and remove unnecessary selector nesting on box shadow application (if it's selected, it can't also be loading/disabled/warning)

- make emotion classNames more closely match passed `status`es

- fix BEM class naming

- Remove old prop documentation to now-removed `isSelected` and `isComplete` props, + remove `isSelected` var naming in favor of `isCurrent`

- clean up unnecessarily verbose `isCurrent` spread operator
- create `euiStepNumberContentStyles` to reduce CSS nesting

- rewrite JSX output to use a switch (w/ groupings for icon vs number types) and an aria labels map for clearer readability

- move `createStepsNumber` to fn within map its used in (since it's fairly basic and only used for one specific purpose, there's no need to keep passing around euiTheme

- prefer theme vars over static `px` sizes
+ fix missing specific titles for `danger` and `loading` statuses
Comment on lines +22 to +26
// Remove the respective lines if the first or last child
&:first-of-type > .euiStepHorizontal::before,
&:last-of-type > .euiStepHorizontal::after {
display: none;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Note for reference: I debated trying to flatten this by passing isFirst or isLast to the underying EuiStep, but decided against it - I don't think the extra code cruft is worth the slight CSS flattening, as consumers are unlikely to want to override this CSS

Copy link
Contributor

@cee-chen cee-chen left a comment

Choose a reason for hiding this comment

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

Hey Elizabet, done with my QA & cleanups and I think this is GTG. I just have one remaining comment I found while comparing prod vs dev, but I'm not sure if the change was intentional.

src/components/steps/step_number.styles.ts Outdated Show resolved Hide resolved
@kibanamachine
Copy link

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

onClick={onStepClick}
disabled={disabled}
css={cssStyles}
data-step-status={status}
Copy link
Contributor

Choose a reason for hiding this comment

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

Note for reference: I added this new data-step-status util because we're not setting status classes via Emotion, and because it looks like Fleet is hooking into euiStepHorizontal-isIncomplete as an override (link).

If needed we can add this data attr to EuiStep as well, but I currently don't see the need / any Kibana usage

- remove unnecessary Fragments and divs
Comment on lines 109 to 111
current: css`
${euiShadowXSmall(euiThemeContext)}
`,
Copy link
Contributor

Choose a reason for hiding this comment

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

I see the CSS for this correctly appearing, but I can barely see this shadow at all on either light or dark mode. Am I just blind, or should we consider removing this? 🤷 @miukimiu, any opinions?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I could notice it in light mode. But I agree, it's almost unperceivable. So I removed it.

@kibanamachine
Copy link

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

@elizabetdev elizabetdev enabled auto-merge (squash) February 14, 2023 12:53
@elizabetdev
Copy link
Contributor Author

Thanks @cee-chen for all the help and for finding some design inconsistencies. I pushed f2ea3c8 based on your final review.

@kibanamachine
Copy link

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

@elizabetdev elizabetdev merged commit 1b82dd8 into elastic:main Feb 14, 2023
cee-chen added a commit to elastic/kibana that referenced this pull request Feb 15, 2023
## Summary

`[email protected]` ⏩ `[email protected]`

---

## [`75.1.0`](https://github.com/elastic/eui/tree/v75.1.0)

- Added padding to `EuiStep` title to better align with icon
([#6555](elastic/eui#6555))
- Added a new `lineNumbers.annotations` API to `EuiCodeBlock`. This new
feature displays an informational icon next to the specified line
number(s), providing more context via popover
([#6580](elastic/eui#6580))

**Bug fixes**

- Fixed bug in `EuiRange` where styles were applied incorrectly when
custom ticks were passed but `showTicks` were false
([#6588](elastic/eui#6588))
- Fixed `fleetApp` and `agentApp` icons that were swapped
([#6590](elastic/eui#6590))

**CSS-in-JS conversions**

- Converted `EuiSteps` to Emotion; Removed `$euiStepStatusColorsToFade`,
`$euiStepNumberSize`, `$euiStepNumberSmallSize`, and
`$euiStepNumberMargin`
([#6555](elastic/eui#6555))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Emotion] EuiSteps [EuiStep] Add padding to step title to better align with icon
3 participants