-
Notifications
You must be signed in to change notification settings - Fork 844
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] Global theme #4643
[CSS-in-JS] Global theme #4643
Conversation
…e/css-in-js_themes
commit 9f4bcba Merge: e7c9c43 88709ac Author: Greg Thompson <thompson.glowe@gmail.com> Date: Thu Mar 11 10:41:10 2021 -0600 Merge branch css-in-js/sizes of https://github.com/thompsongl/eui into css-in-js/sizes commit e7c9c43 Merge: 60ef501 1a35553 Author: Greg Thompson <thompson.glowe@gmail.com> Date: Thu Mar 11 10:38:44 2021 -0600 Merge branch feature/css-in-js into css-in-js/sizes commit 88709ac Author: cchaos <caroline.horn@elastic.co> Date: Mon Mar 8 16:46:31 2021 -0500 Updating consuming example to show `calc()` commit 60ef501 Author: Greg Thompson <thompson.glowe@gmail.com> Date: Wed Mar 3 17:46:29 2021 -0600 fewer calc() commit 10ad430 Author: Greg Thompson <thompson.glowe@gmail.com> Date: Wed Mar 3 12:37:09 2021 -0600 docs commit 34e0ba1 Merge: c897fa7 1b2f77b Author: Greg Thompson <thompson.glowe@gmail.com> Date: Wed Mar 3 12:10:44 2021 -0600 Merge branch feature/css-in-js into css-in-js/sizes commit c897fa7 Merge: 9766b78 9074437 Author: Greg Thompson <thompson.glowe@gmail.com> Date: Mon Mar 1 11:08:17 2021 -0600 Merge branch feature/css-in-js into css-in-js/sizes commit 9766b78 Author: Greg Thompson <thompson.glowe@gmail.com> Date: Thu Feb 25 10:34:45 2021 -0600 convert numbers to strings with units
… and anything conusming via `[COLOR_MODE_KEY]` should get converted to top level concern while anything just using `euiTheme.colors` would stay
Breaks test in components (??)
…ure/css-in-js_themes # Conflicts: # src-docs/src/views/theme/consuming.tsx # src-docs/src/views/theme/consuming_hoc.tsx # src/services/theme/theme.ts
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@thompsongl We talked through a bunch of these, but thought it would be helpful to point them out in the code for easier reference too.
Support more files, and arrays in theme
This comment has been minimized.
This comment has been minimized.
See cchaos#44 for a concept on changing how |
Preview documentation changes for this PR: https://eui.elastic.co/pr_4643/ |
Preview documentation changes for this PR: https://eui.elastic.co/pr_4643/ |
Preview documentation changes for this PR: https://eui.elastic.co/pr_4643/ |
@cchaos Some unused variable files exist:
Do you have any later plans for them or should we remove them? |
jenkins test this |
Preview documentation changes for this PR: https://eui.elastic.co/pr_4643/ |
…e/css-in-js_themes
Preview documentation changes for this PR: https://eui.elastic.co/pr_4643/ |
Yeah they're not used yet but I didn't want to lose this initial conversion work. Im ok to leave in. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Preview documentation changes for this PR: https://eui.elastic.co/pr_4643/ |
Preview documentation changes for this PR: https://eui.elastic.co/pr_4643/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🙀
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
This is a starting PR to work out the basic global theme object
Help
See outdated commentary
_I'll also comment about/point to these in the code._I'm having some issues about where I'm usingcomputed()
and getting an error around'getOwnPropertyDescriptor'
like with the text variants if I try to pull them out of thetheme.js
file.I can't seem to declare themes withbuildTheme()
outside oftheme.js
color
keys are getting removed/not outputting?Can't seem to pass any values that aren't a number or string, like if we want an arrayTrying to be efficient by mapping through arrays to create theme keys comes with some TS challengesCan we useuseEuiTheme
in helper functions to get something like the currentbase
value when computing other theme values?Trying to just re-use a full object is not working. Like if the key is:And I try to use it like this to spread those keys onto a new key, it doesn't work:Discuss
COLOR_MODE_KEY
tl;dr: Using
LIGHT
andDARK
keys at any level of nesting (#4643 (comment))See outdated commentary
Can we get rid of having to specify
[COLOR_MODE_KEY]
which evaluates tocolors
in order to distinguish betweenlight
anddark
theme values? Instead can the actuallight
anddark
keys be those?Before
Instead, it could be a top level key that either exists or doesn't (for single color mode)
Or even better, just remove always check for
light
ordark
at any nested levelChakra uses hooks internally when creating the theme that would look something like this, though I'm not convinced this is the best approach or is able to work with computed values, just an example:
Global vs Component theme
We should limit the top level
euiTheme
to truly just the global tokens like color, size, type sizes, etc. Even things likeeuiFontWeightCode
should be scoped to it's own theme.Before:
After:
ChecklistIgnoring for now, will go through it all on the feature branch