Skip to content

Commit 4fa83aa

Browse files
authored
Merge branch 'jm-mc-setup' into jm-copy-edits
2 parents 12b986b + 3db2ed7 commit 4fa83aa

14 files changed

Lines changed: 347 additions & 216 deletions

File tree

_includes/card.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<div class="usa-card">
1+
<div class="usa-card my-card">
22
<div class="usa-card__container">
33
<div class="usa-card__header">
44
<h2 class="usa-card__heading">Card component</h2>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ <h3>Contents</h3>
88
<li>
99
<a class="contents-item" href="#part-one">
1010
<span class="contents-part">1</span>
11-
<span class="contents-title">Theming USWDS Components</span>
11+
<span class="contents-title">Theming USWDS components</span>
1212
<span class="material-icons right" aria-hidden="true">arrow_forward</span>
1313
</a>
1414
</li>

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

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,10 @@ <h4 class="filename"><span class="material-icons" aria-hidden="true">description
3030
</pre>
3131
<pre class="blur">);</pre>
3232
</div>
33+
3334
<h3 class="step">Customize type settings.</h3>
3435
<p class="step-description">
35-
Next let's update the typesetting of our header to use a <strong>sans</strong> font, increase the size ("xl"), and use a tight line height (2).
36+
Next, let's update the typesetting of our header to use a <strong>sans</strong> font, increase the size ("xl"), and use a tight line height (2).
3637
</p>
3738
<div class="editor">
3839
<h4 class="filename"><span class="material-icons" aria-hidden="true">description</span> _theme/_uswds-theme.scss</h4>
@@ -48,6 +49,49 @@ <h4 class="filename"><span class="material-icons" aria-hidden="true">description
4849
Save, wait for the Sass to compile, and reload. You'll see the updated border and font settings shape the card component! All without having to write any custom CSS.
4950
</p>
5051

