Skip to content

Commit f0681d0

Browse files
committed
Merge branch 'jm-mc-setup' of https://github.com/uswds/uswds-tutorial into jm-mc-setup
2 parents 4ba006c + 5221d70 commit f0681d0

8 files changed

Lines changed: 132 additions & 61 deletions

File tree

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<h1>Part Two</h1>
33
<h2>Theming, customizing, extending</h2>
44
<p class="subhed">Take USWDS and make it your own.</p>
5-
<p class="subhed">In this section of the tutorial, you'll expand on theming components. Then you'll learn creating custom project styles for our components. Finally, you'll exend a component to create a custom component!</p>
5+
<p class="subhed">In this section of the tutorial, you'll expand on theming components. Then you'll learn creating custom project styles for our components. Finally, you'll extend a component to create a custom component!</p>
66
<h3>Contents</h3>
77
<ul class="contents">
88
<li>

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

Lines changed: 62 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
<section class="part three" id="part-three">
22
<h2><span>Part Three</span> Create a custom component</h2>
3-
<p>In this section we'll explore extending USWDS by creating a custom <strong>testmionial</strong> component not offered by the design system.</p>
3+
<p>In this section we'll explore extending USWDS by creating a custom <strong>testimonial</strong> component not offered by the design system.</p>
44
<h3 class="step">Create a the markup for a new component.</h3>
55
<p class="step-description">
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>
62-
<h3 class="step">Add styleheet partial.</h3>
62+
<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 *;
8787

88-
.ut-testimonial {
88+
.my-testimonial {
8989
background-color: color("indigo-10");
9090
padding: units(3);
9191
}
92+
93+
.my-testimonial__icon {
94+
fill: color("indigo-30");
95+
stroke: color("indigo-30");
96+
}
9297

93-
.ut-testimonial__body p {
98+
.my-testimonial__body p {
9499
text-align: center;
95100
}
96101

97-
.ut-testimonial__footer {
102+
.my-testimonial__footer {
98103
display: flex;
99104
flex-direction: row;
100105
margin-top: units(3);
101106
}
102107

103-
.ut-testimonial img {
108+
.my-testimonial img {
104109
@include u-circle(10);
105110
}
106111

107-
.ut-testimonial__profile {
112+
.my-testimonial__profile {
108113
margin-left: units(3)
109114
}
110115

111-
.ut-testimonial__profile-name {
116+
.my-testimonial__profile-name {
112117
color: color("indigo-70v");
113118
}
114119

115-
.ut-testimonial__profile-title {
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 {
145+
</pre>
146+
<pre class="remove">
147+
fill: color("indigo-30");
148+
stroke: color("indigo-30");
138149
</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: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ <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 your tutorial, lets use <strong>my-</strong>card as our custom class.
11+
When adding custom classes we recommend using a two- to three-letter prefix for clear identification. USWDS primarily uses <strong>usa-</strong>. Since this is your tutorial, 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/card.html</h4>
@@ -31,10 +31,10 @@ <h3 class="step">Open a new terminal window.</h3>
3131

3232
<h3 class="step">Create a custom stylesheet for our custom card component.</h3>
3333
<p class="step-description">
34-
To help keep things organized, we'll create a custom stylesheet with styles specific to our customized card component. In later excercises, 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.
34+
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.
3535
</p>
3636
<div class="terminal">
37-
<pre>mkdir assets/css/components</pre>
37+
<pre>mkdir _theme/components</pre>
3838
</div>
3939
<p class="step-description">
4040
Now let's add our new <strong>my-card</strong> stylesheet. It's standard naming convention to prefix CSS partials with an underscore (as we've already seen in <strong>_uswds-theme</strong> and <strong>_uswds-theme-custom-styles</strong>).
@@ -70,7 +70,7 @@ <h4 class="filename"><span class="material-icons" aria-hidden="true">description
7070
</div>
7171
<h3 class="step">Add custom class and styles</h3>
7272
<p class="step-description">
73-
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>.
73+
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>.
7474
</p>
7575
<div class="editor">
7676
<h4 class="filename"><span class="material-icons" aria-hidden="true">description</span> assets/css/components/my-card.scss</h4>

_includes/sxs/part-end.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ <h2><span>Next steps</span>Extending USWDS</h2>
55
</p>
66

77
<p>
8-
Before we go, we'll need to add a little additonal functionality to our stylesheets. We'll need USWDS Utilities and the USWDS Layout Grid for the next part of the tutorial, so let's add them now, just before custom styles. Give it a save and head on to Part Two!
8+
Before we go, we'll need to add a little additional functionality to our stylesheets. We'll need USWDS Utilities and the USWDS Layout Grid for the next part of the tutorial, so let's add them now, just before custom styles. Give it a save and head on to Part Two!
99
</p>
1010

1111
<div class="editor">

_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/my-card.scss";
26-
// @forward "../assets/css/components/my-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")};
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
@use "uswds-core" as *;
2+
3+
.my-card .usa-card__container {
4+
// @include u-text("indigo-30");
5+
// @include u-bg("indigo-70v");
6+
7+
@include set-text-and-bg("indigo-70v", "indigo-20")
8+
9+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
@use "uswds-core" as *;
2+
3+
$my-testimonial-icon-color: color("indigo-30");
4+
5+
.my-testimonial {
6+
@include u-margin-x(1);
7+
@include u-border($theme-card-border-width);
8+
@include u-radius($theme-card-border-radius);
9+
background-color: color("indigo-10");
10+
padding: units(3);
11+
}
12+
13+
.my-testimonial__icon {
14+
@include u-square(7);
15+
fill: $my-testimonial-icon-color;
16+
stroke: $my-testimonial-icon-color;
17+
}
18+
19+
.my-testimonial__body p {
20+
@include u-font-size("heading", "xl");
21+
font-weight: font-weight("bold");
22+
text-align: center;
23+
}
24+
25+
.my-testimonial__footer {
26+
display: flex;
27+
flex-direction: row;
28+
margin-top: units(3);
29+
}
30+
31+
.my-testimonial img {
32+
@include u-circle(10);
33+
}
34+
35+
.my-testimonial__profile {
36+
margin-left: units(3);
37+
}
38+
39+
.my-testimonial__profile-name {
40+
color: color("indigo-70v");
41+
}
42+
43+
.my-testimonial__profile-title {
44+
margin-top: units(0);
45+
font-size: font-size("body", 5);
46+
}

0 commit comments

Comments
 (0)