-
Notifications
You must be signed in to change notification settings - Fork 2
Generate CSS/SCSS files for typography, palette, breakpoints #2195
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
base: main
Are you sure you want to change the base?
Conversation
🦋 Changeset detectedLatest commit: 0a23ecf The changes in this PR will be included in the next version bump. 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 |
|
Tip Once this PR is ready to go, add the This saves us a lot of money by not running the tests before we need them. |
|
🐥 |
Co-Authored-By: Edward Gargan <[email protected]>
6a4e75f to
0a23ecf
Compare
|
Note The following canaries were published to NPM: 🐥 |
|
🐥 |
|
🐥 |
Note
All credit to @egargan who did the actual work in the original PR. We needed to make a copy as Canaries releases (understandably) don't work on forks
What are you changing?
These changes add three new generated files under
foundations/__generated__.typography.cssfile containing plain CSS classes for each typography presetpalette.cssfile containing CSS variable declarations for each palette colourbreakpoints.scssfile exporting Source's breakpoints as a$breakpointsvariableThree new custom Cobalt plugins were added to generate these files. Each was adapted from the existing plugins that generate the existing TypeScript files already under
__generated__.New folders were added to
cobalt-pluginsto help with organisation, now that we have multiple plugins for breakpoints, palette, and typography.To be decided
exportpaths inpackage.json?--srcprefix before classes and variable names? A prefix is important but it should be as brief as possibleFurther work
One potential issue: adding typography class names to all of your text elements could get repetitive and bloat-y.
We could either define a mixin (something like
@src-typog("article17")), or, more straightforward, export the typography classes as an SCSS file, so they can be imported and used in@extendrules.Why?
The design tokens exported by this package are unusable without using a CSS-in-JS framework like Emotion.
I work for the visuals team in editorial. We primarily use Svelte to build our visual projects, a tool which Emotion does not work well with. So we rely on hardcoded stylesheets that copy Source's tokens (such as these), but of course, this is not a sustainable solution.
These changes aim to make Source's design tokens as accessible as possible by exporting them as vanilla CSS (with a bit of SCSS too).
This builds on the experimental work that produces the existing
variables.cssfile.What does this look like in consuming projects?
Here's an example bit of Svelte (almost identical to HTML save the
lang="scss"), assuming the stylesheets have been imported in the appropriate place.See also
In a similar vein, the visuals team has also been developing a CSS-only version of Source's component library. See guardian/interactive-source-components.