-
Notifications
You must be signed in to change notification settings - Fork 829
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
Theme typing discrepencies. #1465
Comments
A side question I have: Have you considered migrating away from js and only develop in typescript? I might make it easier to infer types from all components, theme, etc if you're implementing everything in typescript from the get-go? |
Speaking of which, I’ve been thinking for a while now that
AFAIK, these theme callback functions are remnants from a previous iteration of the theming architecture. There’s still internal theme objects that use it, but I’m not sure it’s a pattern we still want to move forward with or encourage others to use externally - do you have specific use-cases in mind where this sort of function would help you do something the standard theming conventions wouldn’t?
We’d love to - it would certainly make the typing aspect of theming (and all things) much smoother and more accurate overall. (In the most recent theme typing improvements, I manually went through and documented all of the pseudoselectors available in the default theme - that wasn’t very fun) As you can imagine, porting over a codebase of this size is no small feat, even with tooling like ts-migrate available. I’ve got a running branch on my fork that has the vast majority ported over, but there’s still a lot of testing + some polish before it’ll be ready to merge in and release. |
Thanks for the detailed response Brandon! Our specific use-cases for using the callback function are when we want to style something based on a combination of props. Example is our primary buttons with specific intents can be colored correctly etc. Not sure if there are any other good ways to do so, but at least that is the way we found to get it to work atm. Another use-case was to basically calculate variations of colors from our "common" theme. We went for doing that over enumerating all of the specific colors in multiple themes and so we wouldn't pollute theme.colors with a lot of colors.
Yeah I know exactly what you mean, I spent a couple of months doing this exact thing last year. Side question: Do you know how one would go about to set specific styling for the spinner that appears in buttons that have |
Totally understandable. PRs welcome - I believe adding these to the
Ah, I see. That's fair. The typing for this might be a little more complex - from what I've gathered, the object passed as the second param in that callback there isn't really the full component evergreen/src/hooks/use-style-config.js Lines 125 to 133 in 108a5bc
evergreen/src/buttons/src/Button.js Lines 80 to 85 in 108a5bc
evergreen/src/text-input/src/TextInput.js Lines 45 to 50 in 108a5bc
I don't think that's possible right now with the way the evergreen/src/buttons/src/Button.js Lines 103 to 109 in 108a5bc
|
Missing components in exported 'Components' type
When checking the value of the defaultTheme runtime, I saw a couple of components that I would like to override that weren't included in the
type Components
you export from the typings.Would it be sensible to inlcude those components in the type?
The components I found missing were:
DialogBody, DialogFooter, DialogHeader, Option and Table
Missing typing for theme callback function
I've seen that some components have functions to apply styles in the default theme and experimented with it, and what I found was that the callbackfunction basically has a signature of
(theme: Theme, props: ComponentProps)
where "ComponentProps" is the given component's props. Would it be sensible to expand the theme type to allow those functions? Atm I'm overriding the theme type to allow it in our project.The text was updated successfully, but these errors were encountered: