-
Notifications
You must be signed in to change notification settings - Fork 81
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
Add stricter type support #72
Comments
This should work in a |
@nandorojo it looks like #74, does that help push this along at all? PS: You've been doing really great work on the recent releases! |
Yeah, I haven't really had time to work on this. At the moment, I'm just using this in my app: import { useDripsyTheme } from 'dripsy'
import type { DripsyTheme } from './index'
export default function useTheme() {
return (useDripsyTheme().theme as any) as DripsyTheme
} |
Closed
3 tasks
This will be added in v3. See #124 🥳 |
Coming very soon... Code.-.hook.tsx.dripsy.mp4 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm still waiting on system-ui/theme-ui#1090 to merge, and it seems to be getting hung up.
I think it might be time to upstream theme-ui on types for certain things.
I have 2 goals:
Theme['customFonts']
useDripsyTheme
.sx
prop, but it's too complicated so I'll wait for the PR above.1) Edit the default
Theme
type, name itDripsyTheme
For starters, I'd like to override the default
Theme
type exported fromtheme-ui
, which does not includedripsy
'scustomFonts
key in the theme.As we can see here in this app by @byCedric,
customFonts
isn't included in the type, so you need to either ignoreTheme
, or make it a separate type. This doesn't seem ideal.Custom Font type implementation
Since Dripsy has strict requirements for custom fonts, it would be nice to enforce them with types too:
Unfortunately, it seems like this code sample doesn't actually work as intended, so I'd love suggestions on that.
2) Provide strict types for
useDripsyTheme
As it stands,
useDripsyTheme
has relatively weak typings. At the very least, I'd like it to piggy back off of 1) above, like so:Here, we at least get the
customFonts
field withuseDripsyTheme
.However, I think we could take it a step further with declaration merging. This is what system-ui/theme-ui#1090 intends to achieve for the
sx
prop. In the meantime, I think we can hack our way around it foruseDripsyTheme
.Strict types implementation
Imagine we have this theme:
A fair expectation from the user should be this:
I think it could be achieved with this kind of solution:
Step 1: Dripsy creates a
makeTheme
function:An example looks like this from theme-ui's upcoming PR.
Step 2: Dripsy exports
CustomDripsyTheme
Theme-ui plans to call this
UserTheme
, so once they do, we can merge them somehow, but this way we don't collide.Step 3: Users create their theme with
makeTheme
:Step 4. Make
FinalDripsyTheme
We can combine the original
BaseDripsyTheme
withCustomDripsyTheme
:The code above is taken from theme-ui here.
Now that we have this
DripsyTheme
created, we can use that inuseDripsyTheme
:The text was updated successfully, but these errors were encountered: