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

CSS Library: Migrate VA styles from Formation #1124

Merged
merged 30 commits into from
May 8, 2024

Conversation

jamigibbs
Copy link
Contributor

@jamigibbs jamigibbs commented Apr 18, 2024

Chromatic

https://2537-formation-styles-to-css-library--65a6e2ed2314f7b8f98609d8.chromatic.com

Description

What is this PR doing?

  • Moves necessary Formation files into CSS Library. Reference this import mapping spreadsheet.
    • Many of these files and code blocks should be replaced by USWDS style imports or web components.
  • Updated anywhere that node-sass functionality was being used for dart-sass compatibility
  • Updated tokens in those stylesheets to semantic tokens (if available)
  • Added fonts and image assets
    • Some font files may still be missing but those files should just need to be dropped into the fonts folder.
  • The build script is updated to generate assets

What has not been added from Formation?

The CSS Library already offers utilities and tokens that we will want to use instead of porting over the old stuff:

  • grid
  • utilities
  • breakpoints
  • font awesome

What's next after this PR is merged?

  • Swapping Formation links for CSS Library so that we can migrate off of the Formation package.
  • Replace styles with USWDS imports or web components and start deleting some of this stuff.
  • Organization! This is just a mapping from Formation but as we remove a lot of these files with the USWDS v3 migration, we should re-organize the CSS Library

related department-of-veterans-affairs/vets-design-system-documentation#2537
closes department-of-veterans-affairs/vets-design-system-documentation#2768

Acceptance criteria

  • QA checklist has been completed
  • Screenshots have been attached that cover desktop and mobile screens

Definition of done

  • Documentation has been updated, if applicable
  • A link has been provided to the originating GitHub issue (or connected to it via ZenHub)

Copy link
Contributor Author

@jamigibbs jamigibbs Apr 23, 2024

Choose a reason for hiding this comment

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

I've added the Bitter font files (from Formation) here which will copy over into dist/fonts.

I have also loaded USWDS v3 @font-face font imports which loads the font face for and references the font files in the USWDS package for these:

  • Roboto Mono Web
  • Source Sans Pro Web
  • Merriweather Web

@use 'uswds-core' with (
$theme-show-notifications: false,
// TODO: verify USWDS font path
$theme-font-path: '../node_modules/@uswds/uswds/dist/fonts',
);

The problem though is that they have added "Web" to all of these font names so at some point we will need to update wherever "Source Sans Pro" is referenced to "Source Sans Pro Web". The same with "Merriweather" to "Merriweather Web", etc.

@@ -11,15 +11,19 @@
"build:tokens": "style-dictionary build",
"build:stylesheets": "sass --load-path=../../node_modules/@uswds/uswds/packages/ src/stylesheets:dist/",
"build:minify": "yarn build:stylesheets --style compressed --no-source-map",
"build": "yarn run copy && yarn build:tokens && yarn build:minify",
"copy": "node ./copy-uswds-color-tokens.js"
"build:minify-core": "sass --style compressed --no-source-map dist/core.css:dist/core.min.css",
Copy link
Contributor Author

@jamigibbs jamigibbs Apr 23, 2024

Choose a reason for hiding this comment

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

The build:minify-core script isn't being used right now but I'm going to leave it here as a working example of how we could generate minified stylesheet(s) if necessary.

Copy link
Contributor Author

@jamigibbs jamigibbs Apr 23, 2024

Choose a reason for hiding this comment

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

I have added just the images from Formation that were being referenced in the stylesheets that were moved over so they would still work. They will be copied over to dist/img.

But I expect that we wouldn't actually need any of these images in the CSS Library eventually. All necessary images would instead be coming from component-library or USWDS directly.

@@ -0,0 +1,434 @@
//============ PORTED MIXINS FROM FORMATION ==============//
Copy link
Contributor Author

@jamigibbs jamigibbs Apr 23, 2024

Choose a reason for hiding this comment

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

There is zero organization for the mixins in this file because I don't expect any of these to survive the Formation culling. I just moved over whatever mixins were necessary to keep the ported stylesheets working.

@@ -0,0 +1,159 @@
@use 'sass:math';
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I had to make some modifications to this file in order for it to work with dart-sass but I expect that this will also eventually go away as we remove stylesheets.

