Since we're working on a complete rebrand, we're also creating all of our CSS from scratch. While we could have reused some of the existing styles, most of them didn't rely on variables, and had multiple implementations of the same things, so this change will allow us to achieve consistency much more effectively.
At the very core of our design system are clearly defined values - a set of base colours, spacers, font sizes, breakpoints, border radii, and box shadows. These are defined at the very top of stylesheets/design
. Every value that's used outside of this section should ultimately refer back to these in some fashion, unless it is very specifically and explicitly a hardcoded exception. This will allow us to easily change these values and have them immediately take effect across the entire project, and also give us theming basically for free - all a theme needs to do is change the values of those base colours, and everything else will automatically fall in line.
These values are then used by clearly defined components. Most of the elements on our pages, unless they truly are nothing more than generic containers setting some spacing, should refer back to one of our predefined components. This not only makes it easier to reuse, but it again allows us to make changes globally and consistently without having to find and touch all the specific places a component is used in.
Most of the components you're going to need should already be defined. If something seems to be missing, check with Maya and/or Jack first - there might be one of our existing components that already covers this use case, or should be adapted to match. If something is truly missing from the component gallery, we’ll want to add it there instead of doing something page-specific. For consistency, here are the principles that were used when writing them so far - and if you see something that you feel does not conform to these in the existing components, please fix it!
button
should mean that we want want all of our buttons to have that style.
This goes both ways - if the style you’re looking to add is in any way specific to a set of circumstances, look for a more specific selector.
On the other hand, don't fear exceptions. Yes, something at some point may need to be a button
for accessibility or JS reasons while having different styles, but the selector should still be modeled after the design intent.button
s in a certain context look the same, then write it that way and account for exceptions later.
Note: div and span are not semantic elements. You never want to select by them.display
, and relative units such as currentColor
, em
, and %
.
When referring to a value, again think about intent - if the usage is truly specific to the current component, feel free to just write spacer(4)
or similar. In many cases though, there'll be some reasoning for using a value a certain way (example: $form-element-padding-x
). Where applicable, create an intermediary variable named after the intent, and ensure it is used in all relevant places.display
and related properties) are more layout than they are style, so keeping them in HTML makes sense.
I know using inline CSS sounds sacrilegious, and using utility clases to avoid it is common practice - but utility classes really just allow you to write inline CSS while being able to say "well technically this is a class, not inline CSS."
Our base values are all available as CSS variables (example: var(--spacer-4)
), and you should make use of them in that context, as well to ensure consistency.
Only use inline CSS for non-reusable styles. If what you're writing is in any way a part of a reusable component or pattern, it should be a class rather than inline.This section outlines the process of how to pick up, write and ship the migration of a page to the new design system.
If there are any problems with the migration, such as missing/incomplete components in the new system, or unresolvable incompatibilities between the old and new design systems, feel free to ask for help in the #rebrand channel.
deploy-
branch for your migration, open up the page in question, then enable the design_system
Rollout flag. Refresh the page and you'll likely be faced with a lot of broken/missing CSS. Some parts will work out of the box, as the new design automatically styles certain semantic HTML elements, and includes some temporary legacy styles for JS classes such as soft-hidden
.design/_legacy.scss
- that file contains styles that we'll look to remove as soon as we can. Example: Styles for jQuery libraries.design_system
Rollout flag on the branch app, create a PR, assign it to Maya and Jack for review, and reward yourself with a cookie (or another snack of your choice), because you deserve it.Right now, we're leaving all existing classes and image assets behind, as we need the existing design to continue functioning until we've migrated over all pages and switched them over in production.
Once we're ready to leave behind the old CSS and clean it up, we'll need to: