You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: pages/documentation/getting-started-developers/phase-two.md
+29-19Lines changed: 29 additions & 19 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -34,25 +34,26 @@ U.S. Web Design System source code is written in Sass, a powerful stylesheet lan
34
34
35
35
## Introducing uswds-compile
36
36
37
-
We’ve developed `uswds-compile`, a tool [hosted on GitHub](https://github.com/uswds/uswds-compile), to help teams compile USWDS Sass files. This tool provides simple Gulp 4 functions that copy USWDS static assets into your project and transform USWDS Sass into browser-readable CSS. Additionally, `uswds-compile` applies Autoprefixer to all compiled code to make sure your CSS is browser-compatible.
37
+
We recommend using `uswds-compile`, a USWDS tool [hosted on GitHub](https://github.com/uswds/uswds-compile), as a quick way to get up and running with Sass compilation for USWDS.
38
38
39
-
We recommend using `uswds-compile`as a quick way to get up and running with Sass compilation for USWDS .
39
+
This tool provides simple Gulp 4 functions that copy USWDS static assets into your project and transform USWDS Sass into browser-readable CSS. Additionally, `uswds-compile`applies Autoprefixer to all compiled code to make sure your CSS is browser-compatible.
40
40
41
-
{: .site-note }
42
-
Note: One of the benefits of using `uswds-compile` is that it will set up a Sass entry point for you. If you plan on using `uswds-compile`, you can safely skip [About Sass entry points](#about-sass-entry-points) and jump straight to the [step-by-step instructions](#step-1-install-uswds-compile) that explain how to install and use `uswds-compile`.
41
+
Later in this guide we will walk you through setting up Sass compilation for your project with `uswds-compile`. To get started, jump ahead to the [Using uswds-compile](#using-uswds-compile) section below.
43
42
44
-
If you prefer to set up Sass compilation yourself, the next thing you'll need to do is set up (or edit) your Sass entry point.
43
+
## Loading USWDS Sass with a custom compiler
44
+
If you already have Sass compilation set up on your project, you'll need to load USWDS Sass and your USWDS settings configuration into your Sass entry point.
45
45
46
-
## About Sass entry points
46
+
###About Sass entry points
47
47
48
48
A project often has many Sass files, but typically, there’s a single file that serves as the root — the “homepage” of the Sass — that links out to the others. This root file is also known as the “Sass entry point.” The Sass entry point is the most important stylesheet file in your project because it tells the compiler what source files make up your Sass codebase. Often, a project's Sass entry point is named something like `index.scss` or `styles.scss`.
49
49
50
-
### Setting up USWDS in your Sass entry point
51
-
If your project does not yet have a Sass entry point, create a file called `index.scss` or `styles.scss`.
50
+
### Creating a Sass entry point
51
+
If your project does not yet have a Sass entry point, create a file called `index.scss` or `styles.scss`. This file will typically live at the root of your project's Sass directory.
52
52
53
-
Your project’s Sass entry point is a simple file that will only need to do the following three tasks:
53
+
### Loading USWDS in your Sass entry point
54
+
Your project’s Sass entry point is a simple file that will need to:
54
55
55
-
1. Load or define[USWDS settings]({{ site.baseurl }}/documentation/settings/) (required)
56
+
1. Load your project's[USWDS settings configuration]({{ site.baseurl }}/documentation/settings/) (required)
56
57
2. Load USWDS source code (required)
57
58
3. Load your project’s custom Sass (optional)
58
59
@@ -61,23 +62,23 @@ For your entry point to complete these tasks, you will need to add the following
61
62
```scss
62
63
/* styles.scss */
63
64
64
-
// 1. Load USWDS settings
65
-
@forward"uswds-settings.scss";
65
+
// 1. Load your project's USWDS settings configuration
66
+
@forward"uswds-theme.scss";
66
67
67
68
// 2. Load USWDS source code
68
69
@forward"./path/to/source/uswds";
69
70
70
71
// 3. Load your project's custom Sass
71
-
@forward"project-custom.scss";
72
+
@forward"project-styles.scss";
72
73
```
73
74
74
75
Note that each `@forward` reference in this example is tied to one of the tasks listed above.
75
76
76
77
In plain language, this code says:
77
78
78
-
1.**Get the instructions**: Get the USWDS settings that tell the Design System how to build the styles. Settings are the first thing you'll need to include in your entry point.
79
+
1.**Get the instructions**: Add the USWDS settings configuration that tells the Design System how to build the styles.
79
80
80
-
In USWDS, settings are Sass variables that can be configured via Sass' `@use...with()` rule. You can find full instructions for configuring USWDS settings, along with a list of all available settings, on the [Settings page]({{ site.baseurl }}/documentation/settings/).
81
+
Your settings configuration is the first thing you'll need to include in your entry point. Often, this configuration will live in its own file, which in this example is called `uswds-theme.scss`. You can find full instructions for configuring USWDS settings, along with a list of all available settings, on the [Settings page]({{ site.baseurl }}/documentation/settings/).
81
82
82
83
2.**Create the foundation**: Build all USWDS styles from these settings.
83
84
@@ -87,9 +88,12 @@ In plain language, this code says:
87
88
88
89
To load the `uswds` package, you must provide a path to its `index.scss` entry point. If you installed USWDS 3 with npm, the complete path to this file is: `./node_modules/@uswds/uswds/packages/uswds/_index.scss`.
89
90
90
-
3.**Build new work on top of that foundation**: Finally, add any custom project styles built from design system code.
91
+
3.**Build new work on top of that foundation**: Finally, add any custom project styles built from Design System code.
92
+
93
+
After you've loaded the USWDS source code, you can build new styles with USWDS design tokens, functions, and mixins. For the purposes of this guide, we won’t get into custom code, but the important thing to understand is that any custom code should follow the settings configuration and USWDS source code in your Sass entry point.
91
94
92
-
After you've loaded the USWDS source code, you can build new styles with USWDS design tokens, functions, and mixins. For the purposes of this guide, we won’t get into custom code, but the important thing to understand is that any custom code should follow the settings and USWDS source code in your Sass entry point.
95
+
{:.site-note}
96
+
**Note:** USWDS relies on [Autoprefixer](https://github.com/postcss/autoprefixer) to make its compiled CSS browser-compatible. If your compiler does not already use Autoprefixer, we strongly encourage that you add it to your project.
93
97
94
98
## Using uswds-compile
95
99
Complete the following steps to install, configure, and use `uswds-compile`:
Once installed, create a file called `gulpfile.js` at the root of your project by running the command `touch gulpfile.js` (alternatively, use an existing gulpfile if one already exists). This file will need to do the following:
111
+
If your project does not yet have a `gulpfile.js` file, create one at the root of your project by running this command:
112
+
113
+
```
114
+
touch gulpfile.js
115
+
```
116
+
117
+
This file will need to do the following:
108
118
109
119
1.[Import the `@uswds/compile` package](#step-3-import-the-uswds-compile-package)
110
120
2.[Set the project's USWDS version](#step-4-set-uswds-version)
@@ -241,7 +251,7 @@ npx gulp compile
241
251
242
252
When your `gulpfile.js` is ready, initialize your project to copy all the necessary Sass, image, font, and Javascript assets from the USWDS source code.
243
253
244
-
Initialize your project and get started by running the following command:
254
+
If you defined the `init` export in [Step 6](#step-6-export-compile-functions), you can initialize your project and get started by running the following command:
0 commit comments