Skip to content

Commit c524bbd

Browse files
authored
Add o-article-header (#2137)
1 parent 6580785 commit c524bbd

File tree

5 files changed

+114
-0
lines changed

5 files changed

+114
-0
lines changed

.changeset/shy-bees-doubt.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@cloudfour/patterns': minor
3+
---
4+
5+
Adds Article Header layout object for composing an article's title with relevant meta information
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
@use '../../compiled/tokens/scss/size';
2+
3+
.o-article-header {
4+
display: grid;
5+
gap: size.$rhythm-condensed;
6+
}
7+
8+
.o-article-header__eyebrow {
9+
order: -1;
10+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import { Canvas, Meta, Story } from '@storybook/addon-docs';
2+
// The '!!raw-loader!' syntax is a non-standard, Webpack-specific, syntax.
3+
// See: https://github.com/webpack-contrib/raw-loader#examples
4+
// For now, it seems likely Storybook is pretty tied to Webpack, therefore, we
5+
// are okay with the following Webpack-specific raw loader syntax. It's better
6+
// to leave the ESLint rule enabled globally, and only thoughtfully disable as
7+
// needed (e.g. within a Storybook docs page and not within an actual
8+
// component). This can be revisited in the future if Storybook no longer relies
9+
// on Webpack.
10+
// eslint-disable-next-line @cloudfour/import/no-webpack-loader-syntax
11+
import exampleDemoSource from '!!raw-loader!./demo/example.twig';
12+
import exampleDemo from './demo/example.twig';
13+
14+
<Meta title="Objects/Article Header" />
15+
16+
# Article Header
17+
18+
The Article Header layout object composes an article's title and meta information. The "eyebrow" block is visually oriented above the title, providing additional context up-front (such as the article's taxonomy).
19+
20+
<Canvas>
21+
<Story
22+
name="Example"
23+
parameters={{
24+
docs: {
25+
source: {
26+
code: exampleDemoSource,
27+
},
28+
},
29+
}}
30+
>
31+
{exampleDemo()}
32+
</Story>
33+
</Canvas>
34+
35+
## Template Properties
36+
37+
- `class` (string, optional): Additional CSS classes to append to `class` attribute of containing element.
38+
- `eyebrow` (block): Additional meta content, will display above `title` visually.
39+
- `meta` (block): Supporting content, such as the author and/or publication date.
40+
- `tag_name` (string, default: `header`): Tag to use for containing element.
41+
- `title` (block): The article heading.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{% set _tag_name = tag_name|default('header') %}
2+
{% set _eyebrow_block %}{% block eyebrow %}{% endblock %}{% endset %}
3+
4+
<{{_tag_name}} class="o-article-header{% if class %} {{class}}{% endif %}">
5+
{% block title %}{% endblock %}
6+
{% block meta %}{% endblock %}
7+
{% if _eyebrow_block|trim is not empty %}
8+
<div class="o-article-header__eyebrow">
9+
{{_eyebrow_block}}
10+
</div>
11+
{% endif %}
12+
</{{_tag_name}}>
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
{% embed '@cloudfour/objects/article-header/article-header.twig' only %}
2+
{% block title %}
3+
{% include '@cloudfour/components/heading/heading.twig' with {
4+
"level": -1,
5+
"content": "A Rather Long Headline So We Don’t Forget About Line Breaks"
6+
} only %}
7+
{% endblock %}
8+
{% block meta %}
9+
{% include '@cloudfour/components/author/author.twig' with {
10+
"authors": [
11+
{
12+
"name": "Buster Boo",
13+
"avatar": "/media/avatar-buster-b.jpg",
14+
"link": "#"
15+
}
16+
],
17+
"date": "2022-03-28T12:00:00.000Z"
18+
} only %}
19+
{% endblock %}
20+
{% block eyebrow %}
21+
<h2 class="u-hidden-visually">Categories</h2>
22+
<ul class="o-list o-list--inline">
23+
<li>
24+
{% include '@cloudfour/components/badge/badge.twig' with {
25+
"label": "CSS",
26+
"href": "#",
27+
"rel": "category"
28+
} only %}
29+
</li>
30+
<li>
31+
{% include '@cloudfour/components/badge/badge.twig' with {
32+
"label": "HTML",
33+
"href": "#",
34+
"rel": "category"
35+
} only %}
36+
</li>
37+
<li>
38+
{% include '@cloudfour/components/badge/badge.twig' with {
39+
"label": "Responsive Design",
40+
"href": "#",
41+
"rel": "category"
42+
} only %}
43+
</li>
44+
</ul>
45+
{% endblock %}
46+
{% endembed %}

0 commit comments

Comments
 (0)