From a348b716f9e113355be8da82e2ed41d80aacdd12 Mon Sep 17 00:00:00 2001 From: Dave Skender <8432125+DaveSkender@users.noreply.github.com> Date: Mon, 26 Jun 2023 22:34:19 -0400 Subject: [PATCH] refactor: catalog settings (#37) --- sass/_site.scss | 9 +- .../pages/card-catalog/catalog.component.html | 116 +++++++++--------- .../pages/card-catalog/catalog.component.scss | 4 + .../pages/card-catalog/catalog.component.ts | 8 +- .../pages/card-catalog/catalog.settings.scss | 21 +++- 5 files changed, 87 insertions(+), 71 deletions(-) diff --git a/sass/_site.scss b/sass/_site.scss index efc74e4..48101c9 100644 --- a/sass/_site.scss +++ b/sass/_site.scss @@ -1,8 +1,8 @@ @use "uswds-core" as *; -// SITE STYLES +/* SITE STYLES */ -// site mixin +/* site mixin */ @mixin site-style { h1 { @@ -96,11 +96,6 @@ max-width: 800px; margin: auto; - border: 5px; - border-style: solid; - border-radius: 1rem; - border-color: color($theme-color-base); - @include at-media-max("mobile-lg") { @include u-padding(2); } diff --git a/src/app/pages/card-catalog/catalog.component.html b/src/app/pages/card-catalog/catalog.component.html index ddbc66a..b7ae941 100644 --- a/src/app/pages/card-catalog/catalog.component.html +++ b/src/app/pages/card-catalog/catalog.component.html @@ -22,8 +22,8 @@

Card catalog

href="https://designsystem.digital.gov/components/card/" target="_blank">Card component with “show more” card loading. Learn more about this design pattern or - - change settings at the bottom of this page. + change settings + at the bottom of this page.

+ +

Showing {{cardStart}}-{{cardEnd}} of {{totalCards}} cards

+ -

Showing {{cardStart}}-{{cardEnd}} of {{totalCards}} cards

-
+
-

About this pattern

+ +
+
+

+ Catalog settings +

+
+ +
+ + + + + + + + + + +
+ + +
+ + + +
    +
  • + +
  • +
  • + +
  • +
+
+ +
+
+
+ +

About this pattern

@@ -152,10 +201,11 @@

What we changed:

href="https://web.dev/patterns/layout/aspect-ratio-image-card/">fixed aspect ratio to ensure a consistent size.
  • 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 ...
  • + allowable raw text, so overflow is rare. Ellipses ... indicate overflows.
  • Full card is clickable to maximize the click/touch target (we also removed the button).
  • A hover shadow effect provides a haptic response to emphasize clickability.
  • Images ease in on load to reduce the visual "pop" that occurs on late arrival.
  • +
  • Lazy load images so only nearby images download and render.
  • Pagination

    @@ -171,7 +221,6 @@

    What we changed:

    • See more and Show all pagination adds next page(s) cards to the collection.
    • -
    • Lazy load images so only nearby images download and render.
    • Optionally, auto-scroll to reposition page to new cards.
    @@ -179,9 +228,9 @@

    Use caution with large catalogs:

    • Show all should not be used with large catalogs that impact page performance.
    • -
    • For large data collections, offload initial cards that exceed a max limit with each subsequent Show - more command. A See previous button can be used at the top of your catalog to - similarly restore.
    • +
    • If you decide to use with a large catalog, offload initial cards that exceed a max limit with each + subsequent Show more. A See previous button can be used at the top + of your catalog to similarly restore.
    @@ -200,52 +249,5 @@

    Use caution with large catalogs:

    - -
    -
    -

    - Page settings -

    -
    - -
    - - - - - - - - - - -
    - - -
    - - - -
      -
    • - -
    • -
    • - -
    • -
    -
    - -
    -
    -
    -
    diff --git a/src/app/pages/card-catalog/catalog.component.scss b/src/app/pages/card-catalog/catalog.component.scss index 8e34634..886fdd9 100644 --- a/src/app/pages/card-catalog/catalog.component.scss +++ b/src/app/pages/card-catalog/catalog.component.scss @@ -92,6 +92,10 @@ /* "see more" button groups at bottom of page */ .usa-button-group { @include u-flex("justify-center"); + + /* match classic height */ + margin-top: 1rem; + margin-bottom: calc(1rem - 8px); } /* classic pagination */ diff --git a/src/app/pages/card-catalog/catalog.component.ts b/src/app/pages/card-catalog/catalog.component.ts index 1389670..6288216 100644 --- a/src/app/pages/card-catalog/catalog.component.ts +++ b/src/app/pages/card-catalog/catalog.component.ts @@ -115,22 +115,22 @@ export class CatalogComponent implements OnInit { } - // PAGINATION SETTINGS + // CATALOG SETTINGS changeTotalCards() { // maintain a rational page size this.pageMax = Math.min(180, this.totalCards); this.pageSize = Math.min(this.pageSize, this.pageMax); - this.resetCatalog(); + this.resetCatalog(true); } updatePageCount() { this.pages = Math.ceil(this.totalCards / this.pageSize); } - resetCatalog() { + resetCatalog(skipScroll = false) { this.cards = []; this.updatePageCount(); - this.showPage(1, false); + this.showPage(1, skipScroll); } } diff --git a/src/app/pages/card-catalog/catalog.settings.scss b/src/app/pages/card-catalog/catalog.settings.scss index 16f70f7..cadc79e 100644 --- a/src/app/pages/card-catalog/catalog.settings.scss +++ b/src/app/pages/card-catalog/catalog.settings.scss @@ -5,12 +5,22 @@ @forward "usa-pagination"; @forward "usa-icon"; -// page configuration +/* page settings */ .usa-summary-box { - margin-top: 50px !important; - background-color: color($theme-color-base-light); + @include u-margin-x(-6); + @include u-margin-top(-4); + @include u-margin-bottom(7); + @include u-padding-x(6); + @include u-padding-y(4); + + @include at-media-max("mobile-lg") { + @include u-margin(-2); + } + + background-color: color($theme-color-base-lighter); border: none; + border-radius: 1rem; .usa-summary-box__heading { color: unset; @@ -38,6 +48,11 @@ &::before { box-shadow: 0 0 0 1px color($theme-color-base); + background-color: color($theme-color-base-lightest); } } + + .usa-button--outline { + background-color: color($theme-color-base-lightest); + } }