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

Add color modes to theming API #1112

Merged
merged 50 commits into from
Mar 24, 2021
Merged

Add color modes to theming API #1112

merged 50 commits into from
Mar 24, 2021

Conversation

colebemis
Copy link
Contributor

@colebemis colebemis commented Mar 6, 2021

Problem

Primer React doesn't provide an easy way for consumers to change color modes in their applications.

Solution

This PR updates the Primer React theming API to provide first-class support for color modes.

👉 Click here to review the new theming documentation

Impact

Primer React consumers can now easily change color modes in their applications using the new ThemeProvider component.

Breaking changes

You'll need to replace the ThemeProvider from styled-components with the new Primer React ThemeProvider:

- import {ThemeProvider} from 'styled-components'
- import {theme} from '@primer/components
+ import {ThemeProvider} from '@primer/components'

function App() {
  return (
-   <ThemeProvider theme={theme}>
+   <ThemeProvider>
      <div>your app here...</div>
    </ThemeProvider>
  )
}

Also, if you're customizing the theme, note that the structure of the theme object has changed to support color schemes:

const theme = {
- colors,
- shadows,
+ colorSchemes: {
+   light: {
+     colors,
+     shadows,
+   },
+   dark: {...},
+   dark_dimmed: {...},
+ },
  space,
  fonts,
  fontSizes,
  fontWeights,
  lineHeights,
  borderWidths,
  radii,
  breakpoints,
  sizes,
}

cc @bscofield

@changeset-bot
Copy link

changeset-bot bot commented Mar 6, 2021

🦋 Changeset detected

Latest commit: 3fc66b3

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@primer/components Major

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel
Copy link

vercel bot commented Mar 6, 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/primer/primer-components/5TW2ViTVYiuPcWWZnduiThSUdwrt
✅ Preview: https://primer-components-git-update-theming-api-primer.vercel.app

Copy link

@emplums emplums left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made a few suggestions! One question I had that I don't think is covered by the docs - out of the box does the color scheme change at all depending on what OS color mode the user is in? Should we call out somewhere that PRC will only render in light mode unless you explicitly set up a switching mechanism using the useColorScheme prop?

docs/content/getting-started.md Outdated Show resolved Hide resolved
docs/content/getting-started.md Outdated Show resolved Hide resolved
docs/content/theming.md Show resolved Hide resolved
docs/content/theming.md Outdated Show resolved Hide resolved
docs/content/theming.md Outdated Show resolved Hide resolved
@emplums
Copy link

emplums commented Mar 11, 2021

One more suggestion: should we add a glossary of terms at the top of the theme docs? 😂

@vercel vercel bot temporarily deployed to Preview March 19, 2021 22:46 Inactive
@colebemis colebemis requested a review from emplums March 19, 2021 22:47
@colebemis colebemis marked this pull request as ready for review March 19, 2021 22:47
…b.com:primer/components into update-theming-api
@vercel vercel bot temporarily deployed to Preview March 19, 2021 22:55 Inactive
@colebemis colebemis dismissed emplums’s stale review March 19, 2021 22:55

Addressed feedback

@colebemis colebemis requested a review from jonrohan March 23, 2021 18:23
@vercel vercel bot temporarily deployed to Preview March 23, 2021 20:40 Inactive
docs/content/theming.md Outdated Show resolved Hide resolved
@vercel vercel bot temporarily deployed to Preview March 23, 2021 20:53 Inactive
docs/content/theming.md Outdated Show resolved Hide resolved
Copy link

@bscofield bscofield left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left one typo, but otherwise this looks great 🎉

Co-authored-by: Ben Scofield <bscofield@github.com>
@vercel vercel bot temporarily deployed to Preview March 24, 2021 14:33 Inactive
@vercel vercel bot temporarily deployed to Preview March 24, 2021 15:02 Inactive
src/ThemeProvider.tsx Outdated Show resolved Hide resolved
@vercel vercel bot temporarily deployed to Preview March 24, 2021 15:09 Inactive
@vercel vercel bot temporarily deployed to Preview March 24, 2021 15:12 Inactive
@colebemis colebemis merged commit c25d28b into main Mar 24, 2021
@colebemis colebemis deleted the update-theming-api branch March 24, 2021 15:16
@github-actions github-actions bot mentioned this pull request Mar 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants