diff --git a/.changeset/five-turkeys-double.md b/.changeset/five-turkeys-double.md new file mode 100644 index 000000000..10b8a6fcf --- /dev/null +++ b/.changeset/five-turkeys-double.md @@ -0,0 +1,5 @@ +--- +'@cloudfour/patterns': major +--- + +Renamed the Heading property from `permalink_id` to `id` and allowed you to use `id` when `permalink` is false. diff --git a/.changeset/shaggy-pumpkins-hug.md b/.changeset/shaggy-pumpkins-hug.md new file mode 100644 index 000000000..ef97711e9 --- /dev/null +++ b/.changeset/shaggy-pumpkins-hug.md @@ -0,0 +1,5 @@ +--- +'@cloudfour/patterns': minor +--- + +Added Overview object for use in Article Listings diff --git a/src/components/heading/heading.stories.mdx b/src/components/heading/heading.stories.mdx index 05de59fe4..98569489a 100644 --- a/src/components/heading/heading.stories.mdx +++ b/src/components/heading/heading.stories.mdx @@ -76,6 +76,8 @@ The `c-heading` class may include a permalink using [a technique from Marcy Sutt - `c-heading__content`: The actual semantic heading element (usually `

` – `

`), including the `id` referenced by `c-heading__permalink`. - `c-heading__permalink`: The `` element that exposes the permalink to the user. This element is kept separate from the actual heading so it won't disrupt a user's ability to navigate via headings. +You can specify an ID that will be used for the heading (and therefore the permalink hash) using the `id` property. (The `id` property can also be used without permalinking.) + Note that the layout of this pattern is optimized for [our prose containers](/docs/objects-container--prose#prose) with generous horizontal whitespace. + + + +# Overview + +The Overview object can be used to provide an overview of a site section. For example, it is used to provide an index of article categories, as well as a form to search for articles. + +It handles the responsive layout of `header`, `actions`, and `content` blocks. On small screens they are stacked vertically. On large screens the `header` and `actions` blocks stack horizontally above the `content` block. + +It should usually be placed in a [Container](/docs/objects-container--basic). + + + + {basicDemo()} + + + +## Advanced Usage + +Here's a more complex usage example, showing how the Overview object could be used on the article listing page. + + + + {advancedDemo({ topics })} + + + +## Template Properties + +- `overview_tag` - defaults to `section` but can be switched out for any HTML tag. +- `labelledby_id` - an optional ID to use with the `aria-labelledby` attribute. + +## Template blocks + +- `header` - should generally contain a [Heading](/docs/components-heading--levels) +- `actions` - could contain a searchbar or other actions +- `content` the primary overview content. For example, a list of categories. diff --git a/src/objects/overview/overview.twig b/src/objects/overview/overview.twig new file mode 100644 index 000000000..17426ccdd --- /dev/null +++ b/src/objects/overview/overview.twig @@ -0,0 +1,14 @@ +<{{overview_tag|default('section')}} + class="o-overview" + {% if labelledby_id %}aria-labelledby="{{labelledby_id}}"{% endif %} +> +
+ {% block header %}{% endblock %} +
+
+ {% block actions %}{% endblock %} +
+
+ {% block content %}{% endblock %} +
+ diff --git a/src/prototypes/article-listing/example/example.scss b/src/prototypes/article-listing/example/example.scss index f1a300284..e20702910 100644 --- a/src/prototypes/article-listing/example/example.scss +++ b/src/prototypes/article-listing/example/example.scss @@ -74,31 +74,8 @@ } } - .topics-header { - padding-bottom: ms.step(3); - - @media (min-width: breakpoint.$l) { - display: grid; - @include fluid.grid-gap( - breakpoint.$s, - breakpoint.$xl, - size.$spacing-gap-fluid-min, - size.$spacing-gap-fluid-max - ); - grid-template-columns: repeat(3, minmax(max-content, 1fr)); - padding-bottom: ms.step(3); - } - } - .search-content { - align-items: center; display: flex; - grid-column: 3 / -1; - padding-top: ms.step(1); - - @media (min-width: breakpoint.$l) { - padding-top: 0; - } } .search-input { @@ -115,24 +92,4 @@ .search-btn .c-icon { font-size: ms.step(1); } - - .topics-content { - @media (min-width: breakpoint.$m) { - columns: 2; - @include fluid.grid-gap( - breakpoint.$s, - breakpoint.$xl, - size.$spacing-gap-fluid-min, - size.$spacing-gap-fluid-max - ); - } - - @media (min-width: breakpoint.$l) { - columns: 3; - } - } - - .topics-content li { - margin-bottom: ms.step(0); - } } diff --git a/src/prototypes/article-listing/example/example.twig b/src/prototypes/article-listing/example/example.twig index ef0e29308..b78de8bb9 100644 --- a/src/prototypes/article-listing/example/example.twig +++ b/src/prototypes/article-listing/example/example.twig @@ -168,41 +168,50 @@ {% endfor %}
-
- {% include '@cloudfour/components/heading/heading.twig' with { - level: -1, - tag_name: 'h2', - weight: 'light', - content: 'More Topics', - } only %} -
- {% include '@cloudfour/components/input/input.twig' with { - class: 'search-input' - } %} - {% embed '@cloudfour/components/button/button.twig' with { - class: 'search-btn' - } %} + {% embed '@cloudfour/objects/overview/overview.twig' with { + labelledby_id: 'more-topics' + } %} + {% block header %} + {% include '@cloudfour/components/heading/heading.twig' with { + level: -1, + weight: "light", + content: 'More Topics', + id: 'more-topics' + } only %} + {% endblock %} + {% block actions %} +
+ {% include '@cloudfour/components/input/input.twig' with { + class: 'search-input' + } %} + {% embed '@cloudfour/components/button/button.twig' with { + class: 'search-btn' + } %} + {% block content %} + {% include '@cloudfour/components/icon/icon.twig' with { + name: 'magnifying-glass' + } %} + {% endblock %} + {% endembed %} +
+ {% endblock %} + {% block content %} + {% embed '@cloudfour/objects/list/list.twig' with { + "tag_name": "ul", + "class": "o-list--2-column@m o-list--3-column@l" + } %} {% block content %} - {% include '@cloudfour/components/icon/icon.twig' with { - name: 'magnifying-glass' - } %} + {% for topic in topics %} +
  • + {% include '@cloudfour/components/dot-leader/dot-leader.twig' with { + label: topic.title, + count: topic.count, + href: 'https://cloudfour.com/thinks/' + } only %} +
  • + {% endfor %} {% endblock %} {% endembed %} -
    -
    - {% embed '@cloudfour/objects/list/list.twig' with { - class: 'topics-content' - } %} - {% block content %} - {% for topic in topics %} -
  • - {% include '@cloudfour/components/dot-leader/dot-leader.twig' with { - label: topic.title, - count: topic.count, - href: 'https://cloudfour.com/thinks/' - } only %} -
  • - {% endfor %} {% endblock %} {% endembed %}