You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: _includes/sxs/02-extending/part-one.html
+47-3Lines changed: 47 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -13,6 +13,7 @@ <h3 class="step">View available theme settings.</h3>
13
13
<pclass="step-description">
14
14
Visit the <ahref="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.
15
15
</p>
16
+
16
17
<h3class="step">Customize border settings</h3>
17
18
<pclass="step-description">
18
19
Let's start but updating the border to remove the border and give the card a rounder border radius.
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.
Save and reload. You'll see the card's button has gotten a bit purple-er.
49
94
</p>
50
-
51
95
<pclass="step-description">
52
96
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.
Copy file name to clipboardExpand all lines: _includes/sxs/02-extending/part-three.html
+36-16Lines changed: 36 additions & 16 deletions
Original file line number
Diff line number
Diff line change
@@ -3,29 +3,29 @@ <h2><span>Part Three</span> Create a custom component</h2>
3
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>
4
4
<h3class="step">Create a the markup for a new component.</h3>
5
5
<pclass="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!
7
7
</p>
8
8
<pclass="step-description">
9
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>.
Lastly, lets add a quotation icon for some visual flare! Visit the <ahref="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.
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).
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 <ahref="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 <ahref="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 <ahref="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.
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 <ahref="https://designsystem.digital.gov/design-tokens/color/overview/#magic-number-2">Using Color</a> page.
84
-
</p>
85
-
<pclass="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 <ahref="https://designsystem.digital.gov/design-tokens/spacing-units/">units tokens</a> and <ahref="https://designsystem.digital.gov/design-tokens/typesetting/font-weight/">font weight tokens</a> for this.
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.
0 commit comments