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

[EuiCard & friends] Convert to Emotion #6110

Merged
merged 13 commits into from
Aug 22, 2022
Merged

Conversation

cchaos
Copy link
Contributor

@cchaos cchaos commented Aug 4, 2022

Note
I didn't actually start anything new this week, I had done this conversion before going on vacation, I just forgot about it and didn't want to waste the effort 😆

Design update

There's been a updated design proposal in the Figma version for a long time (since Amsterdam style updates) that I've now included in this PR. It simplifies a lot of the original selectable card button code.

image

I left the de-selected button as text color instead of primary, but it's debatable and technically still customizable.

Code notes

  • Passes through paddingSize and display for some generated styles
  • Explicitely sets default padding to m and keeps m when betaBadge exists
  • Added progressive enhancement for :has() to propograte the outline to the whole card

Other updates

  • Added anchorProps to EuiToolTip and EuiBetaBadge to allow passing through more options like css
  • Added truncation to EuiBetaBadge and white background for hollow which aligns with basic EuiBadge styles
  • Fixed card top padding for badge which was always hard-coded, now it resizes with paddingSize

Checklist

  • Checked in both light and dark modes
  • Checked in mobile
  • Checked in Chrome, Safari, Edge, and Firefox
  • Props have proper autodocs 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

cchaos added 10 commits June 23, 2022 23:12
Todo: Investigate why `shouldRenderCustomStyles` doesn’t work
… to match proposed design from Figma
and cleaning up some outdated styles
- Added `anchorProps` to EuiToolTip and EuiBetaBadge to allow passing through more options like `css`
- Added truncation to EuiBetaBadge and white background for `hollow`
- Passes through `paddingSize` and `display` for some generated styles
- Explicitely sets default padding to `m` and keeps `m` when `betaBadge` exists
- Added progressive enhancement for `:has()` to propograte the outline to the whole card
- Deleted the Sass files
- Logicals
- Converted docs to TSX
- Fixed top padding for badge
@kibanamachine
Copy link

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

* A constant storing the support for the `:has()` selector through a
* media query that will only apply the content it is supported.
*/
export const euiSupportsHas = '@supports(selector(:has(p)))';
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should (and where) we start documenting small style-only helpers like this?

src/components/panel/panel.tsx Show resolved Hide resolved
Comment on lines +31 to +34
// TODO
// shouldRenderCustomStyles(
// <EuiCheckableCard {...checkablePanelRequiredProps} />
// );
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Help? It spits out some really weird stuff in the console.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah it looks like there are a couple scenarios not accounted for in the shouldRenderCustomStyles helper.

  • When the css prop is passed to a component that already uses Emotion
  • When the style prop is not passed to the main element in the component

Looking, but we may need shouldRenderCustomStyles to accept a some kind of config object

Copy link
Contributor

Choose a reason for hiding this comment

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

Created #6152 to track the work and not block this PR

src/components/card/card.tsx Outdated Show resolved Hide resolved
src/components/card/card.tsx Outdated Show resolved Hide resolved
src/components/card/card.tsx Show resolved Hide resolved
src/components/card/card.tsx Show resolved Hide resolved
Comment on lines +260 to +262
// Todo: $euiButtonMinWidth
// Extend beta badges to at least 30% of the container's width or 112px (whichever is smaller)
${logicalCSS('min-width', 'min(30%, 112px)')};
Copy link
Contributor Author

Choose a reason for hiding this comment

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

At some point when EuiButton is converted it'd be nice to get values like this for re-use.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This may be a good place to use the pattern @miukimiu is using in the range slider conversion

@kibanamachine
Copy link

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

1 similar comment
@kibanamachine
Copy link

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

@cchaos cchaos marked this pull request as ready for review August 8, 2022 14:15
@cchaos
Copy link
Contributor Author

cchaos commented Aug 8, 2022

Forgot to mark this as ready for review 😄

@cchaos cchaos requested a review from miukimiu August 8, 2022 14:16
@thompsongl thompsongl self-requested a review August 8, 2022 18:46
Copy link
Contributor

@miukimiu miukimiu left a comment

Choose a reason for hiding this comment

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

Thanks, @cchaos.

I basically tested the cards in Chrome, Safari, Edge, and Firefox. Also in light and dark modes.
Looked at the code and LGTM! 🎉

upcoming_changelogs/6110.md Outdated Show resolved Hide resolved
@cla-checker-service
Copy link

❌ Author of the following commits did not sign a Contributor Agreement:
b6d64f9, 10a0fbe, e7f1bf4, bd0e60e, eaf4632, 122ce69, 0832a74, f962f5d, 72900e7, ebdb62f

Please, read and sign the above mentioned agreement if you want to contribute to this project

@kibanamachine
Copy link

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

Copy link
Contributor

@thompsongl thompsongl left a comment

Choose a reason for hiding this comment

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

❌ Author of the following commits did not sign a Contributor Agreement:
b6d64f9, 10a0fbe, e7f1bf4, bd0e60e, eaf4632, 122ce69, 0832a74, f962f5d, 72900e7, ebdb62f

Please, read and sign the above mentioned agreement if you want to contribute to this project

Caroline was still with Elastic when these commits were made, so we're good to merge.

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.

4 participants