52+
<h3 class="step">Customize perimeter padding settings</h3>
53+
<p class="step-description">
54+
And while we're add it, let's add a bit more padding to help the component feel a little more comfortable and less cramped.
55+
</p>
56+
<div class="editor">
57+
<h4 class="filename"><span class="material-icons" aria-hidden="true">description</span> _theme/_uswds-theme.scss</h4>
58+
<pre class="blur">@use "uswds-core" with (
59+
...
60+
$theme-border-radius-lg: 2,
61+
$theme-card-border-radius: "lg",
62+
$theme-card-border-width: 0,
63+
$theme-card-header-typeset: ("sans", "xl", 2),
64+
</pre><pre class="add"> $theme-card-padding-perimeter: 4,</pre>
65+
</div>
66+
<p class="step-description">
67+
Save and reload. Ah, that's nicer.
68+
</p>
69+
70+
71+
<h3 class="step">Customize primary color settings</h3>
72+
<p class="step-description">
73+
Finally, let's update our project's primary color, from blue to indigo.
74+
</p>
75+
<div class="editor">
76+
<h4 class="filename"><span class="material-icons" aria-hidden="true">description</span> _theme/_uswds-theme.scss</h4>
77+
<pre class="blur">@use "uswds-core" with (
78+
...
79+
$theme-border-radius-lg: 2,
80+
$theme-card-border-radius: "lg",
81+
$theme-card-border-width: 0,
82+
$theme-card-header-typeset: ("sans", "xl", 2),
83+
$theme-card-padding-perimeter: 4,
84+
85+
</pre><pre class="add"> $theme-color-primary-lighter: "indigo-20v",
86+
$theme-color-primary-light: "indigo-40v",
87+
$theme-color-primary: "indigo-60v",
88+
$theme-color-primary-dark: "indigo-70v",
89+
$theme-color-primary-darker: "indigo-80v",</pre><pre class="blur">);</pre>
90+
</div>
91+
<p class="step-description">
92+
Save and reload. You'll see the card's button has gotten a bit purple-er.
93+
</p>
94+
5195
<p class="step-description">
5296
But maybe there are additional changes your team would like to make that aren't available in theme settings. In the next section we'll take a look at adding custom styles.
5397
</p>

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

Lines changed: 174 additions & 96 deletions
Large diffs are not rendered by default.

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

Lines changed: 45 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -8,95 +8,96 @@ <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, let's use <strong>ut-</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">
14-
<h4 class="filename"><span class="material-icons" aria-hidden="true">description</span> _includes/sxs/02-extending/card.html</h4>
14+
<h4 class="filename"><span class="material-icons" aria-hidden="true">description</span> _includes/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>
20+
21+
<h3 class="step">Open a new terminal window.</h3>
22+
<p class="step-description">
23+
At this point you should already have two terminal windows open. One is serving our site and the other is compiling our stylesheets. We're going to open one more so we can add a couple new files.
24+
</p>
25+
<p class="step-description">
26+
Open a new terminal window and navigate to the tutorial's root directory, as before. In the following example, change <strong>path/to/uswds-tutorial</strong> to the actual path.
27+
</p>
28+
<div class="terminal">
29+
<pre>cd path/to/uswds-tutorial</pre>
30+
</div>
31+
2032
<h3 class="step">Create a custom stylesheet for our custom card component.</h3>
2133
<p class="step-description">
2234
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, let's add a <strong>components</strong> directory to our css assets.
2335
</p>
2436
<div class="terminal">
25-
<pre>mkdir assets/css/components</pre>
37+
<pre>mkdir _theme/components</pre>
2638
</div>
2739
<p class="step-description">
28-
This pattern will allow us to organize CSS partials in 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.
40+
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>).
2941
</p>
3042
<div class="terminal">
31-
<pre>touch assets/css/components/_ut-card.scss</pre>
43+
<pre>touch assets/css/components/_my-card.scss</pre>
3244
</div>
45+
3346
<h3 class="step">Import the new stylesheet into USWDS custom styles.</h3>
3447
<p class="step-description">
3548
Navigate to <strong>_theme/_uswds-theme-custom-styles.scss</strong> and import our new stylesheet into the USWDS custom styles file.
3649
</p>
3750
<div class="editor">
3851
<h4 class="filename"><span class="material-icons" aria-hidden="true">description</span> _theme/_uswds-theme-custom-styles.scss</h4>
3952
<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>
53+
@forward "../assets/css/styles.scss";
54+
</pre><pre class="add">@forward "../assets/css/_my-card.scss";</pre>
4255
</div>
4356
<p class="step-description">
4457
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!
4558
</p>
46-
<h3 class="step">Use USWDS utilities in custom styles.</h3>
4759
<p class="step-description">
48-
Now that our stylesheet is being imported, let's write some custom styles to really make this card stand out!
60+
Now that our stylesheet is being imported, lets write some customs styles to finish up our card.
4961
</p>
62+
63+
<h3 class="step">Use USWDS core features in custom styles.</h3>
5064
<p class="step-description">
51-
We'll want to use USWDS design tokens in our stylesheets using USWDS functions and mixins. To do this, let's add <strong>uswds-core</strong> to the top of our new stylesheet with the <strong>use</strong> Sass directive.
65+
We'll want to use USWDS design tokens in our stylesheets using USWDS stylesheet features like 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.
5266
</p>
5367
<div class="editor">
54-
<h4 class="filename"><span class="material-icons" aria-hidden="true">description</span> assets/css/components/_ut-card.scss</h4>
68+
<h4 class="filename"><span class="material-icons" aria-hidden="true">description</span> assets/css/components/_my-card.scss</h4>
5569
<pre class="add">@use "uswds-core" as *;</pre>
5670
</div>
71+
5772
<h3 class="step">Add custom class and styles.</h3>
5873
<p class="step-description">
59-
Next let's 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>.
74+
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 use color tokens in our CSS rules.
6075
</p>
6176
<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 {
64-
background-color: color("indigo-70v");
65-
color: color("indigo-30");
77+
<h4 class="filename"><span class="material-icons" aria-hidden="true">description</span> assets/css/components/_my-card.scss</h4>
78+
<pre class="add">.my-card .usa-card__container {
79+
background-color: color("yellow-10");
6680
}</pre>
6781
</div>
6882
<p class="step-description">
69-
After recompiling we can see our changes have taken effect. <strong>But wait!</strong> Upon closer inspection, these colors <strong>fail</strong> AA color contrast requirements! Luckily, USWDS uses a color grading system. Using this system, a grade difference 50+ will ensure AA across any two color values. You can learn more about this on our <a href="https://designsystem.digital.gov/design-tokens/color/overview/#magic-number-2">Using Color</a> page.
70-
</p>
71-
<p class="step-description">
72-
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.
83+
After recompiling we can see our changes have taken effect. Let's refine this card a bit more by reducing the boldness of the header and adding bit more space before the call to action. We'll use <a href="https://designsystem.digital.gov/design-tokens/spacing-units/">units tokens</a> and <a href="https://designsystem.digital.gov/design-tokens/typesetting/font-weight/">font weight tokens</a> for this.
7384
</p>
7485
<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>
77-
<pre class="remove">
86+
<h4 class="filename"><span class="material-icons" aria-hidden="true">description</span> assets/css/components/_my-card.scss</h4>
87+
<pre class="blur">.my-card .usa-card__container {
7888
background-color: color("indigo-70v");
79-
color: color("indigo-30");
80-
</pre><pre class="add">
81-
@include set-text-and-bg("indigo-70v", "indigo-30");
82-
</pre>
83-
<pre class="blur">}</pre>
84-
</div>
85-
<p class="step-description">
86-
If you inspect the compilation messages in the terminal, you'll actually see a warning. These colors don't pass color contrast requirements! let's use the magic number of 50+ to resolve this issue.
87-
</p>
88-
<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>
91-
<pre class="remove">
92-
@include set-text-and-bg("indigo-70v", "indigo-30");
93-
</pre><pre class="add">
94-
@include set-text-and-bg("indigo-70v", "indigo-20");
95-
</pre>
89+
}
90+
91+
</pre><pre class="add">.my-card .usa-card__footer {
92+
margin-top: units(1);
93+
}
94+
95+
.my-card .usa-card__heading {
96+
font-weight: font-weight("bold");
97+
}</pre>
9698
</div>
97-
<h3 class="step">Adjust the layout of card.</h3>
9899
<p class="step-description">
99-
Create steps to add separate footer styles and a variant.
100+
Now we're making progress. This component is looking pretty good.
100101
</p>
101-
<p>In our next section, we'll take a look at using everything USWDS has to offer to create a custom component!</p>
102+
<p class="step-description">In our next section, we'll take a look at using everything USWDS has to offer to create a custom component!</p>
102103
</section>

