Add @theme-ui/css/utils with TypeScript CIF functions and fix preset types#1862
Conversation
|
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/systemui/theme-ui/66kAS3wwxg3hY8YpLhTbJYmdAAwA |
e7bb26d to
5872143
Compare
|
Hey @tornewuff, would you maybe have a moment to give it a look and see if it addresses your problems? |
| * Constrained identity function used to constrain user's theme type to Theme | ||
| * while preserving its exact type. | ||
| */ | ||
| export const makeTheme = <T extends Theme>(theme: T): T => theme |
There was a problem hiding this comment.
This looks awesome, is it internal API or intended to be used from the outside?
(Wondering if consumers could use it to build custom themes with or without presets?)
There was a problem hiding this comment.
I try to prefix exported internal APIs with __ or even __internal and mark add @internal jsdoc comment. This one is user-facing. I've been defining it in my projects for a long time.
Exported values in presets should have the correct types so they can be used properly when imported. Define types for all the relatively-easy cases, and fix various outdated property references.
Defined presets in a typesafe way. You can read more on CIFs at: https://kentcdodds.com/blog/how-to-write-a-constrained-identity-function-in-typescript
5872143 to
54af5ba
Compare
|
🚀 PR was released in |
Based on #1856.
Release Notes
makeTheme,makeStylesandmakeColorsScalewhich can be imported from @theme-ui/css/utils.📦 Published PR as canary version:
0.11.0-canary.1862.0fb581dc03f7a88fd9e6c94d2beabb7189bfc738.0✨ Test out this PR locally via:
npm install @theme-ui/color-modes@0.11.0-canary.1862.0fb581dc03f7a88fd9e6c94d2beabb7189bfc738.0 npm install @theme-ui/color@0.11.0-canary.1862.0fb581dc03f7a88fd9e6c94d2beabb7189bfc738.0 npm install @theme-ui/components@0.11.0-canary.1862.0fb581dc03f7a88fd9e6c94d2beabb7189bfc738.0 npm install @theme-ui/core@0.11.0-canary.1862.0fb581dc03f7a88fd9e6c94d2beabb7189bfc738.0 npm install @theme-ui/css@0.11.0-canary.1862.0fb581dc03f7a88fd9e6c94d2beabb7189bfc738.0 npm install @theme-ui/custom-properties@0.11.0-canary.1862.0fb581dc03f7a88fd9e6c94d2beabb7189bfc738.0 npm install @theme-ui/editor@0.11.0-canary.1862.0fb581dc03f7a88fd9e6c94d2beabb7189bfc738.0 npm install gatsby-plugin-theme-ui@0.11.0-canary.1862.0fb581dc03f7a88fd9e6c94d2beabb7189bfc738.0 npm install gatsby-theme-style-guide@0.11.0-canary.1862.0fb581dc03f7a88fd9e6c94d2beabb7189bfc738.0 npm install gatsby-theme-ui-layout@0.11.0-canary.1862.0fb581dc03f7a88fd9e6c94d2beabb7189bfc738.0 npm install @theme-ui/match-media@0.11.0-canary.1862.0fb581dc03f7a88fd9e6c94d2beabb7189bfc738.0 npm install @theme-ui/mdx@0.11.0-canary.1862.0fb581dc03f7a88fd9e6c94d2beabb7189bfc738.0 npm install @theme-ui/parse-props@0.11.0-canary.1862.0fb581dc03f7a88fd9e6c94d2beabb7189bfc738.0 npm install @theme-ui/preset-base@0.11.0-canary.1862.0fb581dc03f7a88fd9e6c94d2beabb7189bfc738.0 npm install @theme-ui/preset-bootstrap@0.11.0-canary.1862.0fb581dc03f7a88fd9e6c94d2beabb7189bfc738.0 npm install @theme-ui/preset-bulma@0.11.0-canary.1862.0fb581dc03f7a88fd9e6c94d2beabb7189bfc738.0 npm install @theme-ui/preset-dark@0.11.0-canary.1862.0fb581dc03f7a88fd9e6c94d2beabb7189bfc738.0 npm install @theme-ui/preset-deep@0.11.0-canary.1862.0fb581dc03f7a88fd9e6c94d2beabb7189bfc738.0 npm install @theme-ui/preset-funk@0.11.0-canary.1862.0fb581dc03f7a88fd9e6c94d2beabb7189bfc738.0 npm install @theme-ui/preset-future@0.11.0-canary.1862.0fb581dc03f7a88fd9e6c94d2beabb7189bfc738.0 npm install @theme-ui/preset-polaris@0.11.0-canary.1862.0fb581dc03f7a88fd9e6c94d2beabb7189bfc738.0 npm install @theme-ui/preset-roboto@0.11.0-canary.1862.0fb581dc03f7a88fd9e6c94d2beabb7189bfc738.0 npm install @theme-ui/preset-sketchy@0.11.0-canary.1862.0fb581dc03f7a88fd9e6c94d2beabb7189bfc738.0 npm install @theme-ui/preset-swiss@0.11.0-canary.1862.0fb581dc03f7a88fd9e6c94d2beabb7189bfc738.0 npm install @theme-ui/preset-system@0.11.0-canary.1862.0fb581dc03f7a88fd9e6c94d2beabb7189bfc738.0 npm install @theme-ui/preset-tailwind@0.11.0-canary.1862.0fb581dc03f7a88fd9e6c94d2beabb7189bfc738.0 npm install @theme-ui/preset-tosh@0.11.0-canary.1862.0fb581dc03f7a88fd9e6c94d2beabb7189bfc738.0 npm install @theme-ui/presets@0.11.0-canary.1862.0fb581dc03f7a88fd9e6c94d2beabb7189bfc738.0 npm install @theme-ui/prism@0.11.0-canary.1862.0fb581dc03f7a88fd9e6c94d2beabb7189bfc738.0 npm install @theme-ui/sidenav@0.11.0-canary.1862.0fb581dc03f7a88fd9e6c94d2beabb7189bfc738.0 npm install @theme-ui/style-guide@0.11.0-canary.1862.0fb581dc03f7a88fd9e6c94d2beabb7189bfc738.0 npm install @theme-ui/tachyons@0.11.0-canary.1862.0fb581dc03f7a88fd9e6c94d2beabb7189bfc738.0 npm install @theme-ui/tailwind@0.11.0-canary.1862.0fb581dc03f7a88fd9e6c94d2beabb7189bfc738.0 npm install @theme-ui/theme-provider@0.11.0-canary.1862.0fb581dc03f7a88fd9e6c94d2beabb7189bfc738.0 npm install theme-ui@0.11.0-canary.1862.0fb581dc03f7a88fd9e6c94d2beabb7189bfc738.0 npm install @theme-ui/typography@0.11.0-canary.1862.0fb581dc03f7a88fd9e6c94d2beabb7189bfc738.0 # or yarn add @theme-ui/color-modes@0.11.0-canary.1862.0fb581dc03f7a88fd9e6c94d2beabb7189bfc738.0 yarn add @theme-ui/color@0.11.0-canary.1862.0fb581dc03f7a88fd9e6c94d2beabb7189bfc738.0 yarn add @theme-ui/components@0.11.0-canary.1862.0fb581dc03f7a88fd9e6c94d2beabb7189bfc738.0 yarn add @theme-ui/core@0.11.0-canary.1862.0fb581dc03f7a88fd9e6c94d2beabb7189bfc738.0 yarn add @theme-ui/css@0.11.0-canary.1862.0fb581dc03f7a88fd9e6c94d2beabb7189bfc738.0 yarn add @theme-ui/custom-properties@0.11.0-canary.1862.0fb581dc03f7a88fd9e6c94d2beabb7189bfc738.0 yarn add @theme-ui/editor@0.11.0-canary.1862.0fb581dc03f7a88fd9e6c94d2beabb7189bfc738.0 yarn add gatsby-plugin-theme-ui@0.11.0-canary.1862.0fb581dc03f7a88fd9e6c94d2beabb7189bfc738.0 yarn add gatsby-theme-style-guide@0.11.0-canary.1862.0fb581dc03f7a88fd9e6c94d2beabb7189bfc738.0 yarn add gatsby-theme-ui-layout@0.11.0-canary.1862.0fb581dc03f7a88fd9e6c94d2beabb7189bfc738.0 yarn add @theme-ui/match-media@0.11.0-canary.1862.0fb581dc03f7a88fd9e6c94d2beabb7189bfc738.0 yarn add @theme-ui/mdx@0.11.0-canary.1862.0fb581dc03f7a88fd9e6c94d2beabb7189bfc738.0 yarn add @theme-ui/parse-props@0.11.0-canary.1862.0fb581dc03f7a88fd9e6c94d2beabb7189bfc738.0 yarn add @theme-ui/preset-base@0.11.0-canary.1862.0fb581dc03f7a88fd9e6c94d2beabb7189bfc738.0 yarn add @theme-ui/preset-bootstrap@0.11.0-canary.1862.0fb581dc03f7a88fd9e6c94d2beabb7189bfc738.0 yarn add @theme-ui/preset-bulma@0.11.0-canary.1862.0fb581dc03f7a88fd9e6c94d2beabb7189bfc738.0 yarn add @theme-ui/preset-dark@0.11.0-canary.1862.0fb581dc03f7a88fd9e6c94d2beabb7189bfc738.0 yarn add @theme-ui/preset-deep@0.11.0-canary.1862.0fb581dc03f7a88fd9e6c94d2beabb7189bfc738.0 yarn add @theme-ui/preset-funk@0.11.0-canary.1862.0fb581dc03f7a88fd9e6c94d2beabb7189bfc738.0 yarn add @theme-ui/preset-future@0.11.0-canary.1862.0fb581dc03f7a88fd9e6c94d2beabb7189bfc738.0 yarn add @theme-ui/preset-polaris@0.11.0-canary.1862.0fb581dc03f7a88fd9e6c94d2beabb7189bfc738.0 yarn add @theme-ui/preset-roboto@0.11.0-canary.1862.0fb581dc03f7a88fd9e6c94d2beabb7189bfc738.0 yarn add @theme-ui/preset-sketchy@0.11.0-canary.1862.0fb581dc03f7a88fd9e6c94d2beabb7189bfc738.0 yarn add @theme-ui/preset-swiss@0.11.0-canary.1862.0fb581dc03f7a88fd9e6c94d2beabb7189bfc738.0 yarn add @theme-ui/preset-system@0.11.0-canary.1862.0fb581dc03f7a88fd9e6c94d2beabb7189bfc738.0 yarn add @theme-ui/preset-tailwind@0.11.0-canary.1862.0fb581dc03f7a88fd9e6c94d2beabb7189bfc738.0 yarn add @theme-ui/preset-tosh@0.11.0-canary.1862.0fb581dc03f7a88fd9e6c94d2beabb7189bfc738.0 yarn add @theme-ui/presets@0.11.0-canary.1862.0fb581dc03f7a88fd9e6c94d2beabb7189bfc738.0 yarn add @theme-ui/prism@0.11.0-canary.1862.0fb581dc03f7a88fd9e6c94d2beabb7189bfc738.0 yarn add @theme-ui/sidenav@0.11.0-canary.1862.0fb581dc03f7a88fd9e6c94d2beabb7189bfc738.0 yarn add @theme-ui/style-guide@0.11.0-canary.1862.0fb581dc03f7a88fd9e6c94d2beabb7189bfc738.0 yarn add @theme-ui/tachyons@0.11.0-canary.1862.0fb581dc03f7a88fd9e6c94d2beabb7189bfc738.0 yarn add @theme-ui/tailwind@0.11.0-canary.1862.0fb581dc03f7a88fd9e6c94d2beabb7189bfc738.0 yarn add @theme-ui/theme-provider@0.11.0-canary.1862.0fb581dc03f7a88fd9e6c94d2beabb7189bfc738.0 yarn add theme-ui@0.11.0-canary.1862.0fb581dc03f7a88fd9e6c94d2beabb7189bfc738.0 yarn add @theme-ui/typography@0.11.0-canary.1862.0fb581dc03f7a88fd9e6c94d2beabb7189bfc738.0Version
Published prerelease version:
v0.11.0-develop.2Changelog
🎉 This release contains work from new contributors! 🎉
Thanks for all your work!
❤️ Torne Wuff (@tornewuff)
❤️ Jordie Bodlay (@jordie23)
Release Notes
Add @theme-ui/css/utils with TypeScript CIF functions and fix preset types (#1862)
makeTheme,makeStylesandmakeColorsScalewhich can be imported from @theme-ui/css/utils.🚀 Enhancement
@theme-ui/color,@theme-ui/css,@theme-ui/preset-base,@theme-ui/preset-bootstrap,@theme-ui/preset-bulma,@theme-ui/preset-dark,@theme-ui/preset-deep,@theme-ui/preset-funk,@theme-ui/preset-future,@theme-ui/preset-polaris,@theme-ui/preset-roboto,@theme-ui/preset-sketchy,@theme-ui/preset-swiss,@theme-ui/preset-system,@theme-ui/preset-tailwind,@theme-ui/preset-tosh,@theme-ui/presets@theme-ui/color-modes,@theme-ui/core,@theme-ui/editor,@theme-ui/theme-provider,theme-ui🐛 Bug Fix
@theme-ui/core,@theme-ui/css@theme-ui/color-modes,@theme-ui/components,@theme-ui/core,@theme-ui/editor,gatsby-theme-style-guide,gatsby-theme-ui-layout,@theme-ui/match-media,@theme-ui/mdx,@theme-ui/parse-props,@theme-ui/sidenav,@theme-ui/style-guide,@theme-ui/theme-provider,theme-ui🏠 Internal
theme-uiAuthors: 3