|
| 1 | +<section class="part one" id="part-one"> |
| 2 | + <div class="alert margin-y-3"> |
| 3 | + <p><strong>Heads up!</strong> If you haven't completed part one of this tutorial you'll be unable to complete certain steps throughout this section! Please complete the original tutorial before moving on to Extending USWDS.</p> |
| 4 | + <div class="button-list"> |
| 5 | + <a class="button primary" href="/">Return to Learn how to use USWDS<span class="material-icons right" aria-hidden="true">arrow_forward</span></a> |
| 6 | + </div> |
| 7 | + </div> |
| 8 | + <h2><span>Part one</span> Customize a card with theme settings</h2> |
| 9 | + <p> |
| 10 | + On the opposite side of the screen you'll see a USWDS Card component. Let's customize this card with theme settings. |
| 11 | + </p> |
| 12 | + <h3 class="step">View available theme settings.</h3> |
| 13 | + <p class="step-description"> |
| 14 | + 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 styles globally without writing custom CSS. Today we're going to give our card a light golden look. |
| 15 | + </p> |
| 16 | + <h3 class="step">Customize border settings.</h3> |
| 17 | + <p class="step-description"> |
| 18 | + Let's start with the card border. We'll remove the border and make the card rounder by increasing the border radius. |
| 19 | + </p> |
| 20 | + <p class="step-description"> |
| 21 | + We want to give our card a border radius of 2 units. To do that we'll set the value of the global border radius to <strong>lg</strong> then set the value of the large border radius to 2. |
| 22 | + </p> |
| 23 | + <div class="editor"> |
| 24 | + <h4 class="filename"><span class="material-icons" aria-hidden="true">description</span> _theme/_uswds-theme.scss</h4> |
| 25 | +<pre class="blur">@use "uswds-core" with ( |
| 26 | + ... |
| 27 | +</pre><pre class="add"> $theme-border-radius-lg: 2, |
| 28 | + $theme-card-border-radius: "lg", |
| 29 | + $theme-card-border-width: 0, |
| 30 | +</pre> |
| 31 | +<pre class="blur">);</pre> |
| 32 | + </div> |
| 33 | + |
| 34 | + <h3 class="step">Customize type settings.</h3> |
| 35 | + <p class="step-description"> |
| 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). |
| 37 | + </p> |
| 38 | + <div class="editor"> |
| 39 | + <h4 class="filename"><span class="material-icons" aria-hidden="true">description</span> _theme/_uswds-theme.scss</h4> |
| 40 | +<pre class="blur">@use "uswds-core" with ( |
| 41 | + ... |
| 42 | + $theme-border-radius-lg: 2, |
| 43 | + $theme-card-border-radius: "lg", |
| 44 | + $theme-card-border-width: 0,</pre> |
| 45 | +<pre class="add"> $theme-card-header-typeset: ("sans", "xl", 2), |
| 46 | +</pre><pre class="blur">);</pre> |
| 47 | + </div> |
| 48 | + <p class="step-description"> |
| 49 | + 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. |
| 50 | + </p> |
| 51 | + |
| 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 | + |
| 95 | + <p class="step-description"> |
| 96 | + 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. |
| 97 | + </p> |
| 98 | +</section> |
0 commit comments