-
Notifications
You must be signed in to change notification settings - Fork 840
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] Simplify shadow parameters #5892
Merged
Merged
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
aad3eb0
Simplify shadow parameters
db807fa
cl
3e8d27c
Update naming and simplify some destructuring
fb3cd34
One more
d0c3cfe
Apply suggestions from code review
cchaos 49938a9
Merge branch 'elastic:main' into css-in-js/simplify-shadow-mixins
cchaos File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
- Updated all CSS-in-JS shadow functions parameters to match a `(euiTheme, { color? })` order | ||
- Updated `euiShadow()` parameters to `(euiTheme, size, { color? })` |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This distinction feels somewhat confusing to me and I wish we were a bit more consistent on whether we pass the entire returned context or just
euiTheme
between various helpers (e.g., the typography fns all passeuiTheme.euiTheme
and not the parent context, but this is also because basically every single.styles.ts
file deconstructs{ euiTheme }
automatically in its params).I also wish we had a clearer naming convention for the context vs the actual theme data so that we don't end up essentially deconstructing
_euiTheme.euiTheme
🙈 MaybethemeContext.euiTheme
instead?...@thompsongl, any thoughts here?
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.
Agreed with all those points. I wonder if it's just easiest to say, any mixin/function should accept the entirety of
UseEuiTheme
whether they only need the.euiTheme
portion or not? It keeps them scalable in case of future needs to grab thecolorMode
.As for naming we could just change to also ensure we're naming it as lowercase
useEuiTheme
so that it is clear.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.
Yeah I had mixins passing the full result of
useEuiTheme
originally. The cases where mixins neededcolorMode
were scarce so I went the other way. But I'd rather see consistency like you've suggested if working with the current mixin shape is difficult.We should update all mixins and the createStyleHookFromMixin util with the new pattern.
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.
++
Also I just realized we could simplify the code portion a bit too by deconstructing in the parameters.
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.
I pushed a commit based on those latest comments. But I didn't touch the util (that one still confuses me a bit)
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.
😄 But are you ok if I do it and add a bunch to this PR?
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.
Or if you want to merge this I can do a follow up. Up to you!
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.
Yes, go for it. I'm out for the rest of the week.
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.
Hmm not sure I can make a generic function that works with mixins that do have required args and mixins that do not have required args.
vs
So a couple options:
euiScrollBarStyles(euiThemeContext, {}, {size: 20});
createStyleHookFromMixin
so we have one with required args and one withoutcreateStyleHookFromMixin
entirely and manually create hooks. (We lose the type safety/consistency that it adds to mixins; we have to just be consistent when creating new mixins).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.
Honestly I think my (opinionated) vote goes to
I haven't used this helper personally despite having created a few mixins and I don't super see the need for it. 🤔 It's not really that tedious to manually write a 5-line hook next to a mixin.
If we do strongly want the helper still, then my next vote goes to
Move the required args and optional args into a single object