-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add "Overview" object for use on the Article Listing page (#1406)
This PR adds an "Overview" object which is used on the Article Listing pages to show a full list of topics and a search bar. The Article Listings prototype was updated to use this component
- Loading branch information
1 parent
3f415c9
commit 7bce713
Showing
11 changed files
with
261 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@cloudfour/patterns': minor | ||
--- | ||
|
||
Added Overview object for use in Article Listings |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
{% 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 %} | ||
{# | ||
In the future we could swap this out for the Input Group component | ||
that's currently in the works. | ||
#} | ||
<label> | ||
<span class="u-hidden-visually">Search</span> | ||
{% include '@cloudfour/components/input/input.twig' %} | ||
</label> | ||
{% 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 %} | ||
{% for topic in topics %} | ||
<li class="u-space-block-end-0"> | ||
{% include '@cloudfour/components/dot-leader/dot-leader.twig' with { | ||
label: topic.title, | ||
count: topic.count, | ||
href: 'https://cloudfour.com/thinks/' | ||
} only %} | ||
</li> | ||
{% endfor %} | ||
{% endblock %} | ||
{% endembed %} | ||
{% endblock %} | ||
{% endembed %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{% embed '@cloudfour/objects/overview/overview.twig' %} | ||
{% block header %} | ||
Header | ||
{% endblock %} | ||
{% block actions %} | ||
Actions | ||
{% endblock %} | ||
{% block content %} | ||
Content | ||
{% endblock %} | ||
{% endembed %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
@use "../../compiled/tokens/scss/breakpoint"; | ||
@use '../../mixins/ms'; | ||
@use "../../compiled/tokens/scss/size"; | ||
@use '../../mixins/fluid'; | ||
|
||
/** | ||
* The Overview stacks content vertically on small screens. | ||
* On large screens the header and actions are stacked horizontally above the content. | ||
* The specific spacing values were inferred from the Article Listing prototype. | ||
*/ | ||
|
||
.o-overview__header { | ||
margin-bottom: ms.step(1); | ||
} | ||
|
||
.o-overview__actions { | ||
margin-bottom: ms.step(3); | ||
} | ||
|
||
@supports (display: grid) { | ||
@media (min-width: breakpoint.$l) { | ||
.o-overview { | ||
@include fluid.column-gap( | ||
breakpoint.$s, | ||
breakpoint.$xl, | ||
size.$spacing-gap-fluid-min, | ||
size.$spacing-gap-fluid-max | ||
); | ||
|
||
align-items: center; | ||
display: grid; | ||
grid-template-areas: | ||
'header header actions' | ||
'content content content'; | ||
grid-template-columns: repeat(3, 1fr); | ||
row-gap: ms.step(3); | ||
} | ||
|
||
.o-overview__header, | ||
.o-overview__actions { | ||
margin: 0; | ||
} | ||
|
||
.o-overview__header { | ||
grid-area: header; | ||
} | ||
|
||
.o-overview__actions { | ||
grid-area: actions; | ||
} | ||
|
||
.o-overview__content { | ||
grid-area: content; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import { Story, Canvas, Meta } from '@storybook/addon-docs/blocks'; | ||
import basicDemo from './demo/basic.twig'; | ||
import advancedDemo from './demo/advanced.twig'; // The '!!raw-loader!' syntax is a non-standard, Webpack-specific, syntax. | ||
// See: https://github.com/webpack-contrib/raw-loader#examples | ||
// For now, it seems likely Storybook is pretty tied to Webpack, therefore, we are | ||
// okay with the following Webpack-specific raw loader syntax. It's better to leave | ||
// the ESLint rule enabled globally, and only thoughtfully disable as needed (e.g. | ||
// within a Storybook docs page and not within an actual component). | ||
// This can be revisited in the future if Storybook no longer relies on Webpack. | ||
// eslint-disable-next-line @cloudfour/import/no-webpack-loader-syntax | ||
import basicDemoSource from '!!raw-loader!./demo/basic.twig'; | ||
// eslint-disable-next-line @cloudfour/import/no-webpack-loader-syntax | ||
import advancedDemoSource from '!!raw-loader!./demo/advanced.twig'; | ||
import topics from '../../components/dot-leader/demo/topics.json'; | ||
|
||
<!-- | ||
Inline stories disabled so media queries will behave as expected within | ||
embedded examples. | ||
--> | ||
|
||
<Meta | ||
title="Objects/Overview" | ||
parameters={{ docs: { inlineStories: false } }} | ||
/> | ||
|
||
# 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). | ||
|
||
<Canvas> | ||
<Story | ||
name="Basic" | ||
height="300px" | ||
parameters={{ | ||
docs: { | ||
source: { | ||
code: basicDemoSource, | ||
}, | ||
}, | ||
}} | ||
> | ||
{basicDemo()} | ||
</Story> | ||
</Canvas> | ||
|
||
## Advanced Usage | ||
|
||
Here's a more complex usage example, showing how the Overview object could be used on the article listing page. | ||
|
||
<Canvas> | ||
<Story | ||
name="Advanced Usage" | ||
height="300px" | ||
parameters={{ | ||
docs: { | ||
source: { | ||
code: advancedDemoSource, | ||
}, | ||
}, | ||
}} | ||
> | ||
{advancedDemo({ topics })} | ||
</Story> | ||
</Canvas> | ||
|
||
## 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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<{{overview_tag|default('section')}} | ||
class="o-overview" | ||
{% if labelledby_id %}aria-labelledby="{{labelledby_id}}"{% endif %} | ||
> | ||
<header class="o-overview__header"> | ||
{% block header %}{% endblock %} | ||
</header> | ||
<div class="o-overview__actions"> | ||
{% block actions %}{% endblock %} | ||
</div> | ||
<div class="o-overview__content"> | ||
{% block content %}{% endblock %} | ||
</div> | ||
</{{overview_tag|default('section')}}> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.