Skip to content

Commit 13ad58b

Browse files
committed
Update steps to USWDS 3 instructions
1 parent be24e0a commit 13ad58b

4 files changed

Lines changed: 90 additions & 132 deletions

File tree

_includes/sxs/part-eight.html

Lines changed: 64 additions & 118 deletions
Original file line numberDiff line numberDiff line change
@@ -3,157 +3,103 @@ <h2><span>Part eight</span> Customize USWDS settings</h2>
33
<p>In the final part, we'll bring it all home and customize USWDS to better fit with the original project. </p>
44
<h3 class="step">Stop the watch script.</h3>
55
<p class="step-description">Go the terminal window where the <strong>watch</strong> script is running and enter <strong>control-c</strong> to stop the script.</p>
6-
<h3 class="step">Create a custom settings file.</h3>
7-
<p class="step-description">We're going to make some custom <a href="https://designsystem.digital.gov/documentation/settings/">USWDS settings</a> for our project. To do this, we're going to use a custom settings file. Create this file in the USWDS theme directory.</p>
8-
<div class="terminal">
9-
<pre>touch _theme/_uswds-theme.scss</pre>
10-
</div>
11-
<h3 class="step">Activate custom settings.</h3>
12-
<p class="step-description">Now, let's tell USWDS that this new settings file exists. We'll open the USWDS Sass entry point (<strong>_theme/styles.scss</strong>) and import this new settings file.</p>
6+
<h3 class="step">Activate theme settings.</h3>
7+
<p class="step-description">We're going to add some custom <a href="https://designsystem.digital.gov/documentation/settings/">USWDS settings</a> to our project. To do this, we're going to add them to our custom settings file: <strong>_theme/_uswds-theme.scss</strong>.</p>
8+
<p class="step-description">In <strong>_theme/_uswds-theme.scss</strong>, uncomment lines 11-14</p>
139
<div class="editor">
14-
<h4 class="filename"><span class="material-icons" aria-hidden="true">description</span> _theme/styles.scss</h4>
15-
<pre class="blur">// -------------------------------------
16-
// Import individual theme settings...
17-
</pre><pre class="remove">
18-
@import "uswds-theme-general";
19-
@import "uswds-theme-typography";
20-
@import "uswds-theme-spacing";
21-
@import "uswds-theme-color";
22-
@import "uswds-theme-utilities";
23-
@import "uswds-theme-components";</pre><pre class="blur">
24-
25-
// ...or use a custom theme file.
26-
</pre><pre class="remove">
27-
// @import "my-custom-theme";</pre><pre class="add">
28-
@import "uswds-theme";</pre>
29-
</div>
30-
<h3 class="step">Start the watch script.</h3>
31-
<div class="terminal">
32-
<pre>npx gulp watch</pre>
10+
<h4 class="filename"><span class="material-icons" aria-hidden="true">description</span> _theme/_uswds-theme.scss</h4>
11+
<pre class="remove">// @use "uswds-core" with (
12+
// $setting: value,
13+
// $setting: value
14+
// );</pre><pre class="add">
15+
@use "uswds-core" with (
16+
$setting: value,
17+
$setting: value
18+
);</pre>
3319
</div>
3420
<h3 class="step">Turn off compile notifications.</h3>
3521
<p class="step-description">Now, let's turn off all the verbose notification messages we see each time USWDS compiles. We're reading these, right?</p>
3622
<div class="editor">
3723
<h4 class="filename"><span class="material-icons" aria-hidden="true">description</span> _theme/_uswds-theme.scss</h4>
38-
<pre class="add">$theme-show-notifications: false;</pre>
24+
<pre class="blur">@use "uswds-core" with (</pre><pre class="remove">
25+
$setting: value,
26+
$setting: value</pre><pre class="add">
27+
$theme-show-notifications: false,
28+
</pre><pre class="blur">
29+
);</pre>
3930
</div>
4031
<p class="step-description">Save the file. Now, when the watch script runs you won't see all the messages.</p>
32+
<p class="step-description">So let's run the watch script again.</p>
33+
<div class="terminal">
34+
<pre>npx gulp watch</pre>
35+
</div>
4136
<h3 class="step">Change the project font.</h3>
4237
<p class="step-description">Let's use the same fonts we started with on this project: system fonts.</p>
4338
<div class="editor">
4439
<h4 class="filename"><span class="material-icons" aria-hidden="true">description</span> _theme/_uswds-theme.scss</h4>
45-
<pre class="blur">$theme-show-notifications: false;</pre><pre class="add">
46-
$theme-font-type-sans: "system";</pre>
40+
<pre class="blur">@use "uswds-core" with (
41+
$theme-show-notifications: false,</pre><pre class="add">
42+
$theme-font-type-sans: "system",</pre><pre class="blur">
43+
);</pre>
4744
</div>
4845
<p class="step-description">Save, recompile, and hard reload. Looking good!</p>
4946
<p class="step-description">Now, for fun, let's try using Public Sans here. It's not too different from system fonts, it looks the same on all browsers, and it's a USWDS font.</p>
5047
<div class="editor">
5148
<h4 class="filename"><span class="material-icons" aria-hidden="true">description</span> _theme/_uswds-theme.scss</h4>
52-
<pre class="blur">$theme-show-notifications: false;</pre><pre class="remove">
53-
$theme-font-type-sans: "system";</pre><pre class="add">
54-
$theme-font-type-sans: "public-sans";</pre>
55-
</div>
49+
<pre class="blur">@use "uswds-core" with (
50+
$theme-show-notifications: false,</pre><pre class="remove">
51+
$theme-font-type-sans: "system",</pre><pre class="add">
52+
$theme-font-type-sans: "public-sans",</pre><pre class="blur">
53+
);</pre>
54+
</div>
5655
<p class="step-description">We can also activate an extra bold font weight to better match the weight of the original fonts.</p>
5756
<div class="editor">
5857
<h4 class="filename"><span class="material-icons" aria-hidden="true">description</span> _theme/_uswds-theme.scss</h4>
59-
<pre class="blur">$theme-show-notifications: false;</pre><pre class="blur">
60-
$theme-font-type-sans: "public-sans";</pre><pre class="add">
61-
$theme-font-weight-heavy: 900;</pre>
58+
<pre class="blur">@use "uswds-core" with (
59+
$theme-show-notifications: false,
60+
$theme-font-type-sans: "public-sans",</pre><pre class="add">
61+
$theme-font-weight-heavy: 900,</pre><pre class="blur">
62+
);</pre>
6263
</div>
6364
<h3 class="step">Customize the Banner.</h3>
64-
<p class="step-description">Now we'll update some Banner settings to better match our site. We'll give the banner a dark background, use indigo for a link color, and widen the Banner so the text starts further to the left.</p>
65+
<p class="step-description">Now we'll update some <a href="https://designsystem.digital.gov/documentation/settings/#banner">Banner settings</a> to better match our site. We'll give the banner a dark background, use indigo for a link color, and widen the Banner so the text starts further to the left.</p>
6566
<div class="editor">
6667
<h4 class="filename"><span class="material-icons" aria-hidden="true">description</span> _theme/_uswds-theme.scss</h4>
67-
<pre class="blur">$theme-show-notifications: false;</pre><pre class="blur">
68-
$theme-font-type-sans: "public-sans";
69-
$theme-font-weight-heavy: 900;</pre><pre class="add">
70-
$theme-banner-background-color: "ink";
71-
$theme-banner-link-color: "indigo-30";
72-
$theme-banner-max-width: none;</pre>
68+
<pre class="blur">@use "uswds-core" with (
69+
$theme-show-notifications: false,
70+
$theme-font-type-sans: "public-sans",
71+
$theme-font-weight-heavy: 900,</pre><pre class="add">
72+
$theme-banner-background-color: "ink",
73+
$theme-banner-link-color: "indigo-30",
74+
$theme-banner-max-width: none,</pre><pre class="blur">
75+
);</pre>
7376
</div>
7477
<h3 class="step">Customize the Identifier.</h3>
7578
<p class="step-description">Finally, we'll widen the Identifier to match the Banner!</p>
7679
<div class="editor">
7780
<h4 class="filename"><span class="material-icons" aria-hidden="true">description</span> _theme/_uswds-theme.scss</h4>
78-
<pre class="blur">$theme-show-notifications: false;</pre><pre class="blur">
79-
$theme-font-type-sans: "public-sans";
80-
$theme-font-weight-heavy: 900;
81-
$theme-banner-background-color: "ink";
82-
$theme-banner-link-color: "indigo-30";
83-
$theme-banner-max-width: none;</pre><pre class="add">
84-
$theme-identifier-max-width: none;</pre>
85-
</div>
81+
<pre class="blur">@use "uswds-core" with (
82+
$theme-show-notifications: false,
83+
$theme-font-type-sans: "public-sans",
84+
$theme-font-weight-heavy: 900,
85+
$theme-banner-background-color: "ink",
86+
$theme-banner-link-color: "indigo-30",
87+
$theme-banner-max-width: none,</pre><pre class="add">
88+
$theme-identifier-max-width: none,</pre><pre class="blur">
89+
);</pre>
90+
</div>
8691
<p class="step-description">Save the settings file, wait for compile, and hard reload if needed.</p>
8792
<h3 class="step">Remove unnecessary styles.</h3>
88-
<p class="step-description">Now we've added the Banner and Identifier, but if we look at the size of our compiled CSS, it's quite large — over 400 KB! We can greatly reduce the size by using USWDS packages.</p>
89-
<p class="step-description">Let's open up the USWDS Sass entry point (<strong>_theme/styles.scss</strong>), uncomment the packages we need, and comment out the main <strong>uswds</strong> package.</p>
93+
<p class="step-description">Now we've added the Banner and Identifier, but if we look at the size of our compiled CSS, it's quite large — over 400 KB! We can greatly reduce the size by using <a href="https://designsystem.digital.gov/components/packages/">USWDS packages</a>.</p>
94+
<p class="step-description">Let's open up the USWDS Sass entry point (<strong>_theme/styles.scss</strong>), remove the main <strong>uswds</strong> package, and add both the <strong>usa-banner</strong> and the <strong>usa-identifier</strong> packages.</p>
9095
<div class="editor">
9196
<h4 class="filename"><span class="material-icons" aria-hidden="true">description</span> _theme/styles.scss</h4>
92-
<pre class="blur">// -------------------------------------
93-
// Import individual USWDS packages...
94-
// See https://designsystem.digital.gov/components/
95-
96-
// First import required and global packages...</pre><pre class="remove">
97-
// @import 'packages/required';
98-
// @import 'packages/global';</pre><pre class="add">
99-
@import 'packages/required';
100-
@import 'packages/global';
101-
</pre><pre class="blur">
102-
103-
// Then import individual component packages...
104-
// @import 'packages/form-controls';
105-
// @import 'packages/form-templates';
106-
// @import 'packages/layout-grid';
107-
// @import 'packages/typography';
108-
// @import 'packages/validation';
109-
// @import 'packages/usa-accordion';
110-
// @import 'packages/usa-alert';</pre><pre class="remove">
111-
// @import 'packages/usa-banner';</pre><pre class="add">
112-
@import 'packages/usa-banner';</pre><pre class="blur">
113-
// @import 'packages/usa-breadcrumb';
114-
// @import 'packages/usa-button-group';
115-
// @import 'packages/usa-button';
116-
// @import 'packages/usa-card';
117-
// @import 'packages/usa-checklist';
118-
// @import 'packages/usa-collection';
119-
// @import 'packages/usa-footer';
120-
// @import 'packages/usa-header';
121-
// @import 'packages/usa-hero';
122-
// @import 'packages/usa-icon-list';
123-
// @import 'packages/usa-icon';</pre><pre class="remove">
124-
// @import 'packages/usa-identifier';</pre><pre class="add">
125-
@import 'packages/usa-identifier';</pre><pre class="blur">
126-
// @import 'packages/usa-layout';
127-
// @import 'packages/usa-link';
128-
// @import 'packages/usa-media-block';
129-
// @import 'packages/usa-megamenu';
130-
// @import 'packages/usa-modal';
131-
// @import 'packages/usa-nav-container';
132-
// @import 'packages/usa-nav';
133-
// @import 'packages/usa-navbar';
134-
// @import 'packages/usa-pagination';
135-
// @import 'packages/usa-process-list';
136-
// @import 'packages/usa-search';
137-
// @import 'packages/usa-section';
138-
// @import 'packages/usa-sidenav';
139-
// @import 'packages/usa-site-alert';
140-
// @import 'packages/usa-skipnav';
141-
// @import 'packages/usa-step-indicator';
142-
// @import 'packages/usa-summary-box';
143-
// @import 'packages/usa-table';
144-
// @import 'packages/usa-tag';
145-
146-
// or package sets...
147-
// @import 'packages/uswds-components';
148-
// @import 'packages/uswds-utilities';
149-
150-
// -------------------------------------
151-
// ...or import the complete USWDS kit
152-
153-
</pre><pre class="remove">
154-
@import "uswds";</pre><pre class="add">
155-
// @import "uswds";</pre>
97+
<pre class="blur">@forward "uswds-theme";</pre><pre class="remove">
98+
@forward "uswds";</pre><pre class="add">
99+
@forward "usa-banner";
100+
@forward "usa-identifier";</pre><pre class="blur">
101+
@forward "uswds-theme-custom-styles";</pre>
156102
</div>
157-
<p class="step-description">After you recompile, you'll see that the CSS size drops down to 59 KB — over 80% smaller.</p>
103+
<p class="step-description">After you recompile, you'll see that the CSS size drops down to 59 KB — over 80% smaller. And it compiles in less than a second!</p>
158104
<p class="step-description">Congratulations! You now have a site that integrates USWDS, uses two key USWDS components, adapts USWDS to fit your project tone, and uses less extraneous code.</p>
159105
</section>