@@ -0,0 +1,189 @@
// This file is a place where you put all the code you're not proud of,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Screenshot 2024-04-23 at 2 49 51 PM

- Source Sans Pro Web
- Merriweather Web
*/
@use "uswds-fonts";
Copy link
Contributor Author

@jamigibbs jamigibbs Apr 23, 2024

Choose a reason for hiding this comment

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

This will add @font-face imports for Roboto Mono Web, Source Sans Pro Web, and Merriweather Web from the USWDS v3 package. They all include "Web" in the name though which is different from v1.

@@ -0,0 +1,374 @@
@import '../override-function';

@import 'uswds-core/src/styles/mixins/typography/usa-content-styles';
Copy link
Contributor Author

@jamigibbs jamigibbs Apr 23, 2024

Choose a reason for hiding this comment

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

This stylesheet is the same as elements.scss.

This file is the "16px root font" version and elements.scss is the "10px root font" version. The elements.scss file is being used in the component-library currently.

Copy link
Contributor

Choose a reason for hiding this comment

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

Is this file actually using 16px as its root font size? I see font-size: $em-base below on line 14, and saw that variable being set in /formation-overrides/_variables.scss as 10px.

Copy link
Contributor

Choose a reason for hiding this comment

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

lol ignore me, I just remembered we're setting font-size on the body directly on line 23.

Copy link
Contributor Author

@jamigibbs jamigibbs Apr 23, 2024

Choose a reason for hiding this comment

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

Moved this fonts stylesheet to /stylesheets/base/_b-font-faces.scss to mirror the Formation name and structure.

$h5-font-size: scale-rem(1.5rem);

$color-black-light: #212121;
$color-base: $color-black-light;
Copy link
Contributor Author

@jamigibbs jamigibbs Apr 23, 2024

Choose a reason for hiding this comment

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

All of the tokens in this stylesheet are "imposter tokens". They are only here so that the ported stylesheets continue to work. These should all go away as we remove things though.

);

$font-path: "./fonts"; // TODO: Verify asset path
$image-path: "./img"; // TODO: Verify asset path
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These asset paths point to where the assets will be in dist/ but when we start connecting stylesheets, this will need to be verified that it's correct.

See: https://github.com/uswds/uswds/blob/98566ec5dc12807a2b0bc36699a033fe3a711d44/packages/uswds-global/_index.scss
*/

@use "uswds-elements/lib/normalize";
Copy link
Contributor Author

@jamigibbs jamigibbs Apr 23, 2024

Choose a reason for hiding this comment

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

I think we can just start using the USWDS v3 Normalize.css import instead of trying to keep using the one from USWDS v1 (which Formation was importing).

But USWDS v1 uses normalize v3.0.3 and USWDS v3 is using v8.0.1

I'm not sure if there will be any significant changes since Normalize just makes browsers render HTML elements more consistently but just something I wanted to call out.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm in favor of moving to V3's normalize.

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree with Andrew. Where impact is minimal, we should try and get onto V3 stuff as we go.

Copy link
Contributor

@micahchiang micahchiang left a comment

Choose a reason for hiding this comment

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

I think this looks good for getting us to a spot where we can cut over from Formation to CSS-Library and begin swapping imports. Exciting!

We'll have to do some digging around the uswds repo as a group, but my hope is that we'll be able to replace a lot of this stuff with direct imports from uswds-core

@import './override-function.scss';

body {
// used a lot in vets-website
Copy link
Contributor

Choose a reason for hiding this comment

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

😭

@@ -0,0 +1,374 @@
@import '../override-function';

@import 'uswds-core/src/styles/mixins/typography/usa-content-styles';
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this file actually using 16px as its root font size? I see font-size: $em-base below on line 14, and saw that variable being set in /formation-overrides/_variables.scss as 10px.

@@ -0,0 +1,374 @@
@import '../override-function';

@import 'uswds-core/src/styles/mixins/typography/usa-content-styles';
Copy link
Contributor

Choose a reason for hiding this comment

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

lol ignore me, I just remembered we're setting font-size on the body directly on line 23.

@jamigibbs jamigibbs merged commit 55f806a into main May 8, 2024
9 checks passed
@jamigibbs jamigibbs deleted the 2537-formation-styles-to-css-library branch May 8, 2024 19:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Formation Deprecation: Review the migrated files in CSS Library
3 participants