Skip to content

Commit 5221d70

Browse files
authored
Merge pull request #39 from uswds/cm-mc-instruction-refinement
March MC - Instruction Refinement
2 parents 0c254e7 + c4be99b commit 5221d70

6 files changed

Lines changed: 102 additions & 86 deletions

File tree

_includes/sxs/02-extending/part-three.html

Lines changed: 66 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ <h3 class="step">Create a the markup for a new component.</h3>
66
Visit <strong>_includes/sxs/02-extending/testimonial.html</strong>. This will be where we will add the markup for our new component. Once the markup is filled out, it will appear beneath our custom card component!
77
</p>
88
<p class="step-description">
9-
Start by adding the basic skeleton of the component. We'll need an outer div, a body, and footer section. We'll call this component <strong>ut-testimonial</strong>.
9+
Start by adding the basic skeleton of the component. We'll need an outer div, a body, and footer section. We'll call this component <strong>my-testimonial</strong>.
1010
</p>
1111
<div class="editor">
1212
<h4 class="filename"><span class="material-icons" aria-hidden="true">description</span> _includes/sxs/02-extending/testimonial.html</h4>
1313
<pre class="add">
14-
&lt;div class="ut-testimonial"&gt;
15-
&lt;div class="ut-testimonial__body"&gt;&lt;/div&gt;
16-
&lt;div class="ut-testimonial__footer"&gt;&lt;/div&gt;
14+
&lt;div class="my-testimonial"&gt;
15+
&lt;div class="my-testimonial__body"&gt;&lt;/div&gt;
16+
&lt;div class="my-testimonial__footer"&gt;&lt;/div&gt;
1717
&lt;/div&gt;
1818
</pre>
1919
</div>
@@ -22,13 +22,13 @@ <h4 class="filename"><span class="material-icons" aria-hidden="true">description
2222
</p>
2323
<div class="editor">
2424
<h4 class="filename"><span class="material-icons" aria-hidden="true">description</span> _includes/sxs/02-extending/testimonial.html</h4>
25-
<pre class="blur">&lt;div class="ut-testimonial"&gt;</pre>
26-
<pre class="add"> &lt;div class="ut-testimonial__body"&gt;
25+
<pre class="blur">&lt;div class="my-testimonial"&gt;</pre>
26+
<pre class="add"> &lt;div class="my-testimonial__body"&gt;
2727
&lt;p&gt;
2828
"Wow, this component sure is great"
2929
&lt;/p&gt;
3030
&lt;/div&gt;</pre>
31-
<pre class="blur"> &lt;div class="ut-testimonial__footer"&gt;&lt;/div&gt;
31+
<pre class="blur"> &lt;div class="my-testimonial__footer"&gt;&lt;/div&gt;
3232
&lt;/div&gt;
3333
</pre>
3434
</div>
@@ -37,82 +37,87 @@ <h4 class="filename"><span class="material-icons" aria-hidden="true">description
3737
</p>
3838
<div class="editor">
3939
<h4 class="filename"><span class="material-icons" aria-hidden="true">description</span> _includes/sxs/02-extending/testimonial.html</h4>
40-
<pre class="blur">&lt;div class="ut-testimonial"&gt;
40+
<pre class="blur">&lt;div class="my-testimonial"&gt;
4141
...
42-
&lt;div class="ut-testimonial__footer"&gt;</pre>
43-
<pre class="add"> &lt;img src="https://doodleipsum.com/100x100/avatar-5?bg=a5a8eb&shape=circle&n=1" class="ut-testimonial__icon" alt="Profile pic"&gt;
44-
&lt;div class="ut-testimonial__profile"&gt;
45-
&lt;p class="ut-testimonial__profile-name"&gt;Person McGuy&lt;/p&gt;
46-
&lt;p class="ut-testimonial__profile-title"&gt;USWDS User&lt;/p&gt;
42+
&lt;div class="my-testimonial__footer"&gt;</pre>
43+
<pre class="add"> &lt;img src="https://doodleipsum.com/100x100/avatar-5?bg=a5a8eb&shape=circle&n=1" class="my-testimonial__icon" alt="Profile pic"&gt;
44+
&lt;div class="my-testimonial__profile"&gt;
45+
&lt;p class="my-testimonial__profile-name"&gt;Person McGuy&lt;/p&gt;
46+
&lt;p class="my-testimonial__profile-title"&gt;USWDS User&lt;/p&gt;
4747
&lt;/div&gt;
4848
</pre>
4949
<pre class="blur">&lt;/div&gt;</pre>
5050
</div>
5151
<p class="step-description">
52-
Lastly, lets add a quotation icon for some visual flare! Visit the <a href="https://designsystem.digital.gov/components/icon/">Icon component</a> page, search for <strong>quote</strong>, and click the search result to copy the icons markup. Paste this markup directly after the opening <strong>ut-testimonial</strong> div.
52+
Lastly, lets add a quotation icon for some visual flare! Visit the <a href="https://designsystem.digital.gov/components/icon/">Icon component</a> page, search for <strong>quote</strong>, and click the search result to copy the icons markup. Paste this markup directly after the opening <strong>my-testimonial</strong> div.
5353
</p>
5454
<div class="editor">
5555
<h4 class="filename"><span class="material-icons" aria-hidden="true">description</span> _includes/sxs/02-extending/testimonial.html</h4>
56-
<pre class="blur">&lt;div class="ut-testimonial"&gt;</pre>
57-
<pre class="add"> &lt;svg class="usa-icon" aria-hidden="true" focusable="false" role="img"&gt;
58-
&lt;use xlink:href="/assets/uswds/img/sprite.svg#format_quote"&gt;
59-
&lt;/use&gt;
60-
&lt;/svg&gt;</pre><pre class="blur">&lt;div class="ut-testimonial__body"&gt;&lt;/div&gt;</pre>
56+
<pre class="blur">&lt;div class="my-testimonial"&gt;</pre>
57+
<pre class="add"> &lt;svg class="usa-icon my-testimonial__icon" aria-hidden="true" focusable="false" role="img"&gt;
58+
&lt;use xlink:href="/assets/uswds/img/sprite.svg#format_quote"&gt;
59+
&lt;/use&gt;
60+
&lt;/svg&gt;</pre><pre class="blur">&lt;div class="my-testimonial__body"&gt;&lt;/div&gt;</pre>
6161
</div>
6262
<h3 class="step">Add stylesheet partial.</h3>
6363
<p class="step-description">
6464
Create a new stylesheet partial for our new component.
6565
</p>
6666
<div class="terminal">
67-
<pre>touch assets/css/components/_ut-testimonial.scss</pre>
67+
<pre>touch assets/css/components/_my-testimonial.scss</pre>
6868
</div>
6969
<p class="step-description">
7070
Remember to import the new stylesheet into USWDS custom styles.
7171
</p>
7272
<div class="editor">
7373
<h4 class="filename"><span class="material-icons" aria-hidden="true">description</span> _theme/_uswds-theme-custom-styles.scss</h4>
7474
<pre class="blur">@use "uswds-core" as *;
75-
@forward "../assets/css/styles.scss";
76-
@forward "../assets/css/_ut-card.scss";
77-
</pre><pre class="add"> @forward "../assets/css/_ut-testimonial.scss";</pre>
75+
@forward "../assets/css/styles.scss";
76+
@forward "../assets/css/_my-card.scss";
77+
</pre><pre class="add">@forward "../assets/css/_my-testimonial.scss";</pre>
7878
</div>
7979
<h3 class="step">Start styling the component.</h3>
8080
<p class="step-description">
8181
Just like using the <strong>color()</strong> function to use USWDS color tokens, we can use <strong>units()</strong> to allow native CSS properties to make use of USWDS spacing tokens. To get our base styles for our new component, add the following styles to the new stylesheet.
8282
</p>
8383
<div class="editor">
84-
<h4 class="filename"><span class="material-icons" aria-hidden="true">description</span> assets/css/components/ut-testimonial.scss</h4>
84+
<h4 class="filename"><span class="material-icons" aria-hidden="true">description</span> assets/css/components/my-testimonial.scss</h4>
8585
<pre class="add">
8686
@use "uswds-core" as *;
87-
88-
.ut-testimonial {
87+
88+
.my-testimonial {
8989
background-color: color("indigo-10");
9090
padding: units(3);
9191
}
9292

93-
.ut-testimonial__body p {
93+
.my-testimonial__icon {
94+
fill: color("indigo-30");
95+
stroke: color("indigo-30");
96+
}
97+
98+
.my-testimonial__body p {
9499
text-align: center;
95100
}
96-
97-
.ut-testimonial__footer {
101+
102+
.my-testimonial__footer {
98103
display: flex;
99104
flex-direction: row;
100105
margin-top: units(3);
101106
}
102-
103-
.ut-testimonial img {
107+
108+
.my-testimonial img {
104109
@include u-circle(10);
105110
}
106-
107-
.ut-testimonial__profile {
111+
112+
.my-testimonial__profile {
108113
margin-left: units(3)
109114
}
110-
111-
.ut-testimonial__profile-name {
115+
116+
.my-testimonial__profile-name {
112117
color: color("indigo-70v");
113118
}
114-
115-
.ut-testimonial__profile-title {
119+
120+
.my-testimonial__profile-title {
116121
margin-top: units(0);
117122
}
118123
</pre>
@@ -122,37 +127,48 @@ <h4 class="filename"><span class="material-icons" aria-hidden="true">description
122127
</p>
123128
<h3 class="step">Styling the testimonial icon</h3>
124129
<p class="step-description">
125-
USWDS uses variables to maintain consistent styles across different definitions. Lets create a variable for our icon stroke and fill at the top of our stylesheet.
130+
USWDS uses variables to maintain consistent styles across different definitions. Let's create a variable for our icon stroke and fill at the top of our stylesheet.
126131
</p>
127132
<div class="editor">
128-
<h4 class="filename"><span class="material-icons" aria-hidden="true">description</span> assets/css/components/ut-testimonial.scss</h4>
133+
<h4 class="filename"><span class="material-icons" aria-hidden="true">description</span> assets/css/components/my-testimonial.scss</h4>
129134
<pre class="blur">@use "uswds-core" as *;
130135

131136
</pre>
132-
<pre class="add">$ut-testimonial-icon-color: color("indigo-30");
137+
<pre class="add">
138+
$my-testimonial-icon-color: color("indigo-30");
139+
</pre>
140+
<pre class="blur">
133141

134-
.ut-testimonial__icon {
135-
fill: $ut-testimonial-icon-color;
136-
stroke: $ut-testimonial-icon-color;
137-
}
142+
...
143+
144+
.my-testimonial__icon {
138145
</pre>
146+
<pre class="remove">
147+
fill: color("indigo-30");
148+
stroke: color("indigo-30");
149+
</pre>
150+
<pre class="add">
151+
fill: $my-testimonial-icon-color;
152+
stroke: $my-testimonial-icon-color;
153+
</pre>
154+
<pre class="blur">}</pre>
139155
</div>
140156
<h3 class="step">Using USWDS utility mixins.</h3>
141157
<p class="step-description">
142158
USWDS also offers an extensive library of utility mixins which you can use to simplify style setting. Let's use some of the typeset mixins to customize our font weight and size. It's standard convention to include your mixins at the top of each style definition.
143159
</p>
144160
<div class="editor">
145-
<h4 class="filename"><span class="material-icons" aria-hidden="true">description</span> assets/css/components/ut-testimonial.scss</h4>
146-
<pre class="blur">.ut-testimonial__body p {
161+
<h4 class="filename"><span class="material-icons" aria-hidden="true">description</span> assets/css/components/my-testimonial.scss</h4>
162+
<pre class="blur">.my-testimonial__body p {
147163
</pre>
148-
<pre class="add"> @include u-font-size("heading", "xl");
164+
<pre class="add"> font-size: size("heading", "xl");
149165
font-weight: font-weight("bold");</pre>
150166
<pre class="blur"> text-align: center;
151167
}
152168

153169
...
154170

155-
.ut-testimonial__profile-title {
171+
.my-testimonial__profile-title {
156172
margin-top: units(0);
157173
</pre><pre class="add"> font-size: font-size("body", 5)</pre>
158174
<pre class="blur">}</pre>
@@ -162,8 +178,8 @@ <h3 class="step">Using uswds theme tokens with mixins</h3>
162178
Finally, lets use a combination of utility mixins and uswds theme settings to display how you can add uniformity across your project! In this example, we'll add the border settings from step one to help our new component sit nicely with the original card.
163179
</p>
164180
<div class="editor">
165-
<h4 class="filename"><span class="material-icons" aria-hidden="true">description</span> assets/css/components/ut-testimonial.scss</h4>
166-
<pre class="blur">.ut-testimonial {</pre>
181+
<h4 class="filename"><span class="material-icons" aria-hidden="true">description</span> assets/css/components/my-testimonial.scss</h4>
182+
<pre class="blur">.my-testimonial {</pre>
167183
<pre class="add"> @include u-margin-x(1);
168184
@include u-border($theme-card-border-width);
169185
@include u-radius($theme-card-border-radius);</pre>

_includes/sxs/02-extending/part-two.html

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ <h3 class="step">Add a custom class for our new variant.</h3>
88
We'll use this class to identify our custom card component and assign custom styles.
99
</p>
1010
<p class="step-description">
11-
When adding custom classes we recommend using a two to three letter prefix to identify the organization it belongs to. USWDS primarily uses <strong>usa-</strong>. Since this is a <strong>U</strong>SWDS <strong>T</strong>utorial, lets use <strong>ut-</strong>card as our custom class.
11+
When adding custom classes we recommend using a two to three letter prefix to identify the organization it belongs to. USWDS primarily uses <strong>usa-</strong>. For this example, lets use <strong>my-</strong>card as our custom class.
1212
</p>
1313
<div class="editor">
1414
<h4 class="filename"><span class="material-icons" aria-hidden="true">description</span> _includes/sxs/02-extending/card.html</h4>
1515
<pre class="remove">&lt;div class="usa-card"&gt;</pre>
16-
<pre class="add">&lt;div class="usa-card ut-card"&gt;</pre>
16+
<pre class="add">&lt;div class="usa-card my-card"&gt;</pre>
1717
<pre class="blur"> &lt;div class="usa-card__container"&gt;
1818
&lt;div class="usa-card__header"&gt;</pre>
1919
</div>
@@ -22,13 +22,13 @@ <h3 class="step">Create a custom stylesheet for our custom card component.</h3>
2222
To help keep things organized, we'll create a custom stylesheet with styles specific to our customized card component. In later exercises, we'll use this same stylesheet to extend the card component into a new custom component. First, lets add a <strong>components</strong> directory to our css assets.
2323
</p>
2424
<div class="terminal">
25-
<pre>mkdir assets/css/components</pre>
25+
<pre>mkdir _theme/components</pre>
2626
</div>
2727
<p class="step-description">
28-
This pattern will allow us to organize CSS partials an a logical structure. Let's now add our new <strong>ut-card</strong> stylesheet. It's standard naming convention to prefix CSS partials with an underscore.
28+
This pattern will allow us to organize CSS partials an a logical structure. Let's now add our new <strong>my-card</strong> stylesheet. It's standard naming convention to prefix CSS partials with an underscore.
2929
</p>
3030
<div class="terminal">
31-
<pre>touch assets/css/components/_ut-card.scss</pre>
31+
<pre>touch _theme/components/_my-card.scss</pre>
3232
</div>
3333
<h3 class="step">Import the new stylesheet into USWDS custom styles.</h3>
3434
<p class="step-description">
@@ -37,8 +37,8 @@ <h3 class="step">Import the new stylesheet into USWDS custom styles.</h3>
3737
<div class="editor">
3838
<h4 class="filename"><span class="material-icons" aria-hidden="true">description</span> _theme/_uswds-theme-custom-styles.scss</h4>
3939
<pre class="blur">@use "uswds-core" as *;
40-
@forward "../assets/css/styles.scss";
41-
</pre><pre class="add">@forward "../assets/css/_ut-card.scss";</pre>
40+
@forward "../assets/css/styles.scss";
41+
</pre><pre class="add">@forward "../assets/css/_my-card.scss";</pre>
4242
</div>
4343
<p class="step-description">
4444
Once you've updated this file, you can save and close it. Since we've added our project Sass source directory to our gulpfile in the first part of the tutorial, it should already be compiling correctly!
@@ -51,16 +51,16 @@ <h3 class="step">Use USWDS utilities in custom styles</h3>
5151
We'll want to use USWDS design tokens in our stylesheets using USWDS functions and mixins. To do this, lets add <strong>uswds-core</strong> to the top of our new stylesheet with the <strong>use</strong> Sass directive.
5252
</p>
5353
<div class="editor">
54-
<h4 class="filename"><span class="material-icons" aria-hidden="true">description</span> assets/css/components/_ut-card.scss</h4>
54+
<h4 class="filename"><span class="material-icons" aria-hidden="true">description</span> assets/css/components/_my-card.scss</h4>
5555
<pre class="add">@use "uswds-core" as *;</pre>
5656
</div>
5757
<h3 class="step">Add custom class and styles</h3>
5858
<p class="step-description">
5959
Next lets create a custom class for our personalized component and use some USWDS utilities. We'll start by updating the background color of the card. We can use the <a href="https://designsystem.digital.gov/design-tokens/color/system-tokens/#using-color-tokens-2"><strong>color()</strong> function</a> to set the text and background color with USWDS <a href="https://designsystem.digital.gov/design-tokens/color/overview/">color tokens</a>.
6060
</p>
6161
<div class="editor">
62-
<h4 class="filename"><span class="material-icons" aria-hidden="true">description</span> assets/css/components/ut-card.scss</h4>
63-
<pre class="add">.ut-card .usa-card__container {
62+
<h4 class="filename"><span class="material-icons" aria-hidden="true">description</span> assets/css/components/my-card.scss</h4>
63+
<pre class="add">.my-card .usa-card__container {
6464
background-color: color("indigo-70v");
6565
color: color("indigo-30");
6666
}</pre>
@@ -72,8 +72,8 @@ <h4 class="filename"><span class="material-icons" aria-hidden="true">description
7272
USWDS also utilizes more advanced tools to automatically check color contrast. Replace our text and background color definitions with the combined <strong>set-text-and-bg</strong> mixin.
7373
</p>
7474
<div class="editor">
75-
<h4 class="filename"><span class="material-icons" aria-hidden="true">description</span> assets/css/components/ut-card.scss</h4>
76-
<pre class="blur">.ut-card .usa-card__container {</pre>
75+
<h4 class="filename"><span class="material-icons" aria-hidden="true">description</span> assets/css/components/my-card.scss</h4>
76+
<pre class="blur">.my-card .usa-card__container {</pre>
7777
<pre class="remove">
7878
background-color: color("indigo-70v");
7979
color: color("indigo-30");
@@ -86,8 +86,8 @@ <h4 class="filename"><span class="material-icons" aria-hidden="true">description
8686
If you inspect the compilation messages in the terminal, you'll actually see a warning these colors do not pass color contrast requirements! Lets use the magic number of 50+ to resolve this issue.
8787
</p>
8888
<div class="editor">
89-
<h4 class="filename"><span class="material-icons" aria-hidden="true">description</span> assets/css/components/ut-card.scss</h4>
90-
<pre class="blur">.ut-card .usa-card__container {</pre>
89+
<h4 class="filename"><span class="material-icons" aria-hidden="true">description</span> assets/css/components/my-card.scss</h4>
90+
<pre class="blur">.my-card .usa-card__container {</pre>
9191
<pre class="remove">
9292
@include set-text-and-bg("indigo-70v", "indigo-30");
9393
</pre><pre class="add">

_includes/testimonial.html

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
<div class="ut-testimonial">
2-
<svg class="usa-icon ut-testimonial__icon" aria-hidden="true" focusable="false" role="img" height="50px" width="50px">
1+
<div class="my-testimonial">
2+
<svg class="usa-icon my-testimonial__icon" aria-hidden="true" focusable="false" role="img" height="50px" width="50px">
33
<use xlink:href="/assets/uswds/img/sprite.svg#format_quote"></use>
44
</svg>
5-
<div class="ut-testimonial__body">
5+
<div class="my-testimonial__body">
66
<p>
77
"Wow, this component sure is great"
88
</p>
99
</div>
10-
<div class="ut-testimonial__footer">
10+
<div class="my-testimonial__footer">
1111
<img src="https://doodleipsum.com/100x100/avatar-5?bg=a5a8eb&shape=circle&n=1" alt="Profile pic">
12-
<div class="ut-testimonial__profile">
13-
<p class="ut-testimonial__profile-name">Person McGuy</p>
14-
<p class="ut-testimonial__profile-title">USWDS User</p>
12+
<div class="my-testimonial__profile">
13+
<p class="my-testimonial__profile-name">Person McGuy</p>
14+
<p class="my-testimonial__profile-title">USWDS User</p>
1515
</div>
1616
</div>
1717
</div>

_theme/_uswds-theme-custom-styles.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ i.e.
2222

2323
@use "uswds-core" as *;
2424
@forward "../assets/css/styles.scss";
25-
@forward "../assets/css/components/ut-card.scss";
26-
@forward "../assets/css/components/ut-testimonial.scss";
25+
@forward "../assets/css/components/_my-card.scss";
26+
@forward "../assets/css/components/_my-testimonial.scss";
2727

2828
:root {
2929
--blue-2: #{color("blue-warm-20v")};
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
@use "uswds-core" as *;
22

3-
.ut-card .usa-card__container {
3+
.my-card .usa-card__container {
44
// @include u-text("indigo-30");
55
// @include u-bg("indigo-70v");
66

77
@include set-text-and-bg("indigo-70v", "indigo-20")
88

9-
}
9+
}

0 commit comments

Comments
 (0)