_includes/sxs/part-four.html

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ <h4 class="filename"><span class="material-icons" aria-hidden="true">description
88
<pre class="blur">&lt;head&gt;
99
&lt;meta charset="utf-8"&gt;
1010
...
11-
&lt;link rel="stylesheet" href="&lcub;&lcub; '/assets/css/open-props.css' | relative_url &rcub;&rcub;"&gt;</pre><pre class="add">
12-
&lt;link rel="stylesheet" href="&lcub;&lcub; '/assets/uswds/css/styles.css' | relative_url &rcub;&rcub;"&gt;</pre><pre class="blur">
13-
&lt;link rel="stylesheet" href="&lcub;&lcub; '/assets/css/styles.css' | relative_url &rcub;&rcub;"&gt;
11+
&lt;link rel="stylesheet" href="&lcub;&lcub; '/assets/css/open-props.css' | url &rcub;&rcub;"&gt;</pre><pre class="add">
12+
&lt;link rel="stylesheet" href="&lcub;&lcub; '/assets/uswds/css/styles.css' | url &rcub;&rcub;"&gt;</pre><pre class="blur">
13+
&lt;link rel="stylesheet" href="&lcub;&lcub; '/assets/css/styles.css' | url &rcub;&rcub;"&gt;
1414
...</pre>
1515
</div>
1616
<h3 class="step">Add USWDS initializer to the site head.</h3>
@@ -20,10 +20,10 @@ <h4 class="filename"><span class="material-icons" aria-hidden="true">description
2020
<pre class="blur">&lt;head&gt;
2121
&lt;meta charset="utf-8"&gt;
2222
...
23-
&lt;link rel="stylesheet" href="&lcub;&lcub; '/assets/css/open-props.css' | relative_url &rcub;&rcub;"&gt;
24-
&lt;link rel="stylesheet" href="&lcub;&lcub; '/assets/uswds/css/styles.css' | relative_url &rcub;&rcub;"&gt;
25-
&lt;link rel="stylesheet" href="&lcub;&lcub; '/assets/css/styles.css' | relative_url &rcub;&rcub;"&gt;</pre><pre class="add">
26-
&lt;script src="&lcub;&lcub; '/assets/uswds/js/uswds-init.min.js' | relative_url &rcub;&rcub;"&gt;&lt;/script&gt;</pre><pre class="blur">
23+
&lt;link rel="stylesheet" href="&lcub;&lcub; '/assets/css/open-props.css' | url &rcub;&rcub;"&gt;
24+
&lt;link rel="stylesheet" href="&lcub;&lcub; '/assets/uswds/css/styles.css' | url &rcub;&rcub;"&gt;
25+
&lt;link rel="stylesheet" href="&lcub;&lcub; '/assets/css/styles.css' | url &rcub;&rcub;"&gt;</pre><pre class="add">
26+
&lt;script src="&lcub;&lcub; '/assets/uswds/js/uswds-init.min.js' | url &rcub;&rcub;"&gt;&lt;/script&gt;</pre><pre class="blur">
2727
</head>
2828
</pre>
2929
</div>
@@ -35,7 +35,7 @@ <h4 class="filename"><span class="material-icons" aria-hidden="true">description
3535

