Skip to content

Commit 892d253

Browse files
committed
Replace ut- references with my-
Update related prefix instructions Add final css from testimonial instruction
1 parent 758983f commit 892d253

6 files changed

Lines changed: 73 additions & 73 deletions

File tree

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

Lines changed: 39 additions & 39 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,34 +37,34 @@ <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 ut-testimonial__icon" aria-hidden="true" focusable="false" role="img"&gt;
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;
5858
&lt;use xlink:href="/assets/uswds/img/sprite.svg#format_quote"&gt;
5959
&lt;/use&gt;
60-
&lt;/svg&gt;</pre><pre class="blur">&lt;div class="ut-testimonial__body"&gt;&lt;/div&gt;</pre>
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 styleheet 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.
@@ -73,51 +73,51 @@ <h3 class="step">Add styleheet partial.</h3>
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 *;
7575
@forward "../assets/css/styles.scss";
76-
@forward "../assets/css/_ut-card.scss";
77-
</pre><pre class="add">@forward "../assets/css/_ut-testimonial.scss";</pre>
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 *;
8787

88-
.ut-testimonial {
88+
.my-testimonial {
8989
background-color: color("indigo-10");
9090
padding: units(3);
9191
}
9292

93-
.ut-testimonial__icon {
93+
.my-testimonial__icon {
9494
fill: color("indigo-30");
9595
stroke: color("indigo-30");
9696
}
9797

98-
.ut-testimonial__body p {
98+
.my-testimonial__body p {
9999
text-align: center;
100100
}
101101

102-
.ut-testimonial__footer {
102+
.my-testimonial__footer {
103103
display: flex;
104104
flex-direction: row;
105105
margin-top: units(3);
106106
}
107107

108-
.ut-testimonial img {
108+
.my-testimonial img {
109109
@include u-circle(10);
110110
}
111111

112-
.ut-testimonial__profile {
112+
.my-testimonial__profile {
113113
margin-left: units(3)
114114
}
115115

116-
.ut-testimonial__profile-name {
116+
.my-testimonial__profile-name {
117117
color: color("indigo-70v");
118118
}
119119

120-
.ut-testimonial__profile-title {
120+
.my-testimonial__profile-title {
121121
margin-top: units(0);
122122
}
123123
</pre>
@@ -130,26 +130,26 @@ <h3 class="step">Styling the testimonial icon</h3>
130130
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.
131131
</p>
132132
<div class="editor">
133-
<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>
134134
<pre class="blur">@use "uswds-core" as *;
135135

136136
</pre>
137137
<pre class="add">
138-
$ut-testimonial-icon-color: color("indigo-30");
138+
$my-testimonial-icon-color: color("indigo-30");
139139
</pre>
140140
<pre class="blur">
141141

142142
...
143143

144-
.ut-testimonial__icon {
144+
.my-testimonial__icon {
145145
</pre>
146146
<pre class="remove">
147147
fill: color("indigo-30");
148148
stroke: color("indigo-30");
149149
</pre>
150150
<pre class="add">
151-
fill: $ut-testimonial-icon-color;
152-
stroke: $ut-testimonial-icon-color;
151+
fill: $my-testimonial-icon-color;
152+
stroke: $my-testimonial-icon-color;
153153
</pre>
154154
<pre class="blur">}</pre>
155155
</div>
@@ -158,8 +158,8 @@ <h3 class="step">Using USWDS utility mixins.</h3>
158158
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.
159159
</p>
160160
<div class="editor">
161-
<h4 class="filename"><span class="material-icons" aria-hidden="true">description</span> assets/css/components/ut-testimonial.scss</h4>
162-
<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 {
163163
</pre>
164164
<pre class="add"> font-size: size("heading", "xl");
165165
font-weight: font-weight("bold");</pre>
@@ -168,7 +168,7 @@ <h4 class="filename"><span class="material-icons" aria-hidden="true">description
168168

169169
...
170170

171-
.ut-testimonial__profile-title {
171+
.my-testimonial__profile-title {
172172
margin-top: units(0);
173173
</pre><pre class="add"> font-size: font-size("body", 5)</pre>
174174
<pre class="blur">}</pre>
@@ -178,8 +178,8 @@ <h3 class="step">Using uswds theme tokens with mixins</h3>
178178
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.
179179
</p>
180180
<div class="editor">
181-
<h4 class="filename"><span class="material-icons" aria-hidden="true">description</span> assets/css/components/ut-testimonial.scss</h4>
182-
<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>
183183
<pre class="add"> @include u-margin-x(1);
184184
@include u-border($theme-card-border-width);
185185
@include u-radius($theme-card-border-radius);</pre>

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

Lines changed: 12 additions & 12 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>
@@ -25,10 +25,10 @@ <h3 class="step">Create a custom stylesheet for our custom card component.</h3>
2525
<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 _theme/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">
@@ -38,7 +38,7 @@ <h3 class="step">Import the new stylesheet into USWDS custom styles.</h3>
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 *;
4040
@forward "../assets/css/styles.scss";
41-
</pre><pre class="add">@forward "../assets/css/_ut-card.scss";</pre>
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 utiltities. 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+
}
Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,46 @@
11
@use "uswds-core" as *;
22

3-
$ut-testimonial-icon-color: color("indigo-30");
3+
$my-testimonial-icon-color: color("indigo-30");
44

5-
.ut-testimonial {
5+
.my-testimonial {
66
@include u-margin-x(1);
77
@include u-border($theme-card-border-width);
88
@include u-radius($theme-card-border-radius);
99
background-color: color("indigo-10");
1010
padding: units(3);
1111
}
1212

13-
.ut-testimonial__icon {
13+
.my-testimonial__icon {
1414
@include u-square(7);
15-
fill: $ut-testimonial-icon-color;
16-
stroke: $ut-testimonial-icon-color;
15+
fill: $my-testimonial-icon-color;
16+
stroke: $my-testimonial-icon-color;
1717
}
1818

19-
.ut-testimonial__body p {
19+
.my-testimonial__body p {
2020
@include u-font-size("heading", "xl");
2121
font-weight: font-weight("bold");
2222
text-align: center;
2323
}
2424

25-
.ut-testimonial__footer {
25+
.my-testimonial__footer {
2626
display: flex;
2727
flex-direction: row;
2828
margin-top: units(3);
2929
}
3030

31-
.ut-testimonial img {
31+
.my-testimonial img {
3232
@include u-circle(10);
3333
}
3434

35-
.ut-testimonial__profile {
35+
.my-testimonial__profile {
3636
margin-left: units(3);
3737
}
3838

39-
.ut-testimonial__profile-name {
39+
.my-testimonial__profile-name {
4040
color: color("indigo-70v");
4141
}
4242

43-
.ut-testimonial__profile-title {
43+
.my-testimonial__profile-title {
4444
margin-top: units(0);
4545
font-size: font-size("body", 5);
4646
}

0 commit comments

Comments
 (0)