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

Refactor: Use CSS Variables for colors, font-family #970

Merged
merged 7 commits into from
Oct 3, 2022

Conversation

machikoyasuda
Copy link
Member

@machikoyasuda machikoyasuda commented Sep 28, 2022

closes #968

  • As much as possible, override root Bootstrap CSS variables to match Figma style guide
  • When a Bootstrap CSS variable is not available, create new CSS variables and use them throughout the code
  • Makes some changes to colors based on new Figma designs

The CSS file should no longer have any un-variable-ized colors and font-family declarations.

How to read this code

How this change works

For example, when overriding --bs-primary with #046b99, like so:

:root {
  --primary-color: #046b99;
  --primary-color-rgb: 4, 107, 153;
  --bs-blue: var(--primary-color);
  --bs-primary: var(--primary-color);
  --bs-primary-rgb: var(--primary-color-rgb);
}

all Bootstrap classes that rely on --bs-primary color will also be affected. Most notably, btn-primary, bg-primary will now all also use #046b99. With just these few CSS variable override lines, I was able to change all instances of the "primary" color to #046b99 throughout the CSS styles. Because of this, I was able to delete places in the style.css code where we were manually setting the Header background color or a Button background color to #046b99, because we are using classes of bg-primary or btn-primary instead.

Caveat: If the CA Web Standard code also sets another override to a --bs variable, then we'll still have to manually override it. An example of this is the body and h1 font declaration: we cannot remove the manual font declaration even though we've set --bs-font-family to Roboto because the CA Web Standard code overrides it to some other font. It is tricky.

How to test this

  • Run the app, none of the colors should be different from Figma designs

Changes

  • Radio button is now #323A45

image

  • Form input is now #046B99

image

  • Header, button primary color is now #046B99, which is different from prod:

image

@machikoyasuda machikoyasuda requested a review from a team as a code owner September 28, 2022 23:27
@github-actions github-actions bot added front-end HTML/CSS/JavaScript and Django templates deployment-dev [auto] Changes that will trigger a deploy if merged to dev back-end Django views, sessions, middleware, models, migrations etc. and removed deployment-dev [auto] Changes that will trigger a deploy if merged to dev labels Sep 28, 2022
@machikoyasuda machikoyasuda self-assigned this Sep 28, 2022
@machikoyasuda machikoyasuda added this to the Courtesy Cards milestone Sep 28, 2022
@machikoyasuda
Copy link
Member Author

Rebased

@machikoyasuda machikoyasuda merged commit 834183e into dev Oct 3, 2022
@machikoyasuda machikoyasuda deleted the refactor/css-vars branch October 3, 2022 16:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
back-end Django views, sessions, middleware, models, migrations etc. front-end HTML/CSS/JavaScript and Django templates
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CSS: Create CSS Variables for colors, fonts
2 participants