Skip to content
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

fix(color-modes): combine colors in nested providers #1838

Merged
merged 11 commits into from
Jul 19, 2021
Merged

Conversation

hasparus
Copy link
Member

@hasparus hasparus commented Jun 19, 2021

Should close #1456.

Updated repro: https://codesandbox.io/s/theme-ui-nested-color-modes-bug-qm0lt?file=/src/index.js.


Okay, as we discovered with @fcisio, this PR needs one more change.

Neted theme providers are not updated after SSR with local storage scenario. This could be fixed either by mutating nested theme provider div custom CSS properties or rerendering with proper color mode after hydration (what would also solve derived colors not refreshing after SSR + localStorage read).

📦 Published PR as canary version: 0.11.0-canary.1838.cb3f895316aec940d67cb30e112b2ba2f67e2190.0

✨ Test out this PR locally via:

npm install @theme-ui/color-modes@0.11.0-canary.1838.cb3f895316aec940d67cb30e112b2ba2f67e2190.0
npm install @theme-ui/color@0.11.0-canary.1838.cb3f895316aec940d67cb30e112b2ba2f67e2190.0
npm install @theme-ui/components@0.11.0-canary.1838.cb3f895316aec940d67cb30e112b2ba2f67e2190.0
npm install @theme-ui/core@0.11.0-canary.1838.cb3f895316aec940d67cb30e112b2ba2f67e2190.0
npm install @theme-ui/css@0.11.0-canary.1838.cb3f895316aec940d67cb30e112b2ba2f67e2190.0
npm install @theme-ui/custom-properties@0.11.0-canary.1838.cb3f895316aec940d67cb30e112b2ba2f67e2190.0
npm install @theme-ui/editor@0.11.0-canary.1838.cb3f895316aec940d67cb30e112b2ba2f67e2190.0
npm install gatsby-plugin-theme-ui@0.11.0-canary.1838.cb3f895316aec940d67cb30e112b2ba2f67e2190.0
npm install gatsby-theme-style-guide@0.11.0-canary.1838.cb3f895316aec940d67cb30e112b2ba2f67e2190.0
npm install gatsby-theme-ui-layout@0.11.0-canary.1838.cb3f895316aec940d67cb30e112b2ba2f67e2190.0
npm install @theme-ui/match-media@0.11.0-canary.1838.cb3f895316aec940d67cb30e112b2ba2f67e2190.0
npm install @theme-ui/mdx@0.11.0-canary.1838.cb3f895316aec940d67cb30e112b2ba2f67e2190.0
npm install @theme-ui/parse-props@0.11.0-canary.1838.cb3f895316aec940d67cb30e112b2ba2f67e2190.0
npm install @theme-ui/preset-base@0.11.0-canary.1838.cb3f895316aec940d67cb30e112b2ba2f67e2190.0
npm install @theme-ui/preset-bootstrap@0.11.0-canary.1838.cb3f895316aec940d67cb30e112b2ba2f67e2190.0
npm install @theme-ui/preset-bulma@0.11.0-canary.1838.cb3f895316aec940d67cb30e112b2ba2f67e2190.0
npm install @theme-ui/preset-dark@0.11.0-canary.1838.cb3f895316aec940d67cb30e112b2ba2f67e2190.0
npm install @theme-ui/preset-deep@0.11.0-canary.1838.cb3f895316aec940d67cb30e112b2ba2f67e2190.0
npm install @theme-ui/preset-funk@0.11.0-canary.1838.cb3f895316aec940d67cb30e112b2ba2f67e2190.0
npm install @theme-ui/preset-future@0.11.0-canary.1838.cb3f895316aec940d67cb30e112b2ba2f67e2190.0
npm install @theme-ui/preset-polaris@0.11.0-canary.1838.cb3f895316aec940d67cb30e112b2ba2f67e2190.0
npm install @theme-ui/preset-roboto@0.11.0-canary.1838.cb3f895316aec940d67cb30e112b2ba2f67e2190.0
npm install @theme-ui/preset-sketchy@0.11.0-canary.1838.cb3f895316aec940d67cb30e112b2ba2f67e2190.0
npm install @theme-ui/preset-swiss@0.11.0-canary.1838.cb3f895316aec940d67cb30e112b2ba2f67e2190.0
npm install @theme-ui/preset-system@0.11.0-canary.1838.cb3f895316aec940d67cb30e112b2ba2f67e2190.0
npm install @theme-ui/preset-tailwind@0.11.0-canary.1838.cb3f895316aec940d67cb30e112b2ba2f67e2190.0
npm install @theme-ui/preset-tosh@0.11.0-canary.1838.cb3f895316aec940d67cb30e112b2ba2f67e2190.0
npm install @theme-ui/presets@0.11.0-canary.1838.cb3f895316aec940d67cb30e112b2ba2f67e2190.0
npm install @theme-ui/prism@0.11.0-canary.1838.cb3f895316aec940d67cb30e112b2ba2f67e2190.0
npm install @theme-ui/sidenav@0.11.0-canary.1838.cb3f895316aec940d67cb30e112b2ba2f67e2190.0
npm install @theme-ui/style-guide@0.11.0-canary.1838.cb3f895316aec940d67cb30e112b2ba2f67e2190.0
npm install @theme-ui/tachyons@0.11.0-canary.1838.cb3f895316aec940d67cb30e112b2ba2f67e2190.0
npm install @theme-ui/tailwind@0.11.0-canary.1838.cb3f895316aec940d67cb30e112b2ba2f67e2190.0
npm install @theme-ui/theme-provider@0.11.0-canary.1838.cb3f895316aec940d67cb30e112b2ba2f67e2190.0
npm install theme-ui@0.11.0-canary.1838.cb3f895316aec940d67cb30e112b2ba2f67e2190.0
npm install @theme-ui/typography@0.11.0-canary.1838.cb3f895316aec940d67cb30e112b2ba2f67e2190.0
# or 
yarn add @theme-ui/color-modes@0.11.0-canary.1838.cb3f895316aec940d67cb30e112b2ba2f67e2190.0
yarn add @theme-ui/color@0.11.0-canary.1838.cb3f895316aec940d67cb30e112b2ba2f67e2190.0
yarn add @theme-ui/components@0.11.0-canary.1838.cb3f895316aec940d67cb30e112b2ba2f67e2190.0
yarn add @theme-ui/core@0.11.0-canary.1838.cb3f895316aec940d67cb30e112b2ba2f67e2190.0
yarn add @theme-ui/css@0.11.0-canary.1838.cb3f895316aec940d67cb30e112b2ba2f67e2190.0
yarn add @theme-ui/custom-properties@0.11.0-canary.1838.cb3f895316aec940d67cb30e112b2ba2f67e2190.0
yarn add @theme-ui/editor@0.11.0-canary.1838.cb3f895316aec940d67cb30e112b2ba2f67e2190.0
yarn add gatsby-plugin-theme-ui@0.11.0-canary.1838.cb3f895316aec940d67cb30e112b2ba2f67e2190.0
yarn add gatsby-theme-style-guide@0.11.0-canary.1838.cb3f895316aec940d67cb30e112b2ba2f67e2190.0
yarn add gatsby-theme-ui-layout@0.11.0-canary.1838.cb3f895316aec940d67cb30e112b2ba2f67e2190.0
yarn add @theme-ui/match-media@0.11.0-canary.1838.cb3f895316aec940d67cb30e112b2ba2f67e2190.0
yarn add @theme-ui/mdx@0.11.0-canary.1838.cb3f895316aec940d67cb30e112b2ba2f67e2190.0
yarn add @theme-ui/parse-props@0.11.0-canary.1838.cb3f895316aec940d67cb30e112b2ba2f67e2190.0
yarn add @theme-ui/preset-base@0.11.0-canary.1838.cb3f895316aec940d67cb30e112b2ba2f67e2190.0
yarn add @theme-ui/preset-bootstrap@0.11.0-canary.1838.cb3f895316aec940d67cb30e112b2ba2f67e2190.0
yarn add @theme-ui/preset-bulma@0.11.0-canary.1838.cb3f895316aec940d67cb30e112b2ba2f67e2190.0
yarn add @theme-ui/preset-dark@0.11.0-canary.1838.cb3f895316aec940d67cb30e112b2ba2f67e2190.0
yarn add @theme-ui/preset-deep@0.11.0-canary.1838.cb3f895316aec940d67cb30e112b2ba2f67e2190.0
yarn add @theme-ui/preset-funk@0.11.0-canary.1838.cb3f895316aec940d67cb30e112b2ba2f67e2190.0
yarn add @theme-ui/preset-future@0.11.0-canary.1838.cb3f895316aec940d67cb30e112b2ba2f67e2190.0
yarn add @theme-ui/preset-polaris@0.11.0-canary.1838.cb3f895316aec940d67cb30e112b2ba2f67e2190.0
yarn add @theme-ui/preset-roboto@0.11.0-canary.1838.cb3f895316aec940d67cb30e112b2ba2f67e2190.0
yarn add @theme-ui/preset-sketchy@0.11.0-canary.1838.cb3f895316aec940d67cb30e112b2ba2f67e2190.0
yarn add @theme-ui/preset-swiss@0.11.0-canary.1838.cb3f895316aec940d67cb30e112b2ba2f67e2190.0
yarn add @theme-ui/preset-system@0.11.0-canary.1838.cb3f895316aec940d67cb30e112b2ba2f67e2190.0
yarn add @theme-ui/preset-tailwind@0.11.0-canary.1838.cb3f895316aec940d67cb30e112b2ba2f67e2190.0
yarn add @theme-ui/preset-tosh@0.11.0-canary.1838.cb3f895316aec940d67cb30e112b2ba2f67e2190.0
yarn add @theme-ui/presets@0.11.0-canary.1838.cb3f895316aec940d67cb30e112b2ba2f67e2190.0
yarn add @theme-ui/prism@0.11.0-canary.1838.cb3f895316aec940d67cb30e112b2ba2f67e2190.0
yarn add @theme-ui/sidenav@0.11.0-canary.1838.cb3f895316aec940d67cb30e112b2ba2f67e2190.0
yarn add @theme-ui/style-guide@0.11.0-canary.1838.cb3f895316aec940d67cb30e112b2ba2f67e2190.0
yarn add @theme-ui/tachyons@0.11.0-canary.1838.cb3f895316aec940d67cb30e112b2ba2f67e2190.0
yarn add @theme-ui/tailwind@0.11.0-canary.1838.cb3f895316aec940d67cb30e112b2ba2f67e2190.0
yarn add @theme-ui/theme-provider@0.11.0-canary.1838.cb3f895316aec940d67cb30e112b2ba2f67e2190.0
yarn add theme-ui@0.11.0-canary.1838.cb3f895316aec940d67cb30e112b2ba2f67e2190.0
yarn add @theme-ui/typography@0.11.0-canary.1838.cb3f895316aec940d67cb30e112b2ba2f67e2190.0

Version

Published prerelease version: v0.11.0-develop.0

Changelog

🎉 This release contains work from a new contributor! 🎉

Thank you, null@jordie23, for all your work!

🚀 Enhancement

  • @theme-ui/color-modes, @theme-ui/core, @theme-ui/editor, @theme-ui/theme-provider, theme-ui
    • fix(color-modes): combine colors in nested providers #1838 (@hasparus)

🐛 Bug Fix

  • Update global-styles.mdx #1858 (@jordie23)
  • @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

Authors: 2

hasparus added 6 commits June 10, 2021 16:36

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
@vercel
Copy link

vercel bot commented Jun 19, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/systemui/theme-ui/4WMhRKkksBBLWRqEdXrAAjZtpUm8
✅ Preview: https://theme-ui-git-nested-providers-systemui.vercel.app

@hasparus
Copy link
Member Author

Hey @fcisio, I got it to work :)

@hasparus hasparus added the minor Increment the minor version when merged label Jul 19, 2021
@hasparus hasparus merged commit 27424d6 into develop Jul 19, 2021
@hasparus hasparus deleted the nested-providers branch July 19, 2021 17:16
@hasparus hasparus added the prerelease This change is available in a prerelease. label Jul 19, 2021
@hasparus
Copy link
Member Author

🚀 PR was released in v0.11.0 🚀

@hasparus hasparus added released This issue/pull request has been released. and removed prerelease This change is available in a prerelease. labels Aug 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
minor Increment the minor version when merged released This issue/pull request has been released.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

sx prop does not correctly apply theme in nested ThemeProviders with ColorMode
2 participants