-
Notifications
You must be signed in to change notification settings - Fork 82
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
Custom theme-based TypeScript Intellisense #6
Comments
This requires some TypeScript codegen wizardry that I just don't have. I'll probably close this until some TS genius stumbles upon it and can solve it. |
There's an exciting theme UI PR which seems like it could solve this system-ui/theme-ui#1090. Still have to look more into it, but I've re-opened this issue. |
After many months, I'm excited to say that this feature is close to landing. @hasparus has been hard at work with many great additions to To follow: system-ui/theme-ui#1090 |
Alright, let's make this happen. |
Gosh, this is sooo hard with all of theme-ui's complex types in the way rn. @cmaycumber I think this is the start of v3 of Dripsy. Remove (I accidentally wrote this on the other thread first) |
This cool new project by @intergalacticspacehighway has good custom types: https://github.com/intergalacticspacehighway/react-native-styled-variants/blob/9d6a801683b5ffbc8641b5937b62f24425e504de/src/types.ts#L32 |
@nandorojo Have you seen |
Haha yeah good timing. I'd want to make sure that the type creator there from the custom theme is performant. For massive TS objects, you can get into slow performance if you recurse too much (see millsp/ts-toolbelt#154) |
Looks like TS performance has improved for this, which is good news microsoft/TypeScript#45711 |
That makes a lot of sense. We should definitely make sure that's the case. I wonder if we can build off of some of the work from |
Yeah, I wrote more about my vision for how this could work at #72 a while ago I feel like a good UX is const theme = createTheme({
...
})
type MyTheme = typeof theme
declare module 'dripsy' {
interface UserTheme extends MyTheme {}
} But I'm open to anything, also could make it like the styled variants for sure. The one missing piece is adding all of the custom scales |
I think that's definitely a good UX imo. Let me reread #72. I'm super pumped to get this started |
Starting at #124 |
I published the first version of this at yarn add dripsy@canary |
2 things left:
|
Popping in to say I thoroughly appreciate all the work being put into this. It will be such a great addition to Dripsy! |
Thanks, glad you think so! You can see more details at #124 |
Will be closed with the release of v3. |
Another goal of this library is to have a script that detects your theme, and builds TypeScript intellisense into your components based on your custom theme values. But this isn't made yet. I'd love help with it.
For example, if you have a theme like this:
Then you would get intellisense like this:
^ The gif might take sec to load.
I think this could be achieved with some TypeScript wizardry, where a command line takes in the theme file and generates a typescript hidden file in your repository. This hidden file would globally declare values that override the
sx
prop, injecting in type suggestions. The command would probably be placed in a given project'spostinstall
, so that it runs every time you runyarn
ornpm install
@slorber recommended I look here.
I think generating something like this would work?
The text was updated successfully, but these errors were encountered: