Skip to content

Commit

Permalink
Load utility classes after components (#212)
Browse files Browse the repository at this point in the history
* Load utility classes after components

**Why**: To match USWDS intended load order of stylesheets, to allow utility classes to take precedent over component styles, and to facilitate a potential future use of USWDS 2.11.0 package subsetting.

* Use symlink to point to uswds dependency for src files

**Why**: Avoid changing file structure for built output, while retaining the ability to point to dependency source in development in a way that's compatible with the copied dependency in the build distributable. Also, nicer paths.

* Ignore USWDS files for lint

* Run copy-scss tasks in series

**Why**: Guarantee USWDS always takes precedent over symlink
  • Loading branch information
aduth authored Apr 28, 2021
1 parent 96ef102 commit 4226b82
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 17 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- Reduce the border width of the normal outline button to the intended width of `1px` (previously `2px`). The big variant of the outline button is unaffected by this change, and remains `2px`.
- Fix rounded corners on sidebar current page item.
- Fix unintentional rounded corners on search text field.
- Fix utility classes not always applying as expected when applied to components. For example, using `margin-` utility classes on an unstyled button would previously unexpectedly conflict with and not take precedent over the button's own margins.

## 5.0.3

Expand Down
14 changes: 4 additions & 10 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ const gulpif = require('gulp-if');
const sass = require('gulp-sass');
const gulpStylelint = require('gulp-stylelint');
const sourcemaps = require('gulp-sourcemaps');
const uswds = require('uswds-gulp/config/uswds');
const browserify = require('browserify');
const babel = require('gulp-babel');
const source = require('vinyl-source-stream');
Expand Down Expand Up @@ -99,7 +98,7 @@ gulp.task('build-js', () => {
gulp.task('watch-js', () => gulp.watch(`${PROJECT_JS_SRC}/**/*.js`, gulp.series('build-js')));

gulp.task('lint-sass', () =>
gulp.src(`${PROJECT_SASS_SRC}/**/*.scss`).pipe(
gulp.src([`${PROJECT_SASS_SRC}/**/*.scss`, `!${PROJECT_SASS_SRC}/uswds/**/*.scss`]).pipe(
gulpStylelint({
failAfterError: true,
reporters: [{ formatter: 'string', console: true }],
Expand All @@ -122,11 +121,7 @@ gulp.task('build-sass', () => {
.src([`${PROJECT_SASS_SRC}/*.scss`])
.pipe(replace(/\buswds @version\b/g, `uswds v${uswdsPkg.version}`))
.pipe(sourcemaps.init({ largeFile: true }))
.pipe(
sass({
includePaths: [PROJECT_SASS_SRC, `${uswds}/scss`, `${uswds}/scss/packages`],
}).on('error', notificationOptions.handler),
)
.pipe(sass().on('error', notificationOptions.handler))
.pipe(postcss(plugins))
.pipe(gulp.dest(CSS_DEST))
.pipe(notify(notificationOptions.success));
Expand All @@ -146,21 +141,20 @@ const underscorePrefix = () => gulpif((f) => f.basename[0] !== '_', rename({ pre
gulp.task('copy-login-scss', () =>
gulp
.src([`${PROJECT_SASS_SRC}/**/*.scss`])
.pipe(replace("@import 'uswds'", "@import 'uswds/uswds'"))
.pipe(replaceUrls())
.pipe(underscorePrefix())
.pipe(gulp.dest(SCSS_DEST)),
);

gulp.task('copy-uswds-scss', () =>
gulp
.src([`${uswds}/scss/**/*.scss`])
.src(['node_modules/uswds/dist/scss/**/*.scss'])
.pipe(replaceUrls())
.pipe(underscorePrefix())
.pipe(gulp.dest(`${SCSS_DEST}/uswds`)),
);

gulp.task('copy-scss', gulp.parallel('copy-login-scss', 'copy-uswds-scss'));
gulp.task('copy-scss', gulp.series('copy-login-scss', 'copy-uswds-scss'));

gulp.task('lint', gulp.parallel('lint-js', 'lint-sass'));

Expand Down
5 changes: 0 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@
"serve": "^11.3.2",
"stylelint": "^13.7.2",
"stylelint-scss": "^3.18.0",
"uswds-gulp": "github:uswds/uswds-gulp",
"vinyl-buffer": "^1.0.1",
"vinyl-source-stream": "^2.0.0",
"wait-on": "^5.3.0",
Expand Down
6 changes: 5 additions & 1 deletion src/scss/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
@import 'uswds-theme/utilities';
@import 'uswds-theme/components';

@import 'uswds';
@import 'uswds/packages/required';
@import 'uswds/packages/global';
@import 'uswds/packages/uswds-components';

@import 'functions/focus';

Expand All @@ -27,3 +29,5 @@
@import 'components/spinner';
@import 'components/typography';
@import 'components/verification-badge';

@import 'uswds/packages/uswds-utilities';
1 change: 1 addition & 0 deletions src/scss/uswds

0 comments on commit 4226b82

Please sign in to comment.