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] Create font scale functions/mixins #5822

Merged
merged 18 commits into from
Apr 21, 2022

Conversation

cchaos
Copy link
Contributor

@cchaos cchaos commented Apr 19, 2022

[NEW] euiFontSize() and useEuiFontSize()

Documentation link: Building

Screen Shot 2022-04-19 at 17 56 17 PM

Pixel value comparison to Sass version:

Screen Shot 2022-04-19 at 17 59 01 PM

Also:

  • Renamed SCALES to FONT_SCALES
  • Some (but not applied to all yet) file organization:
    • Moved typography values into Amsterdam theme folder
    • Simplified typography functions and moved to functions folder

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

@kibanamachine
Copy link

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

Copy link
Contributor Author

@cchaos cchaos left a comment

Choose a reason for hiding this comment

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

Ready for review! 😄

useIsWithinBreakpoints(['xs', 's', 'm']) && mobileOptions.width
useIsWithinBreakpoints(['xs', 's']) && mobileOptions.width
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 noticed that the JS breakpoint styles were not in sync with the Sass breakpoint styles for mobile table layouts. This fixes that

Comment on lines +264 to +266
// onUpdate={(value) => updateScale(key, value)}
// numberProps={{ step: 0.1, style: { width: '6em' } }}
groupProps={{ alignItems: 'center' }}
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'd love some help on seeing if we can have these body values updatable. The difference here, that I couldn't quite work out, is that the options from a specific list of of keys available in the theme. So we'd need a new form control type (EuiSelect) to handle that.

Copy link
Contributor

@thompsongl thompsongl Apr 20, 2022

Choose a reason for hiding this comment

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

Is this something you want to address in this PR? I'm not sure I understand the problem well enough to help at the moment.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not necessarily, if it seems too complicated. Probably best to get the hooks in now.

src/global_styling/variables/typography.ts Outdated Show resolved Hide resolved
@cchaos cchaos marked this pull request as ready for review April 19, 2022 22:36
@kibanamachine
Copy link

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

Comment on lines +162 to +165
Font sizing is provided through this React hook (or function
version) and not the global theme. It returns both the{' '}
<EuiCode>font-size</EuiCode> and <EuiCode>line-height</EuiCode> for
the provided <EuiCode>scale</EuiCode>.
Copy link
Contributor

Choose a reason for hiding this comment

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

I ❤️ this. Super smart way to do the theming "mixins" to also be used as "css utilities". Makes things very flexible.

@miukimiu miukimiu self-requested a review April 20, 2022 13:33
Setting a precedent to us `_` when declaring types
@cchaos cchaos requested a review from thompsongl April 20, 2022 19:13
@kibanamachine
Copy link

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

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.

LGTM!

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.

This looks great @cchaos! 🎉

Tested locally using the tokens and the useEuiFontSize hook. I also customized the theme by changing the typography settings. Everything worked well! 😄

Just found one minor issue in one snippet.

src-docs/src/views/theme/typography/_typography_js.tsx Outdated Show resolved Hide resolved
Co-authored-by: Elizabet Oliveira <elizabet.oliveira@elastic.co>
@kibanamachine
Copy link

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

@cchaos cchaos merged commit a242b7f into elastic:main Apr 21, 2022
@cchaos cchaos deleted the css-in-js/font-scale branch May 8, 2022 21:34
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.

None yet

5 participants