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
Deprecate JS theme in favor of CSS custom properties #2158
Conversation
The ESLint and Stylelint plugins don't support ESM yet.
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
🦋 Changeset detectedLatest commit: fa9b751 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
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 |
Codecov Report
@@ Coverage Diff @@
## next #2158 +/- ##
==========================================
+ Coverage 96.86% 97.02% +0.15%
==========================================
Files 260 263 +3
Lines 23682 25063 +1381
Branches 2213 2265 +52
==========================================
+ Hits 22940 24317 +1377
- Misses 734 738 +4
Partials 8 8
|
0f43799
to
55e6bbf
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No vote here, but I left some comments to understand better the whole thing
|
||
```tsx | ||
// _app.tsx | ||
import '@sumup/design-tokens/light.css'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For switching between light and dark, how will that work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure yet. There's still a lot of uncertainty around the dark theme (Will it follow the system settings? Will users be able to set their preferred one? Will this be built into @sumup/design-tokens
or inside each app?), so I consciously left this out of scope. We may need to adjust the API in the future, but that would be a small breaking change.
Relates to #2153.
Purpose
Currently, the design tokens are distributed as a JavaScript object that can be used with CSS-in-JS libraries such as Emotion.js. We want to migrate away from CSS-in-JS to improve performance and compatibility with more frameworks.
CSS custom properties (aka CSS variables) are a natural choice. They're widely supported in modern browsers, can be used with any framework, and are fast to update.
Circuit UI began its migration to CSS custom properties with the introduction of the semantic color tokens (#1880). This pull request converts the remaining theme properties. Unlike the color tokens, the remaining tokens keep their familiar names and structure:
The
theme.breakpoints.*
andtheme.mq.*
properties cannot be migrated because CSS custom properties aren't supported in media queries.The
theme.grid.*
properties haven't been migrated because the grid components are legacy.Approach and changes
schema
and export all design tokens as CSS custom properties as@sumup/design-tokens/light.css
.@sumup/design-tokens
to CJS. The ESLint and Stylelint plugins, which depend on the package, don't support ESM yet.prefer-custom-properties
ESLint rule to flag and automatically rewrite uses of the Emotion.js theme to CSS custom properties.themePropType
, andTheme
interface as deprecated in@sumup/design-tokens
.Definition of done