Skip to content

Commit

Permalink
add info section for design pattern (#20)
Browse files Browse the repository at this point in the history
Signed-off-by: Dave Skender <8432125+DaveSkender@users.noreply.github.com>
  • Loading branch information
DaveSkender authored Jun 4, 2023
1 parent b10c5fb commit 3ecfa46
Show file tree
Hide file tree
Showing 5 changed files with 197 additions and 96 deletions.
5 changes: 0 additions & 5 deletions .github/PULL_REQUEST_TEMPLATE.md

This file was deleted.

73 changes: 73 additions & 0 deletions sass/_uswds-base.scss
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,76 @@ ref: https://designsystem.digital.gov/components/packages
h1 {
color: unset;
}

.pattern-info-section {

@include u-padding-x(2);

background-color: color($theme-color-base-darkest) !important;

.pattern-info-container {

@include u-padding-x(6);
@include u-padding-y(4);
max-width: 800px;
margin: auto;

border: 5px;
border-style: solid;
border-radius: 1rem;
border-color: color($theme-color-base-darker);

@include at-media-max("mobile-lg") {
@include u-padding(2);
}

h2,
h3,
h4 {
margin-top: 2rem;
margin-bottom: 1rem;
color: color($theme-color-base-lighter);
opacity: 80% !important;
}

h2 {
@include u-font-size("sans", 13);
color: rgba(230, 199, 76);
line-height: 0.9em;

@include at-media-max("mobile-lg") {
@include u-font-size("sans", 12);
}
}

h3 {
@include u-font-size("sans", 10);

@include at-media-max("mobile-lg") {
@include u-font-size("sans", 8);
}
}

h4 {
@include u-font-size("sans", 8);

@include at-media-max("mobile-lg") {
@include u-font-size("sans", 7);
}
}

.features {

p,
ol,
li {
color: color($theme-color-base-lighter);
opacity: 70%;
}

.usa-list li {
max-width: unset;
}
}
}
}
78 changes: 61 additions & 17 deletions src/app/pages/card-catalog/catalog.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@
</nav>
</div>

<!-- Catalog -->
<!-- CATALOG -->
<section class="usa-section catalog-section">
<div class="grid-container">

<h1>Card catalog</h1>
<p class="usa-prose">
A card catalog using the U.S. Web Design System <a class="usa-link usa-link--external"
href="https://designsystem.digital.gov/components/card/">Card</a> component with fixed image aspect ratio,
consistent section sizing, full-surface clickability (to replace the button), a hover effect, and "see more"
pagination.
href="https://designsystem.digital.gov/components/card/" target="_blank">Card</a> component
with "see more" pagination. Learn more about <a class="usa-button usa-button--unstyled"
(click)="u.scrollToStart('info')">our modifications</a> at the bottom of this page.
</p>

<!-- Cards
<!-- CARDS in CARD GROUP
- add tablet-lg grid breakpoint
- changed card container to <a>
- removed card footer with button
Expand Down Expand Up @@ -69,16 +69,60 @@ <h2 class="usa-card__heading">{{ card.title }}</h2>
</div>
</section>

<!-- github | return to top -->
<section class="usa-section grid-container pattern-info-section">
<ul class="usa-button-group">
<li class="usa-button-group__item">
<a class="usa-button usa-button--unstyled" type="button"
href="https://github.com/facioquo/uswds-design-patterns/tree/main/src/app/pages/card-catalog" target="_blank"
rel="noreferrer">view code</a>
</li>
<li class="usa-button-group__item">
<button class="usa-button usa-button--unstyled" (click)="u.scrollToStart('top')">return to top</button>
</li>
</ul>

<!-- INFO SECTION | About this design pattern -->
<section id="info" class="usa-section usa-section--dark usa-dark-background pattern-info-section">

<div class="pattern-info-container">

<h2>When to use this design pattern</h2>

<div class="features">

<h3>Modifications to the card</h3>

<p class="usa-prose">
Use this card approach when you want consistent <a class="usa-link usa-link--alt usa-link--external"
href="https://designsystem.digital.gov/components/card/" target="_blank">Card</a> size proportions and
alignment of its elements when sizes for images, card titles, and descriptions vary.
</p>

<ul class="usa-list">
<li>Card image box uses a fixed aspect ratio to ensure a consistent size.</li>
<li>Card title and summary sections are fixed to 2 and 3 lines to ensure a consistent size. We limited the max
allowable raw text, so overflow is rare. Ellipses indicate overflows ...</li>
<li>Full card is clickable to maximize the size of target surface (we also removed the button).</li>
<li>A hover effect is applied to emphasize and clarify clickability and targeting.</li>
<li>Images ease in on load to reduce the visual "pop" that occurs on late arrival.</li>
</ul>

<h3>Implementation of "see more" pagination</h3>

<p class="usa-prose">
Use this alternate pagination approach when you want to see more content without the large page
shift that you'd get from classic numbered <a class="usa-link usa-link--alt usa-link--external"
href="https://designsystem.digital.gov/components/pagination/" target="_blank">Pagination</a>.
</p>

<ul class="usa-list">
<li>"See more" and "Show all" pagination uses Javascript to add the next page(s)
data to the card collection.</li>
<li>Smooth scroll to position first new items added to the card collection.</li>
<li>Lazy load images so only nearby images download and render.</li>
</ul>
</div>

<!-- github | return to top -->
<ul class="usa-button-group padding-top-6">
<li class="usa-button-group__item">
<a class="usa-button usa-link--external" type="button"
href="https://github.com/facioquo/uswds-design-patterns/tree/main/src/app/pages/card-catalog"
target="_blank">View on GitHub</a>
</li>
<li class="usa-button-group__item">
<button class="usa-button usa-button--outline usa-button--inverse" (click)="u.scrollToStart('top')">Return to
top</button>
</li>
</ul>
</div>
</section>
115 changes: 52 additions & 63 deletions src/app/pages/card-catalog/catalog.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,89 +7,78 @@
@forward "usa-button-group";

.catalog-section {

@include u-padding-top(0);
@include u-padding-bottom(2);
min-height: 100v; // ensures no CLS
}

.usa-card {
a.usa-card__container {
text-decoration: none;
border-color: color($theme-color-base-lighter);
.usa-card {

// hover effect
&:hover {
.usa-card__header {
text-decoration: underline;
text-decoration-color: color($theme-color-base-light);
}
a.usa-card__container {
text-decoration: none;
border-color: color($theme-color-base-lighter);

// hover effect
&:hover {

.usa-card__header {
text-decoration: underline;
text-decoration-color: color($theme-color-base-light);
}

box-shadow:
0px 5px 5px -3px color($theme-color-base-light, 0.2),
box-shadow: 0px 5px 5px -3px color($theme-color-base-light, 0.2),
0px 8px 8px 1px color($theme-color-base-light, 0.14),
0px 3px 14px 2px color($theme-color-base-light, 0.12);
}
}

// click effect
&:active {
background-color: color($theme-color-base-lighter);
// click effect
&:active {

box-shadow:
0px 15px 15px -3px color($theme-color-base-light, 0.2),
0px 24px 30px 1px color($theme-color-base-light, 0.14),
0px 9px 40px 2px color($theme-color-base-light, 0.12);
}

// maintain image box size proportion
.usa-card__img {
aspect-ratio: 600/315;
background-color: color($theme-color-base-lighter);
}
background-color: color($theme-color-base-lighter);

// when above tablet size,
// truncate the title and description
@include at-media("tablet") {
.usa-card__heading {
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
line-height: 2.25ex;
height: 4.5ex;
overflow: hidden;
box-shadow:
0px 15px 15px -3px color($theme-color-base-light, 0.2),
0px 24px 30px 1px color($theme-color-base-light, 0.14),
0px 9px 40px 2px color($theme-color-base-light, 0.12);
}

.usa-card__body p {
display: -webkit-box;
-webkit-line-clamp: 3;
-webkit-box-orient: vertical;
line-height: 2.8ex;
height: 8.4ex;
overflow: hidden;
// maintain image box size proportion
.usa-card__img {

aspect-ratio: 600/315;
background-color: color($theme-color-base-lighter);
}
}
}
}

// button groups at bottom of page
.usa-button-group {
@include u-flex("justify-center");
}
// when above tablet size,
// truncate the title and description
@include at-media("tablet") {

.pattern-info-section {
@include u-padding-y(2);
.usa-card__heading {
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
line-height: 2.25ex;
height: 4.5ex;
overflow: hidden;
}

.usa-button-group__item {
@include u-margin-x(1);
.usa-card__body p {
display: -webkit-box;
-webkit-line-clamp: 3;
-webkit-box-orient: vertical;
line-height: 2.8ex;
height: 8.4ex;
overflow: hidden;
}
}
}
}

.usa-button--unstyled {
@include at-media-max("mobile-lg") {
text-align: center;
min-height: 24px !important;
}
// button groups at bottom of page
.usa-button-group {
@include u-flex("justify-center");
}
}


// fade in images after loading.
// we're partly doing this since we're using a 3rd-party image source
// that does not have a performant caching approach
Expand Down
22 changes: 11 additions & 11 deletions src/app/pages/home/home.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@
@include u-padding-top(4);
@include u-padding-bottom(2);
min-height: 75vh;
}

.subtitle {
@include u-font-size('sans', 9);
font-weight: 400;
color: color($theme-color-base-light);
line-height: 1.2em;
margin-top: 0.25em;
display: block;

@include at-media-max("mobile-lg") {
@include u-font-size('sans', 7);
.subtitle {
@include u-font-size('sans', 9);
font-weight: 400;
color: color($theme-color-base-light);
line-height: 1.2em;
margin-top: 0.25em;
display: block;

@include at-media-max("mobile-lg") {
@include u-font-size('sans', 7);
}
}
}

0 comments on commit 3ecfa46

Please sign in to comment.