_includes/testimonial.html

Lines changed: 8 additions & 8 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>
7-
"Wow, this component sure is great"
7+
“One of the best USWDS tutorials I’ve followed all the way to the end.”
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">J. Fakename</p>
14+
<p class="my-testimonial__profile-title">Participant</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")};

_theme/_uswds-theme.scss

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,16 @@ in the form $setting: value,
1616
$theme-banner-max-width: none,
1717
$theme-identifier-max-width: none,
1818

19-
// $theme-border-radius-lg: 2,
20-
// $theme-card-border-radius: "lg",
21-
// $theme-card-border-width: 0,
22-
// $theme-card-font-family: "sans",
23-
// $theme-card-header-typeset: ("sans", "xl", 1)
19+
$theme-border-radius-lg: 2,
20+
$theme-card-border-radius: "lg",
21+
$theme-card-border-width: 0,
22+
$theme-card-font-family: "sans",
23+
$theme-card-header-typeset: ("sans", "xl", 2),
24+
$theme-card-padding-perimeter: 4,
25+
26+
$theme-color-primary-lighter: "indigo-20v",
27+
$theme-color-primary-light: "indigo-40v",
28+
$theme-color-primary: "indigo-60v",
29+
$theme-color-primary-dark: "indigo-70v",
30+
$theme-color-primary-darker: "indigo-80v",
2431
);
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
@use "uswds-core" as *;
2+
3+
.my-card .usa-card__container {
4+
background-color: color("yellow-10");
5+
}
6+
7+
.my-card .usa-card__footer {
8+
margin-top: units(1);
9+
}
10+
11+
.my-card .usa-card__heading {
12+
font-weight: font-weight("bold");
13+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
@use "uswds-core" as *;
2+
3+
$my-testimonial-icon-color: color("indigo-40");
4+
5+
.my-testimonial {
6+
@include u-border-width($theme-card-border-width);
7+
@include u-margin-x(1);
8+
@include u-padding($theme-card-padding-perimeter);
9+
@include u-radius($theme-card-border-radius);
10+
@include set-text-and-bg("primary-dark", "primary-lighter");
11+
// background-color: color("primary-dark");
12+
// color: color("primary-light");
13+
}
14+
15+
.my-testimonial__icon {
16+
fill: $my-testimonial-icon-color;
17+
stroke: $my-testimonial-icon-color;
18+
}
19+
20+
.my-testimonial__body p {
21+
font-size: size("heading", "xl");
22+
font-weight: font-weight("bold");
23+
text-align: center;
24+
}
25+
26+
.my-testimonial__footer {
27+
display: flex;
28+
flex-direction: row;
29+
margin-top: units(3);
30+
}
31+
32+
.my-testimonial img {
33+
@include u-circle(10);
34+
}
35+
36+
.my-testimonial__profile {
37+
margin-left: units(3)
38+
}
39+
40+
.my-testimonial__profile-title {
41+
font-size: font-size("body", 5);
42+
margin-top: units(0);
43+
}

0 commit comments

Comments
 (0)