3636
&lt;body class="&lcub;&lcub; page.body &rcub;&rcub;"&gt;
3737
&lcub;&lcub; content }}</pre><pre class="add">
38-
&lt;script src="&lcub;&lcub; '/assets/uswds/js/uswds.min.js' | relative_url &rcub;&rcub;"&gt;&lt;/script&gt;</pre><pre class="blur">
38+
&lt;script src="&lcub;&lcub; '/assets/uswds/js/uswds.min.js' | url &rcub;&rcub;"&gt;&lt;/script&gt;</pre><pre class="blur">
3939
&lt;/body&gt;
4040
</pre>
4141
</div>

_includes/sxs/part-seven.html

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ <h3 class="step">Import your project styles into USWDS custom styles.</h3>
1010
<p class="step-description">In your text editor, open <strong>_theme/_uswds-theme-custom-styles.scss</strong>. We'll connect USWDS styles and our existing project styles by "importing" our project styles into the USWDS custom styles file.</p>
1111
<div class="editor">
1212
<h4 class="filename"><span class="material-icons" aria-hidden="true">description</span> _theme/_uswds-theme-custom-styles.scss</h4>
13-
<pre class="add">@import "../assets/css/styles.scss";</pre>
13+
<pre class="add">@forward "../assets/css/styles.scss";</pre>
1414
</div>
1515
<p class="step-description">Once you've updated this file, you can save and close it.</p>
1616
<h3 class="step">Add our project Sass source directory to the gulpfile.</h3>
@@ -48,17 +48,19 @@ <h3 class="step">Delete the original project styles.</h3>
4848
<pre>rm assets/css/styles.css</pre>
4949
</div>
5050
<h3 class="step">Use the watch script to watch for changes and recompile.</h3>
51-
<p class="step-description">In the open terminal window, run the <strong>compile</strong> script to compile our combined styles and watch for future changes.</p>
51+
<p class="step-description">In the open terminal window, run the <strong>watch</strong> script to compile our combined styles and watch for future changes.</p>
5252
<div class="terminal">
5353
<pre>npx gulp watch</pre>
5454
</div>
5555
<h3 class="step">Use USWDS color tokens for project colors.</h3>
5656
<p class="step-description">Our tutorial project uses CSS custom properties (otherwise known as "CSS variables" or "custom props"). We can update the value of those custom properties to use USWDS design tokens.</p>
5757
<p class="step-description">We'll add our updated custom properties to a new <strong>:root</strong> element, and we'll assign each updated property a <a href="https://designsystem.digital.gov/design-tokens/color/system-tokens/">USWDS system color token</a>, accessed with the <a href="https://designsystem.digital.gov/design-tokens/color/system-tokens/#using-color-tokens">USWDS <strong>color()</strong> function</a>.</p>
58+
<p class="step-description">To use these USWDS functions, we'll first tell Sass where to find USWDS functions, and that's in a package called <strong>uswds-core</strong>. We'll add a Sass <strong>use</strong> directive to make this connection.</p>
5859
<p class="step-description"><strong>Advanced note:</strong> If you're already familiar with Sass and functions, you'll see that when writing CSS custom properties, you need to use <a href="https://sass-lang.com/documentation/interpolation">Sass interpolation syntax</a> instead of regular functions. Anywhere else in the codebase, you can use regular functions, but custom properties require Sass interpolation.</p>
5960
<div class="editor">
6061
<h4 class="filename"><span class="material-icons" aria-hidden="true">description</span> assets/css/styles.scss</h4>
61-
<pre class="add">:root {
62+
<pre class="add">@use "uswds-core" as *;
63+
:root {
6264
--blue-2: #{color("blue-warm-20v")};
6365
--blue-3: #{color("blue-warm-30v")};
6466
--blue-8: #{color("blue-warm-50v")};

0 commit comments

Comments
 (0)