diff --git a/.gitignore b/.gitignore index f59253fd..75f8e53f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ /dist /build +/packages /node_modules /tmp .DS_Store diff --git a/.stylelintrc.json b/.stylelintrc.json index eb4f9b33..c39bb4d6 100644 --- a/.stylelintrc.json +++ b/.stylelintrc.json @@ -1,4 +1,4 @@ { "extends": "@18f/identity-stylelint-config", - "ignoreFiles": "./src/scss/uswds/**/*" + "ignoreFiles": "./src/scss/uswds-packages/**/*" } diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 850afb38..5bef753a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -15,7 +15,7 @@ If you have any questions or want to read more, check out the [18F Open Source P Since the Login.gov Design System is based upon the [U.S. Web Design System (USWDS)](https://designsystem.digital.gov/), the code should reflect this: - Where possible, use [the available Sass theme variables](https://designsystem.digital.gov/documentation/developers/#customization-theming-and-tokens) to customize the appearance of components. These are configured under `src/scss/uswds-theme`. We only include the customized variables, to improve visibility of where differences are expected. Refer to the [USWDS theme variables source](https://github.com/uswds/uswds/tree/develop/src/stylesheets/theme) for the full set of configuration values. -- To limit side-effects and to clarify where styles are extended, customized USWDS styles should follow as close to the file location and CSS selector as possible. For example, if USWDS defines a selector `.usa-overlay` in `src/stylesheets/components/_header.scss` which defines a style `background` that we want to override, the style should be located at an identically-named selector in `src/scss/components/_header.scss` in this project. +- To limit side-effects and to clarify where styles are extended, customized USWDS styles should follow as close to the file location and CSS selector as possible. For example, if USWDS defines a selector `.usa-header` in `packages/usa-header` which defines a style `background` that we want to override, the style should be located at an identically-named selector in `src/scss/packages/_usa-header.scss` in this project. - Prefer color and size tokens when possible. Never use hard-coded hex colors. Instead, use the `color` SCSS function with a [color token](https://design.login.gov/utilities/color/) as its argument. ## Public domain diff --git a/Makefile b/Makefile index 9dce0ce6..e1c4ae4a 100644 --- a/Makefile +++ b/Makefile @@ -45,7 +45,7 @@ build: build-docs build-assets build-package build-docs: JEKYLL_ENV=production bundle exec jekyll build -build-assets: build-sass-and-js build-fonts build-images copy-scss +build-assets: build-sass-and-js build-fonts build-images copy-scss build-sass-packages build-package: $(NODE_BIN)/gulp build-package @@ -56,6 +56,11 @@ build-sass-and-js: OUTPUT_DIR=$(OUTPUT_DIR) \ $(NODE_BIN)/gulp build +build-sass-packages: + mkdir -p packages + cp -r node_modules/@uswds/uswds/packages/* packages + cp src/scss/packages/* packages + build-fonts: mkdir -p $(OUTPUT_DIR)/assets/fonts cp -r node_modules/@uswds/uswds/dist/fonts $(OUTPUT_DIR)/assets @@ -65,7 +70,11 @@ build-images: cp -r node_modules/@uswds/uswds/dist/img $(OUTPUT_DIR)/assets cp -r src/img $(OUTPUT_DIR)/assets -copy-scss: +copy-uswds-scss: + mkdir -p $(OUTPUT_DIR)/assets/scss/uswds-packages + cp -r node_modules/@uswds/uswds/packages/* $(OUTPUT_DIR)/assets/scss/uswds-packages + +copy-scss: copy-uswds-scss $(NODE_BIN)/gulp copy-scss test: build diff --git a/README.md b/README.md index b38d1358..62532a2f 100644 --- a/README.md +++ b/README.md @@ -113,14 +113,15 @@ Below are various ways to use the Login.gov Design System throughout our various Finally, import the styles into your main stylesheet: - ```scss - // app/assets/stylesheets/application.css.scss - - $theme-font-path: 'fonts'; - $theme-image-path: 'img'; - - @import '@18f/identity-design-system/dist/assets/scss/styles'; - ``` +```scss +// app/assets/stylesheets/application.css.scss +@use 'uswds-core' with ( + $theme-font-path: 'fonts', + $theme-image-path: 'img', +); + +@forward 'uswds'; +``` If you're using Sprockets and precompiling assets you'll need to update your Sprockets manifest to include the images and fonts for production: diff --git a/gulpfile.js b/gulpfile.js index 54c47884..5900fc6a 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -130,7 +130,7 @@ gulp.task('build-sass', () => .pipe( sass({ outputStyle: isProduction ? 'compressed' : 'expanded', - includePaths: ['node_modules/@uswds/uswds/packages'], + includePaths: ['./src/scss/packages', './src/scss/uswds-packages'], }), ) .pipe( @@ -161,14 +161,7 @@ gulp.task('copy-login-scss', () => .pipe(gulp.dest(SCSS_DEST)), ); -gulp.task('copy-uswds-scss', () => - gulp - .src(['node_modules/@uswds/uswds/dist/scss/**/*.scss']) - .pipe(underscorePrefix()) - .pipe(gulp.dest(`${SCSS_DEST}/uswds`)), -); - -gulp.task('copy-scss', gulp.series('copy-login-scss', 'copy-uswds-scss')); +gulp.task('copy-scss', gulp.series('copy-login-scss')); gulp.task('lint', gulp.parallel('lint-js', 'lint-sass')); diff --git a/package.json b/package.json index 965d2970..a0436ce9 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,8 @@ }, "files": [ "build", - "dist/assets/**/*" + "dist/assets/**/*", + "packages" ], "repository": { "type": "git", diff --git a/src/scss/components/_general.scss b/src/scss/components/_general.scss deleted file mode 100644 index 112749ac..00000000 --- a/src/scss/components/_general.scss +++ /dev/null @@ -1,6 +0,0 @@ -@use 'uswds-core' as *; - -// Overscroll background color to match header and footer -html { - background-color: color('primary-darker'); -} diff --git a/src/scss/components/_header.scss b/src/scss/components/_header.scss deleted file mode 100644 index faef8a13..00000000 --- a/src/scss/components/_header.scss +++ /dev/null @@ -1,9 +0,0 @@ -@use 'uswds-core' as *; - -.usa-overlay { - background: color('base-darker'); - - &.is-visible { - opacity: opacity(50); - } -} diff --git a/src/scss/components/_inputs.scss b/src/scss/components/_inputs.scss deleted file mode 100644 index ffe63a5f..00000000 --- a/src/scss/components/_inputs.scss +++ /dev/null @@ -1,251 +0,0 @@ -@use 'sass:math'; -@use 'uswds-core' as *; - -$theme-input-tile-background-color-selected: 'primary-lightest'; -$theme-input-tile-border-color: 'primary-light'; -$theme-input-tile-border-color-selected: 'primary-light'; -$theme-input-bordered-background-color-selected: $theme-input-tile-background-color-selected; -$theme-input-bordered-border-radius: $theme-input-tile-border-radius; -$theme-input-bordered-border-width: $theme-input-tile-border-width; -$theme-input-bordered-border-color: $theme-input-tile-border-color; -$theme-input-bordered-border-color-selected: $theme-input-tile-border-color-selected; - -$input-padding: 1; -$border-width: 1px; -$checkbox-radio-size: 0.875rem; -$input-select-margin-right: 1; - -.usa-input, -.usa-textarea, -.usa-select { - @include u-border-color('primary-light'); - font-weight: font-weight('bold'); - background-color: color('primary-lightest'); - border-radius: radius('md'); -} - -.usa-input--error { - @include u-border-color('error'); -} - -[type='search'], -.usa-search__input { - // Restore USWDS inherited square corners customized for `.usa-input`. - border-bottom-right-radius: 0; - border-right: none; - border-top-right-radius: 0; -} - -.usa-label { - font-weight: font-weight('bold'); -} - -@include override-prose { - .usa-input-list { - margin-top: units(1); - } -} - -.usa-radio__label, -.usa-checkbox__label { - @include u-line-height($theme-form-font-family, $theme-body-line-height); - display: inline-block; - margin-bottom: units(1); - padding-left: $checkbox-radio-size + units($input-select-margin-right); - - &::before { - background-color: color('primary-lightest'); - box-shadow: inset 0 0 0 units($border-width) color('primary'); - height: $checkbox-radio-size; - margin-left: 0; - margin-right: 0; - margin-top: math.div( - line-height($theme-form-font-family, $theme-body-line-height) * - font-size($theme-form-font-family, $theme-body-font-size) - $checkbox-radio-size, - 2 - ); - width: $checkbox-radio-size; - } -} - -.usa-radio__input:disabled + .usa-radio__label, -.usa-checkbox__input:disabled + .usa-checkbox__label { - color: color('disabled'); - border-color: color('disabled'); -} - -.usa-radio__label::before { - border-radius: 50%; -} - -.usa-radio__input:disabled + .usa-radio__label::before, -.usa-checkbox__input:disabled + .usa-checkbox__label::before { - box-shadow: inset 0 0 0 units($border-width) color('disabled'); -} - -.usa-radio__input:checked:disabled + .usa-radio__label::before { - box-shadow: inset 0 0 0 3px color('disabled'); - background-color: color('white'); -} - -.usa-checkbox__input:checked:disabled + .usa-checkbox__label::before { - background-color: color('disabled'); - box-shadow: inset 0 0 0 units($border-width) color('disabled'); - background-size: 0.5rem auto; -} - -.usa-radio__input:checked + .usa-radio__label::before { - background-color: color('white'); - box-shadow: inset 0 0 0 3px color('primary'); -} - -.usa-checkbox__input:checked + .usa-checkbox__label::before { - box-shadow: inset 0 0 0 units($border-width) color('primary'); - background-size: 0.5rem auto; -} - -.usa-radio__input.usa-focus + .usa-radio__label::before, -.usa-radio__input:focus + .usa-radio__label::before { - @include focus-outline(); -} - -.usa-radio__input:checked.usa-focus + .usa-radio__label::before, -.usa-radio__input:checked:focus + .usa-radio__label::before { - @include focus-outline(); -} - -.usa-checkbox__input.usa-focus + .usa-checkbox__label::before, -.usa-checkbox__input:focus + .usa-checkbox__label::before { - @include focus-outline(); -} - -.usa-checkbox__input:checked.usa-focus + .usa-checkbox__label::before, -.usa-checkbox__input:checked:focus + .usa-checkbox__label::before { - @include focus-outline(); -} - -.usa-checkbox__input--tile + .usa-checkbox__label, -.usa-radio__input--tile + .usa-radio__label { - @include u-text('primary', 'bold'); - @include u-display('block'); - @include u-padding(3); - padding-left: units(3) + $checkbox-radio-size + $input-select-margin-right; - border-color: color($theme-input-tile-border-color); - max-width: units($theme-input-max-width); - font-size: 1.125rem; - - &::before { - left: units(3); - margin-top: math.div( - line-height($theme-form-font-family, $theme-body-line-height) * 1.125rem - - $checkbox-radio-size, - 2 - ); - } -} - -.usa-radio__input--tile:disabled + .usa-radio__label--illustrated .usa-radio__image, -.usa-checkbox__input--tile:disabled + .usa-checkbox__label--illustrated .usa-checkbox__image { - filter: invert(45%) sepia(1%) saturate(0%) hue-rotate(232deg) brightness(100%) contrast(80%); -} - -.usa-checkbox__input--tile + .usa-checkbox__label--illustrated, -.usa-radio__input--tile + .usa-radio__label--illustrated { - align-items: flex-start; - - @include at-media('tablet') { - display: flex; - } - - .usa-radio__image, - .usa-checkbox__image { - width: 1.5rem; - float: left; - margin-right: 0.5rem; - @include at-media('tablet') { - width: 2.625rem; - padding-top: 0.25rem; - } - } - - .usa-radio__label--text, - .usa-checkbox__label--text { - @include at-media('tablet') { - flex: 1; - padding-left: 0.5rem; - } - } -} - -.usa-radio__input--bordered + .usa-radio__label, -.usa-checkbox__input--bordered + .usa-checkbox__label { - @include u-display('table'); // Margin collapse of a "block" while retaining collapsed width. - border: units($theme-input-bordered-border-width) solid color($theme-input-bordered-border-color); - border-radius: radius($theme-input-bordered-border-radius); - margin: units(1) 0; - max-width: units($theme-input-max-width); - padding: units(1) units(2) units(1) #{units(2) + $checkbox-radio-size + - units($input-select-margin-right)}; - - &::before { - left: units(2); - } -} - -.usa-checkbox__input--bordered:checked + .usa-checkbox__label, -.usa-radio__input--bordered:checked + .usa-radio__label { - background-color: color($theme-input-bordered-background-color-selected); - border-color: color($theme-input-bordered-border-color-selected); -} - -.usa-checkbox__input--bordered:checked:disabled + .usa-checkbox__label, -.usa-radio__input--bordered:checked:disabled + .usa-radio__label { - background-color: transparent; - border-color: color('disabled'); -} - -.usa-checkbox__input--tile:checked + .usa-checkbox__label, -.usa-radio__input--tile:checked + .usa-radio__label { - background-color: color($theme-input-tile-background-color-selected); - border-color: color($theme-input-tile-border-color-selected); -} - -.usa-checkbox__label-description, -.usa-radio__label-description { - @include typeset($theme-body-font-family, $theme-body-font-size, $theme-body-line-height); - @include u-text('ink', 'normal'); -} - -.usa-legend { - @include u-font-size('sans', '2xs'); - text-transform: uppercase; - font-weight: font-weight('normal'); - border-bottom: $border-width color('primary-light') solid; - width: 100%; - max-width: units($theme-input-max-width); - padding: units(1) 0; -} - -.usa-memorable-date { - margin-bottom: units(1); -} - -.usa-error-message, -.usa-success-message { - @include u-padding-y(0.5); - background-position: 0 0.5em; - background-size: units(2); - display: block; - font-weight: font-weight('bold'); - padding-left: units(3); -} - -.usa-error-message { - @include add-background-svg('alerts/error'); - color: color('error'); -} - -.usa-success-message { - @include add-background-svg('alerts/success'); - color: color('success'); -} diff --git a/src/scss/elements/form-controls/_all.scss b/src/scss/elements/form-controls/_all.scss deleted file mode 100644 index df9b1837..00000000 --- a/src/scss/elements/form-controls/_all.scss +++ /dev/null @@ -1,3 +0,0 @@ -@forward 'dropdown'; -@forward 'global'; -@forward 'text-input'; diff --git a/src/scss/elements/form-controls/_dropdown.scss b/src/scss/elements/form-controls/_dropdown.scss deleted file mode 100644 index 7dec97e7..00000000 --- a/src/scss/elements/form-controls/_dropdown.scss +++ /dev/null @@ -1,8 +0,0 @@ -@use 'uswds-core' as *; - -.usa-select.usa-select--big { - @include u-padding-x(2); - height: auto; - font-size: 1.25rem; - line-height: 1.5; -} diff --git a/src/scss/elements/form-controls/_global.scss b/src/scss/elements/form-controls/_global.scss deleted file mode 100644 index 5e4d9af3..00000000 --- a/src/scss/elements/form-controls/_global.scss +++ /dev/null @@ -1,5 +0,0 @@ -@use 'uswds-core' as *; - -%block-input-styles { - margin-top: units(0.5); -} diff --git a/src/scss/elements/form-controls/_text-input.scss b/src/scss/elements/form-controls/_text-input.scss deleted file mode 100644 index dec830b7..00000000 --- a/src/scss/elements/form-controls/_text-input.scss +++ /dev/null @@ -1,16 +0,0 @@ -@use 'uswds-core' as *; - -.usa-input.usa-input--big, -.usa-textarea.usa-textarea--big { - font-size: units(2.5); - line-height: 1.5; -} - -.usa-input.usa-input--big { - @include u-padding-x(2); - height: auto; -} - -.usa-textarea.usa-textarea--big { - height: 15rem; -} diff --git a/src/scss/packages/_global.scss b/src/scss/packages/_global.scss deleted file mode 100644 index 9ae4fc11..00000000 --- a/src/scss/packages/_global.scss +++ /dev/null @@ -1 +0,0 @@ -@forward 'uswds-global'; diff --git a/src/scss/packages/_required.scss b/src/scss/packages/_required.scss deleted file mode 100644 index 0aee15cc..00000000 --- a/src/scss/packages/_required.scss +++ /dev/null @@ -1,2 +0,0 @@ -@forward '../uswds-theme'; -@forward 'uswds-core'; diff --git a/src/scss/components/_accordions.scss b/src/scss/packages/_usa-accordion.scss similarity index 96% rename from src/scss/components/_accordions.scss rename to src/scss/packages/_usa-accordion.scss index 4c9d67c3..74fa966d 100644 --- a/src/scss/components/_accordions.scss +++ b/src/scss/packages/_usa-accordion.scss @@ -1,4 +1,5 @@ @use 'uswds-core' as *; +@forward './usa-accordion/index'; .usa-accordion__button { @include u-border($theme-accordion-border-width, $theme-accordion-border-color); diff --git a/src/scss/components/_alerts.scss b/src/scss/packages/_usa-alert.scss similarity index 95% rename from src/scss/components/_alerts.scss rename to src/scss/packages/_usa-alert.scss index 804a844e..2adcacf7 100644 --- a/src/scss/components/_alerts.scss +++ b/src/scss/packages/_usa-alert.scss @@ -1,4 +1,5 @@ @use 'uswds-core' as *; +@forward './usa-alert/index'; $alerts: 'success', 'warning', 'error', 'info', 'emergency'; diff --git a/src/scss/components/_banner.scss b/src/scss/packages/_usa-banner.scss similarity index 97% rename from src/scss/components/_banner.scss rename to src/scss/packages/_usa-banner.scss index 7f2105d6..9b18a41f 100644 --- a/src/scss/components/_banner.scss +++ b/src/scss/packages/_usa-banner.scss @@ -1,4 +1,5 @@ @use 'uswds-core' as *; +@forward './usa-banner/index'; .usa-banner__header { @include set-text-from-bg('primary-darker'); diff --git a/src/scss/components/_buttons.scss b/src/scss/packages/_usa-button.scss similarity index 98% rename from src/scss/components/_buttons.scss rename to src/scss/packages/_usa-button.scss index 265b18e4..1230bd77 100644 --- a/src/scss/components/_buttons.scss +++ b/src/scss/packages/_usa-button.scss @@ -1,4 +1,5 @@ @use 'uswds-core' as *; +@forward './usa-button/index'; $button-stroke-big: inset 0 0 0 units($theme-button-stroke-width * 2); diff --git a/src/scss/components/_cards.scss b/src/scss/packages/_usa-card.scss similarity index 89% rename from src/scss/components/_cards.scss rename to src/scss/packages/_usa-card.scss index f880ac1c..703ca909 100644 --- a/src/scss/components/_cards.scss +++ b/src/scss/packages/_usa-card.scss @@ -1,4 +1,5 @@ @use 'uswds-core' as *; +@forward './usa-card/index'; .lg-card { @include u-radius('sm'); diff --git a/src/scss/packages/_usa-checkbox.scss b/src/scss/packages/_usa-checkbox.scss new file mode 100644 index 00000000..a81ca43e --- /dev/null +++ b/src/scss/packages/_usa-checkbox.scss @@ -0,0 +1,139 @@ +@use 'sass:math'; +@use 'uswds-core' as *; +@forward './usa-checkbox/index'; + +$border-width: 1px; +$checkbox-size: 0.875rem; +$input-select-margin-right: 1; + +.usa-checkbox__label { + @include u-line-height($theme-form-font-family, $theme-body-line-height); + display: inline-block; + margin-bottom: units(1); + padding-left: $checkbox-size + units($input-select-margin-right); + + &::before { + background-color: color('primary-lightest'); + box-shadow: inset 0 0 0 units($border-width) color('primary'); + height: $checkbox-size; + margin-left: 0; + margin-right: 0; + margin-top: math.div( + line-height($theme-form-font-family, $theme-body-line-height) * + font-size($theme-form-font-family, $theme-body-font-size) - $checkbox-size, + 2 + ); + width: $checkbox-size; + } +} + +.usa-checkbox__input:disabled + .usa-checkbox__label { + color: color('disabled'); + border-color: color('disabled'); +} + +.usa-checkbox__input:disabled + .usa-checkbox__label::before { + box-shadow: inset 0 0 0 units($border-width) color('disabled'); +} + +.usa-checkbox__input:checked:disabled + .usa-checkbox__label::before { + background-color: color('disabled'); + box-shadow: inset 0 0 0 units($border-width) color('disabled'); + background-size: 0.5rem auto; +} + +.usa-checkbox__input:checked + .usa-checkbox__label::before { + box-shadow: inset 0 0 0 units($border-width) color('primary'); + background-size: 0.5rem auto; +} + +.usa-checkbox__input.usa-focus + .usa-checkbox__label::before, +.usa-checkbox__input:focus + .usa-checkbox__label::before { + @include focus-outline(); +} + +.usa-checkbox__input:checked.usa-focus + .usa-checkbox__label::before, +.usa-checkbox__input:checked:focus + .usa-checkbox__label::before { + @include focus-outline(); +} + +.usa-checkbox__input--tile + .usa-checkbox__label { + @include u-text('primary', 'bold'); + @include u-display('block'); + @include u-padding(3); + padding-left: units(3) + $checkbox-size + $input-select-margin-right; + border-color: color($theme-input-tile-border-color); + max-width: units($theme-input-max-width); + font-size: 1.125rem; + + &::before { + left: units(3); + margin-top: math.div( + line-height($theme-form-font-family, $theme-body-line-height) * 1.125rem - $checkbox-size, + 2 + ); + } +} + +.usa-checkbox__input--tile:disabled + .usa-checkbox__label--illustrated .usa-checkbox__image { + filter: invert(45%) sepia(1%) saturate(0%) hue-rotate(232deg) brightness(100%) contrast(80%); +} + +.usa-checkbox__input--tile + .usa-checkbox__label--illustrated { + align-items: flex-start; + + @include at-media('tablet') { + display: flex; + } + + .usa-checkbox__image { + width: 1.5rem; + float: left; + margin-right: 0.5rem; + @include at-media('tablet') { + width: 2.625rem; + padding-top: 0.25rem; + } + } + + .usa-checkbox__label--text { + @include at-media('tablet') { + flex: 1; + padding-left: 0.5rem; + } + } +} + +.usa-checkbox__input--bordered + .usa-checkbox__label { + @include u-display('table'); // Margin collapse of a "block" while retaining collapsed width. + border: units($theme-input-bordered-border-width) solid color($theme-input-bordered-border-color); + border-radius: radius($theme-input-bordered-border-radius); + margin: units(1) 0; + max-width: units($theme-input-max-width); + padding: units(1) units(2) units(1) #{units(2) + $checkbox-size + + units($input-select-margin-right)}; + + &::before { + left: units(2); + } +} + +.usa-checkbox__input--bordered:checked + .usa-checkbox__label { + background-color: color($theme-input-bordered-background-color-selected); + border-color: color($theme-input-bordered-border-color-selected); +} + +.usa-checkbox__input--bordered:checked:disabled + .usa-checkbox__label { + background-color: transparent; + border-color: color('disabled'); +} + +.usa-checkbox__input--tile:checked + .usa-checkbox__label { + background-color: color($theme-input-tile-background-color-selected); + border-color: color($theme-input-tile-border-color-selected); +} + +.usa-checkbox__label-description { + @include typeset($theme-body-font-family, $theme-body-font-size, $theme-body-line-height); + @include u-text('ink', 'normal'); +} diff --git a/src/scss/components/_code.scss b/src/scss/packages/_usa-code.scss similarity index 100% rename from src/scss/components/_code.scss rename to src/scss/packages/_usa-code.scss diff --git a/src/scss/packages/_usa-error-message.scss b/src/scss/packages/_usa-error-message.scss new file mode 100644 index 00000000..baae1214 --- /dev/null +++ b/src/scss/packages/_usa-error-message.scss @@ -0,0 +1,13 @@ +@use 'uswds-core' as *; +@forward './usa-error-message/index'; + +.usa-error-message { + @include add-background-svg('alerts/error'); + @include u-padding-y(0.5); + background-position: 0 0.5em; + background-size: units(2); + display: block; + font-weight: font-weight('bold'); + padding-left: units(3); + color: color('error'); +} diff --git a/src/scss/components/_footer.scss b/src/scss/packages/_usa-footer.scss similarity index 96% rename from src/scss/components/_footer.scss rename to src/scss/packages/_usa-footer.scss index 4925715a..591779bf 100644 --- a/src/scss/components/_footer.scss +++ b/src/scss/packages/_usa-footer.scss @@ -1,4 +1,5 @@ @use 'uswds-core' as *; +@forward './usa-footer/index'; .usa-footer__primary-section { padding-top: units(4); diff --git a/src/scss/packages/_usa-header.scss b/src/scss/packages/_usa-header.scss new file mode 100644 index 00000000..bd40fd54 --- /dev/null +++ b/src/scss/packages/_usa-header.scss @@ -0,0 +1,82 @@ +@use 'uswds-core' as *; +@forward './usa-header/index'; + +$header-height: 10; + +.usa-overlay { + background: color('base-darker'); + + &.is-visible { + opacity: opacity(50); + } +} + +// Header navigation +// --------------------------------- + +.usa-header--extended, +.usa-header--basic { + .usa-logo { + @include at-media-max($theme-header-min-width) { + font-size: unset; + flex: unset; + } + + @include at-media($theme-header-min-width) { + font-size: unset; + margin: 0; + } + + line-height: units(2); + } + + .usa-navbar { + @include at-media-max($theme-header-min-width) { + border-bottom: units(1px) solid color('base-light'); + justify-content: space-between; + } + + @include at-media($theme-header-min-width) { + display: flex; + align-items: center; + height: units($header-height); + } + } +} + +.usa-header { + + .usa-section, + + main { + @include at-media($theme-header-min-width) { + border-top: units(1px) solid color('base-light'); + } + } +} + +// Header navigation for basic +// --------------------------------- + +.usa-header--basic { + .usa-nav-container { + @include at-media($theme-header-min-width) { + align-items: center; + } + } + + .usa-nav { + @include at-media($theme-header-min-width) { + padding: 0; + } + } +} + +// Header navigation for extended +// --------------------------------- + +.usa-header--extended .usa-nav { + @include at-media($theme-header-min-width) { + border-top: 0; + padding: 0; + width: 100%; + } +} diff --git a/src/scss/components/_hero.scss b/src/scss/packages/_usa-hero.scss similarity index 95% rename from src/scss/components/_hero.scss rename to src/scss/packages/_usa-hero.scss index a692f80b..d1865d4b 100644 --- a/src/scss/components/_hero.scss +++ b/src/scss/packages/_usa-hero.scss @@ -1,4 +1,5 @@ @use 'uswds-core' as *; +@forward './usa-hero/index'; .usa-hero { background-color: color('primary-darker'); diff --git a/src/scss/components/_identifier.scss b/src/scss/packages/_usa-identifier.scss similarity index 85% rename from src/scss/components/_identifier.scss rename to src/scss/packages/_usa-identifier.scss index 92a87054..e5d3e10d 100644 --- a/src/scss/components/_identifier.scss +++ b/src/scss/packages/_usa-identifier.scss @@ -1,4 +1,5 @@ @use 'uswds-core' as *; +@forward './usa-identifier/index'; .usa-identifier { @include u-line-height($theme-identifier-font-family, 5); diff --git a/src/scss/packages/_usa-input-list.scss b/src/scss/packages/_usa-input-list.scss new file mode 100644 index 00000000..1723456e --- /dev/null +++ b/src/scss/packages/_usa-input-list.scss @@ -0,0 +1,8 @@ +@use 'uswds-core' as *; +@forward './usa-input-list/index'; + +@include override-prose { + .usa-input-list { + margin-top: units(1); + } +} diff --git a/src/scss/packages/_usa-input.scss b/src/scss/packages/_usa-input.scss new file mode 100644 index 00000000..6ceb7cb9 --- /dev/null +++ b/src/scss/packages/_usa-input.scss @@ -0,0 +1,22 @@ +@use 'uswds-core' as *; +@forward './usa-input/index'; + +$input-padding: 1; + +.usa-input { + @include u-border-color('primary-light'); + font-weight: font-weight('bold'); + background-color: color('primary-lightest'); + border-radius: radius('md'); +} + +.usa-input--error { + @include u-border-color('error'); +} + +.usa-input.usa-input--big { + @include u-padding-x(2); + font-size: units(2.5); + line-height: 1.5; + height: auto; +} diff --git a/src/scss/packages/_usa-intro.scss b/src/scss/packages/_usa-intro.scss new file mode 100644 index 00000000..e13c1dd3 --- /dev/null +++ b/src/scss/packages/_usa-intro.scss @@ -0,0 +1,10 @@ +@use 'uswds-core' as *; +@forward './usa-intro/index'; + +.usa-intro { + @include u-font-size('sans', 'md'); + + @include at-media('tablet') { + @include u-font-size('sans', $theme-lead-font-size); + } +} diff --git a/src/scss/packages/_usa-label.scss b/src/scss/packages/_usa-label.scss new file mode 100644 index 00000000..a46c10fb --- /dev/null +++ b/src/scss/packages/_usa-label.scss @@ -0,0 +1,6 @@ +@use 'uswds-core' as *; +@forward './usa-label/index'; + +.usa-label { + font-weight: font-weight('bold'); +} diff --git a/src/scss/packages/_usa-legend.scss b/src/scss/packages/_usa-legend.scss new file mode 100644 index 00000000..eb09f08d --- /dev/null +++ b/src/scss/packages/_usa-legend.scss @@ -0,0 +1,14 @@ +@use 'uswds-core' as *; +@forward './usa-legend/index'; + +$border-width: 1px; + +.usa-legend { + @include u-font-size('sans', '2xs'); + text-transform: uppercase; + font-weight: font-weight('normal'); + border-bottom: $border-width color('primary-light') solid; + width: 100%; + max-width: units($theme-input-max-width); + padding: units(1) 0; +} diff --git a/src/scss/elements/typography/_links.scss b/src/scss/packages/_usa-link.scss similarity index 72% rename from src/scss/elements/typography/_links.scss rename to src/scss/packages/_usa-link.scss index 3e11c7cf..634d68bf 100644 --- a/src/scss/elements/typography/_links.scss +++ b/src/scss/packages/_usa-link.scss @@ -1,4 +1,5 @@ @use 'uswds-core' as *; +@forward './usa-link/index'; .usa-link--external { margin-right: units(2px); diff --git a/src/scss/packages/_usa-memorable-date.scss b/src/scss/packages/_usa-memorable-date.scss new file mode 100644 index 00000000..cb46e6e2 --- /dev/null +++ b/src/scss/packages/_usa-memorable-date.scss @@ -0,0 +1,6 @@ +@use 'uswds-core' as *; +@forward './usa-memorable-date/index'; + +.usa-memorable-date { + margin-bottom: units(1); +} diff --git a/src/scss/components/_navbar.scss b/src/scss/packages/_usa-nav.scss similarity index 81% rename from src/scss/components/_navbar.scss rename to src/scss/packages/_usa-nav.scss index 54674cf8..e1cbaa8f 100644 --- a/src/scss/components/_navbar.scss +++ b/src/scss/packages/_usa-nav.scss @@ -1,78 +1,9 @@ @use 'uswds-core' as *; -@use 'usa-nav'; +@use './usa-nav/index' as usa-nav; +@forward './usa-nav/index'; $header-height: 10; -// Header navigation -// --------------------------------- - -.usa-header--extended, -.usa-header--basic { - .usa-logo { - @include at-media-max($theme-header-min-width) { - font-size: unset; - flex: unset; - } - - @include at-media($theme-header-min-width) { - font-size: unset; - margin: 0; - } - - line-height: units(2); - } - - .usa-navbar { - @include at-media-max($theme-header-min-width) { - border-bottom: units(1px) solid color('base-light'); - justify-content: space-between; - } - - @include at-media($theme-header-min-width) { - display: flex; - align-items: center; - height: units($header-height); - } - } -} - -.usa-header { - + .usa-section, - + main { - @include at-media($theme-header-min-width) { - border-top: units(1px) solid color('base-light'); - } - } -} - -// Header navigation for basic -// --------------------------------- - -.usa-header--basic { - .usa-nav-container { - @include at-media($theme-header-min-width) { - align-items: center; - } - } - - .usa-nav { - @include at-media($theme-header-min-width) { - padding: 0; - } - } -} - -// Header navigation for extended -// --------------------------------- - -.usa-header--extended .usa-nav { - @include at-media($theme-header-min-width) { - border-top: 0; - padding: 0; - width: 100%; - } -} - // Primary navigation // --------------------------------- diff --git a/src/scss/components/_process-list.scss b/src/scss/packages/_usa-process-list.scss similarity index 97% rename from src/scss/components/_process-list.scss rename to src/scss/packages/_usa-process-list.scss index c2297ebc..28c0909e 100644 --- a/src/scss/components/_process-list.scss +++ b/src/scss/packages/_usa-process-list.scss @@ -1,4 +1,5 @@ @use 'uswds-core' as *; +@forward './usa-process-list/index'; $theme-process-list-counter-size-big: 3.125rem; diff --git a/src/scss/components/_typography.scss b/src/scss/packages/_usa-prose.scss similarity index 73% rename from src/scss/components/_typography.scss rename to src/scss/packages/_usa-prose.scss index 143d8b7b..4b655a66 100644 --- a/src/scss/components/_typography.scss +++ b/src/scss/packages/_usa-prose.scss @@ -1,4 +1,5 @@ @use 'uswds-core' as *; +@forward './usa-prose/index'; .usa-prose { @include add-knockout-font-smoothing; @@ -58,19 +59,3 @@ letter-spacing: 0.3px; } } - -.usa-intro { - @include u-font-size('sans', 'md'); - - @include at-media('tablet') { - @include u-font-size('sans', $theme-lead-font-size); - } -} - -@mixin text-wrap-mixin { - word-break: break-all; -} - -.text-wrap { - @include text-wrap-mixin; -} diff --git a/src/scss/packages/_usa-radio.scss b/src/scss/packages/_usa-radio.scss new file mode 100644 index 00000000..3e171c14 --- /dev/null +++ b/src/scss/packages/_usa-radio.scss @@ -0,0 +1,138 @@ +@use 'sass:math'; +@use 'uswds-core' as *; +@forward './usa-radio/index'; + +$border-width: 1px; +$radio-size: 0.875rem; +$input-select-margin-right: 1; + +.usa-radio__label { + @include u-line-height($theme-form-font-family, $theme-body-line-height); + display: inline-block; + margin-bottom: units(1); + padding-left: $radio-size + units($input-select-margin-right); + + &::before { + border-radius: 50%; + background-color: color('primary-lightest'); + box-shadow: inset 0 0 0 units($border-width) color('primary'); + height: $radio-size; + margin-left: 0; + margin-right: 0; + margin-top: math.div( + line-height($theme-form-font-family, $theme-body-line-height) * + font-size($theme-form-font-family, $theme-body-font-size) - $radio-size, + 2 + ); + width: $radio-size; + } +} + +.usa-radio__input:disabled + .usa-radio__label { + color: color('disabled'); + border-color: color('disabled'); +} + +.usa-radio__input:disabled + .usa-radio__label::before { + box-shadow: inset 0 0 0 units($border-width) color('disabled'); +} + +.usa-radio__input:checked:disabled + .usa-radio__label::before { + box-shadow: inset 0 0 0 3px color('disabled'); + background-color: color('white'); +} + +.usa-radio__input:checked + .usa-radio__label::before { + background-color: color('white'); + box-shadow: inset 0 0 0 3px color('primary'); +} + +.usa-radio__input.usa-focus + .usa-radio__label::before, +.usa-radio__input:focus + .usa-radio__label::before { + @include focus-outline(); +} + +.usa-radio__input:checked.usa-focus + .usa-radio__label::before, +.usa-radio__input:checked:focus + .usa-radio__label::before { + @include focus-outline(); +} + +.usa-radio__input--tile + .usa-radio__label { + @include u-text('primary', 'bold'); + @include u-display('block'); + @include u-padding(3); + padding-left: units(3) + $radio-size + $input-select-margin-right; + border-color: color($theme-input-tile-border-color); + max-width: units($theme-input-max-width); + font-size: 1.125rem; + + &::before { + left: units(3); + margin-top: math.div( + line-height($theme-form-font-family, $theme-body-line-height) * 1.125rem - $radio-size, + 2 + ); + } +} + +.usa-radio__input--tile:disabled + .usa-radio__label--illustrated .usa-radio__image { + filter: invert(45%) sepia(1%) saturate(0%) hue-rotate(232deg) brightness(100%) contrast(80%); +} + +.usa-radio__input--tile + .usa-radio__label--illustrated { + align-items: flex-start; + + @include at-media('tablet') { + display: flex; + } + + .usa-radio__image { + width: 1.5rem; + float: left; + margin-right: 0.5rem; + @include at-media('tablet') { + width: 2.625rem; + padding-top: 0.25rem; + } + } + + .usa-radio__label--text { + @include at-media('tablet') { + flex: 1; + padding-left: 0.5rem; + } + } +} + +.usa-radio__input--bordered + .usa-radio__label { + @include u-display('table'); // Margin collapse of a "block" while retaining collapsed width. + border: units($theme-input-bordered-border-width) solid color($theme-input-bordered-border-color); + border-radius: radius($theme-input-bordered-border-radius); + margin: units(1) 0; + max-width: units($theme-input-max-width); + padding: units(1) units(2) units(1) #{units(2) + $radio-size + units($input-select-margin-right)}; + + &::before { + left: units(2); + } +} + +.usa-radio__input--bordered:checked + .usa-radio__label { + background-color: color($theme-input-bordered-background-color-selected); + border-color: color($theme-input-bordered-border-color-selected); +} + +.usa-radio__input--bordered:checked:disabled + .usa-radio__label { + background-color: transparent; + border-color: color('disabled'); +} + +.usa-radio__input--tile:checked + .usa-radio__label { + background-color: color($theme-input-tile-background-color-selected); + border-color: color($theme-input-tile-border-color-selected); +} + +.usa-radio__label-description { + @include typeset($theme-body-font-family, $theme-body-font-size, $theme-body-line-height); + @include u-text('ink', 'normal'); +} diff --git a/src/scss/components/_search.scss b/src/scss/packages/_usa-search.scss similarity index 74% rename from src/scss/components/_search.scss rename to src/scss/packages/_usa-search.scss index dcd11e2e..2c494443 100644 --- a/src/scss/components/_search.scss +++ b/src/scss/packages/_usa-search.scss @@ -1,4 +1,12 @@ @use 'uswds-core' as *; +@forward './usa-search/index'; + +[type='search'], +.usa-search__input { + border-bottom-right-radius: 0; + border-right: none; + border-top-right-radius: 0; +} .usa-search [type='submit'], .usa-search .usa-search__submit { diff --git a/src/scss/packages/_usa-select.scss b/src/scss/packages/_usa-select.scss new file mode 100644 index 00000000..620ce2d2 --- /dev/null +++ b/src/scss/packages/_usa-select.scss @@ -0,0 +1,16 @@ +@use 'uswds-core' as *; +@forward './usa-select/index'; + +.usa-select { + @include u-border-color('primary-light'); + font-weight: font-weight('bold'); + background-color: color('primary-lightest'); + border-radius: radius('md'); +} + +.usa-select.usa-select--big { + @include u-padding-x(2); + height: auto; + font-size: 1.25rem; + line-height: 1.5; +} diff --git a/src/scss/components/_sidenav.scss b/src/scss/packages/_usa-sidenav.scss similarity index 96% rename from src/scss/components/_sidenav.scss rename to src/scss/packages/_usa-sidenav.scss index 8e3d9041..171d1d5a 100644 --- a/src/scss/components/_sidenav.scss +++ b/src/scss/packages/_usa-sidenav.scss @@ -1,4 +1,5 @@ @use 'uswds-core' as *; +@forward './usa-sidenav/index'; .usa-sidenav { a:not(.usa-button) { diff --git a/src/scss/components/_spinner.scss b/src/scss/packages/_usa-spinner.scss similarity index 100% rename from src/scss/components/_spinner.scss rename to src/scss/packages/_usa-spinner.scss diff --git a/src/scss/packages/_usa-success-message.scss b/src/scss/packages/_usa-success-message.scss new file mode 100644 index 00000000..da99c3a7 --- /dev/null +++ b/src/scss/packages/_usa-success-message.scss @@ -0,0 +1,12 @@ +@use 'uswds-core' as *; + +.usa-success-message { + @include u-padding-y(0.5); + @include add-background-svg('alerts/success'); + background-position: 0 0.5em; + background-size: units(2); + display: block; + font-weight: font-weight('bold'); + padding-left: units(3); + color: color('success'); +} diff --git a/src/scss/packages/_usa-textarea.scss b/src/scss/packages/_usa-textarea.scss new file mode 100644 index 00000000..c7947352 --- /dev/null +++ b/src/scss/packages/_usa-textarea.scss @@ -0,0 +1,15 @@ +@use 'uswds-core' as *; +@forward './usa-textarea/index'; + +.usa-textarea { + @include u-border-color('primary-light'); + font-weight: font-weight('bold'); + background-color: color('primary-lightest'); + border-radius: radius('md'); +} + +.usa-textarea.usa-textarea--big { + font-size: units(2.5); + line-height: 1.5; + height: 15rem; +} diff --git a/src/scss/components/_verification-badge.scss b/src/scss/packages/_usa-verification-badge.scss similarity index 100% rename from src/scss/components/_verification-badge.scss rename to src/scss/packages/_usa-verification-badge.scss diff --git a/src/scss/_uswds-theme.scss b/src/scss/packages/_uswds-core.scss similarity index 93% rename from src/scss/_uswds-theme.scss rename to src/scss/packages/_uswds-core.scss index 07027645..2effa2f1 100644 --- a/src/scss/_uswds-theme.scss +++ b/src/scss/packages/_uswds-core.scss @@ -55,7 +55,7 @@ $site-palette: ( 'site-white': #ffffff ); -@forward 'uswds-core' with ( +@forward './uswds-core/index' with ( // ---------------------------------------- // Colors // ---------------------------------------- @@ -236,3 +236,18 @@ $site-palette: ( ) !default ); + +@use './uswds-core/index' as *; + +$theme-input-tile-background-color-selected: 'primary-lightest'; +$theme-input-tile-border-color: 'primary-light'; +$theme-input-tile-border-color-selected: 'primary-light'; +$theme-input-bordered-background-color-selected: $theme-input-tile-background-color-selected; +$theme-input-bordered-border-radius: $theme-input-tile-border-radius; +$theme-input-bordered-border-width: $theme-input-tile-border-width; +$theme-input-bordered-border-color: $theme-input-tile-border-color; +$theme-input-bordered-border-color-selected: $theme-input-tile-border-color-selected; + +%block-input-styles { + margin-top: units(0.5); +} diff --git a/src/scss/packages/_uswds-form-controls.scss b/src/scss/packages/_uswds-form-controls.scss new file mode 100644 index 00000000..6b56f8dc --- /dev/null +++ b/src/scss/packages/_uswds-form-controls.scss @@ -0,0 +1,3 @@ +@forward './uswds-form-controls/index'; + +@forward 'usa-success-message'; diff --git a/src/scss/packages/_uswds-utilities.scss b/src/scss/packages/_uswds-utilities.scss new file mode 100644 index 00000000..be8a0f68 --- /dev/null +++ b/src/scss/packages/_uswds-utilities.scss @@ -0,0 +1,5 @@ +@forward './uswds-utilities/index'; + +.text-wrap { + word-break: break-all; +} diff --git a/src/scss/packages/_components.scss b/src/scss/packages/_uswds.scss similarity index 58% rename from src/scss/packages/_components.scss rename to src/scss/packages/_uswds.scss index d9c7fca0..5a37816b 100644 --- a/src/scss/packages/_components.scss +++ b/src/scss/packages/_uswds.scss @@ -1,4 +1,14 @@ -// USWDS Components +@use 'uswds-core' as *; + +// Global +// ------------------------------------- +@forward 'uswds-global'; + +// Helpers +// ------------------------------------- +@forward 'uswds-helpers'; + +// Components // ------------------------------------- @forward 'uswds-typography'; @forward 'usa-accordion'; @@ -8,6 +18,7 @@ @forward 'usa-button-group'; @forward 'usa-button'; @forward 'usa-card'; +@forward 'usa-code'; @forward 'usa-checklist'; @forward 'usa-collection'; @forward 'usa-embed-container'; @@ -19,6 +30,8 @@ @forward 'usa-icon-list'; @forward 'usa-icon'; @forward 'usa-identifier'; +@forward 'usa-in-page-navigation'; +@forward 'usa-language-selector'; @forward 'usa-layout-docs'; @forward 'usa-layout-grid'; @forward 'usa-media-block'; @@ -31,36 +44,20 @@ @forward 'usa-sidenav'; @forward 'usa-site-alert'; @forward 'usa-skipnav'; +@forward 'usa-spinner'; @forward 'usa-step-indicator'; @forward 'usa-summary-box'; @forward 'usa-table'; @forward 'usa-tag'; @forward 'usa-tooltip'; +@forward 'usa-verification-badge'; @forward 'uswds-form-controls'; -// Elements +// Utilities // ------------------------------------- -@forward '../elements/form-controls/all'; -@forward '../elements/typography/links'; +@forward 'uswds-utilities'; -// Components -// ------------------------------------- -@forward '../components/accordions'; -@forward '../components/alerts'; -@forward '../components/banner'; -@forward '../components/buttons'; -@forward '../components/cards'; -@forward '../components/code'; -@forward '../components/footer'; -@forward '../components/general'; -@forward '../components/header'; -@forward '../components/hero'; -@forward '../components/identifier'; -@forward '../components/inputs'; -@forward '../components/navbar'; -@forward '../components/process-list'; -@forward '../components/search'; -@forward '../components/sidenav'; -@forward '../components/spinner'; -@forward '../components/typography'; -@forward '../components/verification-badge'; +// Overscroll background color to match header and footer +html { + background-color: color('primary-darker'); +} diff --git a/src/scss/packages/_utilities.scss b/src/scss/packages/_utilities.scss deleted file mode 100644 index f7d35eaf..00000000 --- a/src/scss/packages/_utilities.scss +++ /dev/null @@ -1 +0,0 @@ -@forward 'uswds-utilities'; diff --git a/src/scss/styles.scss b/src/scss/styles.scss index 21380855..6ab6af78 100644 --- a/src/scss/styles.scss +++ b/src/scss/styles.scss @@ -1,4 +1,2 @@ -@forward 'packages/required'; -@forward 'packages/global'; -@forward 'packages/components'; -@forward 'packages/utilities'; +@use 'uswds-core'; +@forward 'uswds'; diff --git a/src/scss/uswds b/src/scss/uswds deleted file mode 120000 index 07bc6ab0..00000000 --- a/src/scss/uswds +++ /dev/null @@ -1 +0,0 @@ -../../node_modules/@uswds/uswds/dist/scss \ No newline at end of file diff --git a/src/scss/uswds-packages b/src/scss/uswds-packages new file mode 120000 index 00000000..0f252cb7 --- /dev/null +++ b/src/scss/uswds-packages @@ -0,0 +1 @@ +../../node_modules/@uswds/uswds/packages \ No newline at end of file