Skip to content

Commit 86a8181

Browse files
committed
Add testimonial refinements
1 parent f0681d0 commit 86a8181

9 files changed

Lines changed: 171 additions & 168 deletions

File tree

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

Lines changed: 47 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ <h3 class="step">View available theme settings.</h3>
1313
<p class="step-description">
1414
Visit the <a href="https://designsystem.digital.gov/components/card/#component-settings-card">USWDS Card component settings table</a> to see a list of available settings. Settings allow you to apply a global theme to USWDS components and styles without modifying CSS. Today's we're going to give our card a light golden look.
1515
</p>
16+
1617
<h3 class="step">Customize border settings</h3>
1718
<p class="step-description">
1819
Let's start but updating the border to remove the border and give the card a rounder border radius.
@@ -30,9 +31,10 @@ <h4 class="filename"><span class="material-icons" aria-hidden="true">description
3031
</pre>
3132
<pre class="blur">);</pre>
3233
</div>
34+
3335
<h3 class="step">Customize type settings</h3>
3436
<p class="step-description">
35-
Next lets update the typesetting of our header to use a <strong>sans</strong> font, increase the size ("xl"), and use a tight line height (2).
37+
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).
3638
</p>
3739
<div class="editor">
3840
<h4 class="filename"><span class="material-icons" aria-hidden="true">description</span> _theme/_uswds-theme.scss</h4>
@@ -45,9 +47,51 @@ <h4 class="filename"><span class="material-icons" aria-hidden="true">description
4547
</pre><pre class="blur">);</pre>
4648
</div>
4749
<p class="step-description">
48-
Save, wait for the Sass to compile, and reload. You'll see the the updated border and font settings shape the card component! All without having to write any custom CSS.
50+
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.
51+
</p>
52+
53+
<h3 class="step">Customize perimeter padding settings</h3>
54+
<p class="step-description">
55+
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.
56+
</p>
57+
<div class="editor">
58+
<h4 class="filename"><span class="material-icons" aria-hidden="true">description</span> _theme/_uswds-theme.scss</h4>
59+
<pre class="blur">@use "uswds-core" with (
60+
...
61+
$theme-border-radius-lg: 2,
62+
$theme-card-border-radius: "lg",
63+
$theme-card-border-width: 0,
64+
$theme-card-header-typeset: ("sans", "xl", 2),
65+
</pre><pre class="add"> $theme-card-padding-perimeter: 4,</pre>
66+
</div>
67+
<p class="step-description">
68+
Save and reload. Ah, that's nicer.
69+
</p>
70+
71+
72+
<h3 class="step">Customize primary color settings</h3>
73+
<p class="step-description">
74+
Finally, let's update our project's primary color, from blue to indigo.
75+
</p>
76+
<div class="editor">
77+
<h4 class="filename"><span class="material-icons" aria-hidden="true">description</span> _theme/_uswds-theme.scss</h4>
78+
<pre class="blur">@use "uswds-core" with (
79+
...
80+
$theme-border-radius-lg: 2,
81+
$theme-card-border-radius: "lg",
82+
$theme-card-border-width: 0,
83+
$theme-card-header-typeset: ("sans", "xl", 2),
84+
$theme-card-padding-perimeter: 4,
85+
86+
</pre><pre class="add"> $theme-color-primary-lighter: "indigo-20v",
87+
$theme-color-primary-light: "indigo-40v",
88+
$theme-color-primary: "indigo-60v",
89+
$theme-color-primary-dark: "indigo-70v",
90+
$theme-color-primary-darker: "indigo-80v",</pre><pre class="blur">);</pre>
91+
</div>
92+
<p class="step-description">
93+
Save and reload. You'll see the card's button has gotten a bit purple-er.
4994
</p>
50-
5195
<p class="step-description">
5296
But maybe there are additional changes your team would like to make that are not 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: 36 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,29 @@ <h2><span>Part Three</span> Create a custom component</h2>
33
<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">
6-
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!
6+
Visit <strong>_includes/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">
99
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">
12-
<h4 class="filename"><span class="material-icons" aria-hidden="true">description</span> _includes/sxs/02-extending/testimonial.html</h4>
12+
<h4 class="filename"><span class="material-icons" aria-hidden="true">description</span> _includes/testimonial.html</h4>
1313
<pre class="add">
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;
17-
&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;
17+
&lt;/div&gt;
1818
</pre>
1919
</div>
2020
<p class="step-description">
2121
Now lets add a quote to our testimonial body.
2222
</p>
2323
<div class="editor">
24-
<h4 class="filename"><span class="material-icons" aria-hidden="true">description</span> _includes/sxs/02-extending/testimonial.html</h4>
24+
<h4 class="filename"><span class="material-icons" aria-hidden="true">description</span> _includes/testimonial.html</h4>
2525
<pre class="blur">&lt;div class="my-testimonial"&gt;</pre>
2626
<pre class="add"> &lt;div class="my-testimonial__body"&gt;
2727
&lt;p&gt;
28-
"Wow, this component sure is great"
28+
“One of the best USWDS tutorials I’ve followed all the way to the end.”
2929
&lt;/p&gt;
3030
&lt;/div&gt;</pre>
3131
<pre class="blur"> &lt;div class="my-testimonial__footer"&gt;&lt;/div&gt;
@@ -36,14 +36,14 @@ <h4 class="filename"><span class="material-icons" aria-hidden="true">description
3636
Now lets create a profile section which will feature a profile picture, name, and title.
3737
</p>
3838
<div class="editor">
39-
<h4 class="filename"><span class="material-icons" aria-hidden="true">description</span> _includes/sxs/02-extending/testimonial.html</h4>
39+
<h4 class="filename"><span class="material-icons" aria-hidden="true">description</span> _includes/testimonial.html</h4>
4040
<pre class="blur">&lt;div class="my-testimonial"&gt;
4141
...
4242
&lt;div class="my-testimonial__footer"&gt;</pre>
4343
<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;
4444
&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;
45+
&lt;p class="my-testimonial__profile-name"&gt;J. Fakename&lt;/p&gt;
46+
&lt;p class="my-testimonial__profile-title"&gt;Participant&lt;/p&gt;
4747
&lt;/div&gt;
4848
</pre>
4949
<pre class="blur">&lt;/div&gt;</pre>
@@ -52,22 +52,42 @@ <h4 class="filename"><span class="material-icons" aria-hidden="true">description
5252
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">
55-
<h4 class="filename"><span class="material-icons" aria-hidden="true">description</span> _includes/sxs/02-extending/testimonial.html</h4>
55+
<h4 class="filename"><span class="material-icons" aria-hidden="true">description</span> _includes/testimonial.html</h4>
5656
<pre class="blur">&lt;div class="my-testimonial"&gt;</pre>
5757
<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;
58+
&lt;use xlink:href="/assets/img/sprite.svg#format_quote"&gt;
5959
&lt;/use&gt;
60-
&lt;/svg&gt;</pre><pre class="blur">&lt;div class="my-testimonial__body"&gt;&lt;/div&gt;</pre>
60+
&lt;/svg&gt;</pre><pre class="blur">&lt;div class="my-testimonial__body"&gt;
61+
...</pre>
6162
</div>
63+
<p class="step-description">
64+
Unfortunately, when we reload, the icon image doesn't load. If you've recently done Part One of this tutorial, you probably remember why: we need to update the icon image path to point to its location in this project. We'll need to change the path we got when we copied the icon image from the USWDS website (/assets/img/sprite.svg) to the proper path in our project (/assets<strong>/uswds</strong>/img/sprite.svg).
65+
</p>
66+
<div class="editor">
67+
<h4 class="filename"><span class="material-icons" aria-hidden="true">description</span> _includes/testimonial.html</h4>
68+
<pre class="blur">&lt;div class="my-testimonial"&gt;
69+
&lt;svg class="usa-icon my-testimonial__icon" aria-hidden="true" focusable="false" role="img"&gt;</pre><pre class="remove">
70+
&lt;use xlink:href="/assets/img/sprite.svg#format_quote"&gt;</pre><pre class="add">
71+
&lt;use xlink:href="/assets/uswds/img/sprite.svg#format_quote"&gt;</pre><pre class="blur">
72+
&lt;/use&gt;
73+
&lt;/svg&gt;
74+
&lt;div class="my-testimonial__body"&gt;
75+
...</pre>
76+
</div>
77+
<p class="step-description">
78+
Now we've got some markup, but it doesn't really have any styling. Let's change that.
79+
</p>
80+
81+
6282
<h3 class="step">Add stylesheet partial.</h3>
6383
<p class="step-description">
64-
Create a new stylesheet partial for our new component.
84+
Create a new stylesheet partial for our new component by entering the following in the free temrinal window:
6585
</p>
6686
<div class="terminal">
6787
<pre>touch assets/css/components/_my-testimonial.scss</pre>
6888
</div>
6989
<p class="step-description">
70-
Remember to import the new stylesheet into USWDS custom styles.
90+
And then we'll import this new stylesheet into our USWDS custom styles.
7191
</p>
7292
<div class="editor">
7393
<h4 class="filename"><span class="material-icons" aria-hidden="true">description</span> _theme/_uswds-theme-custom-styles.scss</h4>

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

Lines changed: 19 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<section class="part two" id="part-two">
2-
<h2><span>Part Two</span> Customizing card using custom styles.</h2>
2+
<h2><span>Part Two</span> Customizing a card using custom styles.</h2>
33
<p>
44
Using custom styles, we can customize our components beyond theme settings.
55
</p>
@@ -68,49 +68,36 @@ <h3 class="step">Use USWDS core features in custom styles</h3>
6868
<h4 class="filename"><span class="material-icons" aria-hidden="true">description</span> assets/css/components/_my-card.scss</h4>
6969
<pre class="add">@use "uswds-core" as *;</pre>
7070
</div>
71+
7172
<h3 class="step">Add custom class and styles</h3>
7273
<p class="step-description">
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>.
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.
7475
</p>
7576
<div class="editor">
76-
<h4 class="filename"><span class="material-icons" aria-hidden="true">description</span> assets/css/components/my-card.scss</h4>
77+
<h4 class="filename"><span class="material-icons" aria-hidden="true">description</span> assets/css/components/_my-card.scss</h4>
7778
<pre class="add">.my-card .usa-card__container {
78-
background-color: color("indigo-70v");
79-
color: color("indigo-30");
79+
background-color: color("yellow-10");
8080
}</pre>
8181
</div>
8282
<p class="step-description">
83-
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.
84-
</p>
85-
<p class="step-description">
86-
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.
8784
</p>
8885
<div class="editor">
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>
91-
<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 {
9288
background-color: color("indigo-70v");
93-
color: color("indigo-30");
94-
</pre><pre class="add">
95-
@include set-text-and-bg("indigo-70v", "indigo-30");
96-
</pre>
97-
<pre class="blur">}</pre>
98-
</div>
99-
<p class="step-description">
100-
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.
101-
</p>
102-
<div class="editor">
103-
<h4 class="filename"><span class="material-icons" aria-hidden="true">description</span> assets/css/components/my-card.scss</h4>
104-
<pre class="blur">.my-card .usa-card__container {</pre>
105-
<pre class="remove">
106-
@include set-text-and-bg("indigo-70v", "indigo-30");
107-
</pre><pre class="add">
108-
@include set-text-and-bg("indigo-70v", "indigo-20");
109-
</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>
11098
</div>
111-
<h3 class="step">Adjust the layout of card.</h3>
11299
<p class="step-description">
113-
Create steps to add separate footer styles and a variant.
100+
Now we're making progress. This component is looking pretty good.
114101
</p>
115-
<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>
116103
</section>

_includes/testimonial.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
<!-- <div class="my-testimonial">
1+
<div class="my-testimonial">
22
<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>
55
<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>
1010
<div class="my-testimonial__footer">
1111
<img src="https://doodleipsum.com/100x100/avatar-5?bg=a5a8eb&shape=circle&n=1" alt="Profile pic">
1212
<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>
13+
<p class="my-testimonial__profile-name">J. Fakename</p>
14+
<p class="my-testimonial__profile-title">Participant</p>
1515
</div>
1616
</div>
17-
</div> -->
17+
</div>

_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: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
@use "uswds-core" as *;
22

33
.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")
4+
background-color: color("yellow-10");
5+
}
86

7+
.my-card .usa-card__footer {
8+
margin-top: units(1);
99
}
10+
11+
.my-card .usa-card__heading {
12+
font-weight: font-weight("bold");
13+
}

0 commit comments

Comments
 (0)