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-three.html
+39-39Lines changed: 39 additions & 39 deletions
Original file line number
Diff line number
Diff line change
@@ -6,14 +6,14 @@ <h3 class="step">Create a the markup for a new component.</h3>
6
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!
7
7
</p>
8
8
<pclass="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>.
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>ut-testimonial</strong> div.
52
+
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.
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.
@@ -130,26 +130,26 @@ <h3 class="step">Styling the testimonial icon</h3>
130
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.
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.
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.
Copy file name to clipboardExpand all lines: _includes/sxs/02-extending/part-two.html
+12-12Lines changed: 12 additions & 12 deletions
Original file line number
Diff line number
Diff line change
@@ -8,12 +8,12 @@ <h3 class="step">Add a custom class for our new variant.</h3>
8
8
We'll use this class to identify our custom card component and assign custom styles.
9
9
</p>
10
10
<pclass="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, lets use <strong>ut-</strong>card as our custom class.
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>. For this example, lets use <strong>my-</strong>card as our custom class.
@@ -25,10 +25,10 @@ <h3 class="step">Create a custom stylesheet for our custom card component.</h3>
25
25
<pre>mkdir _theme/components</pre>
26
26
</div>
27
27
<pclass="step-description">
28
-
This pattern will allow us to organize CSS partials an 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.
28
+
This pattern will allow us to organize CSS partials an a logical structure. Let's now add our new <strong>my-card</strong> stylesheet. It's standard naming convention to prefix CSS partials with an underscore.
29
29
</p>
30
30
<divclass="terminal">
31
-
<pre>touch _theme/components/_ut-card.scss</pre>
31
+
<pre>touch _theme/components/_my-card.scss</pre>
32
32
</div>
33
33
<h3class="step">Import the new stylesheet into USWDS custom styles.</h3>
34
34
<pclass="step-description">
@@ -38,7 +38,7 @@ <h3 class="step">Import the new stylesheet into USWDS custom styles.</h3>
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!
We'll want to use USWDS design tokens in our stylesheets using USWDS 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.
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 <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>.
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.
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