Skip to content

Commit c095d4d

Browse files
Add eyebrow block to card component (#2144)
* Reorganize logos * Add eyebrow block to card component --------- Co-authored-by: Scott Vandehey <[email protected]>
1 parent 687d737 commit c095d4d

File tree

15 files changed

+68
-8
lines changed

15 files changed

+68
-8
lines changed

.changeset/hip-cars-collect.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+
Add `eyebrow` block for including branding elements in card component headers

src/components/card/card.scss

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,14 @@ $_content-gap: ms.step(-1, 1rem);
3131

3232
$_cover-gap: ms.step(1, 1rem);
3333

34+
/// We add more space between the eyebrow and heading so they won't feel as
35+
/// crowded if the eyebrow contains visual elements.
36+
///
37+
/// @type Number
38+
/// @access private
39+
40+
$_eyebrow-gap: ms.step(1, 1rem);
41+
3442
/// The focus outline feels a little snug directly on the outer edge, but we
3543
/// don't want to extend _too_ far out for fear of colliding with adjacent
3644
/// content. Doubling the size of the focus edge felt like a nice compromise.
@@ -198,9 +206,13 @@ $_cloud-height: fluid.fluid-clamp(
198206
*
199207
* This exists separately from the heading to encourage the use of the `header`
200208
* element within an `article`.
209+
*
210+
* 1. This display type and gap exist in case an `eyebrow` block is included.
201211
*/
202212

203213
.c-card__header {
214+
display: grid; /* 1 */
215+
gap: $_eyebrow-gap; /* 1 */
204216
grid-area: header;
205217

206218
/**
@@ -223,6 +235,14 @@ $_cloud-height: fluid.fluid-clamp(
223235
@include headings.level(2);
224236
}
225237

238+
/**
239+
* The eyebrow should precede the heading visually.
240+
*/
241+
242+
.c-card__eyebrow {
243+
order: -1;
244+
}
245+
226246
/**
227247
* This is the primary link, presumed but not required to be within the heading.
228248
*/

src/components/card/card.stories.mdx

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ const singleDemoStory = (args) => {
4949
};
5050
const singleDemoBlockExamples = {
5151
heading: 'Lorem ipsum dolor sit amet',
52+
eyebrow: `<img src="/media/logos/pleasantest.svg" alt="Pleasantest" width="180" height="58">`,
5253
cover: `<img src="/media/feature-ozzie-wide.jpg" alt="">`,
5354
content: `<p>Consectetur adipiscing elit...</p>`,
5455
footer: `<p>{{'now'|date('M j, Y')}}</p>`,
@@ -84,7 +85,7 @@ const singleDemoTransformSource = (_src, storyContext) => {
8485
}}
8586
argTypes={{
8687
show: {
87-
options: ['heading', 'cover', 'content', 'footer'],
88+
options: ['heading', 'eyebrow', 'cover', 'content', 'footer'],
8889
control: {
8990
type: 'inline-check',
9091
},
@@ -148,6 +149,22 @@ An optional `cover` block may be provided containing an image or other visual ob
148149
</Story>
149150
</Canvas>
150151

152+
## With eyebrow
153+
154+
If a card includes a heading, you may want to include additional elements that precede the heading visually without disrupting the element's outline. For example, a customer's logo in a card that links to a case study. Similar to [the Article Header object](/?path=/docs/objects-article-header--example), the contents of the `eyebrow` block will render below the heading in the DOM, but display above the heading visually.
155+
156+
<Canvas>
157+
<Story
158+
name="Eyebrow"
159+
args={{
160+
href: '#',
161+
show: ['heading', 'eyebrow', 'content'],
162+
}}
163+
>
164+
{singleDemoStory.bind({})}
165+
</Story>
166+
</Canvas>
167+
151168
## Horizontal
152169

153170
If a card with a cover is meant to occupy its full container width, it may be preferable to display it horizontally at larger [breakpoints](/docs/design-tokens-breakpoint--page). The `c-card--horizontal@m`, `c-card--horizontal@l` and `c-card--horizontal@xl` modifier classes will do that from their respective breakpoints.
@@ -238,6 +255,7 @@ The `c-card--cloudy` modifier is meant to pair with `c-card--contained` and `t-d
238255

239256
- `content` (optional): The main card content.
240257
- `cover` (optional): Designed to provide an image or other visual object. Will display using our `wide` [aspect ratio token](/story/design-tokens-aspect-ratio--page), and includes an effect on hover if the card includes an `href`.
258+
- `eyebrow` (optional): Content to precede the `heading` visually, such as a customer logo.
241259
- `footer` (optional): Information about the author or additional supporting content for the card.
242260
- `heading` (optional): The contents of the heading. The heading level may be customized using the `heading_level` property.
243261

src/components/card/card.twig

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
{% set _heading_level = heading_level|default(2) %}
1414

1515
{% set _heading_block %}{% block heading %}{% endblock %}{% endset %}
16+
{% set _eyebrow_block %}{% block eyebrow %}{% endblock %}{% endset %}
1617
{% set _cover_block %}{% block cover %}{% endblock %}{% endset %}
1718
{% set _content_block %}{% block content %}{% endblock %}{% endset %}
1819
{% set _footer_block %}{% block footer %}{% endblock %}{% endset %}
@@ -34,6 +35,11 @@
3435
{{ _heading_block }}
3536
{% endif %}
3637
</h{{ _heading_level }}>
38+
{% if _eyebrow_block is not empty %}
39+
<div class="c-card__eyebrow">
40+
{{_eyebrow_block}}
41+
</div>
42+
{% endif %}
3743
</{{ _header_tag_name }}>
3844
{% endif %}
3945

src/components/card/demo/div.twig

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@
55
Lorem ipsum dolor sit amet
66
{%- endif -%}
77
{% endblock %}
8+
{% block eyebrow %}
9+
{%- if show_eyebrow -%}
10+
<img src="/media/logos/pleasantest.svg" alt="Pleasantest" width="180" height="58">
11+
{%- endif -%}
12+
{% endblock %}
813
{% block cover %}
914
{%- if show_cover -%}
1015
<img src="/media/feature-ozzie-wide.jpg" alt="">

src/components/card/demo/single.twig

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44
Lorem ipsum dolor sit amet
55
{%- endif -%}
66
{% endblock %}
7+
{% block eyebrow %}
8+
{%- if show_eyebrow -%}
9+
<img src="/media/logos/pleasantest.svg" alt="Pleasantest" width="180" height="58">
10+
{%- endif -%}
11+
{% endblock %}
712
{% block cover %}
813
{%- if show_cover -%}
914
<img src="/media/feature-ozzie-wide.jpg" alt="">
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
11
[
22
{
33
"alt": "Walmart",
4-
"src": "media/client-logos/logo-walmart.svg"
4+
"src": "media/logos/walmart.svg"
55
},
66
{
77
"alt": "Deschutes Brewery",
8-
"src": "media/client-logos/logo-deschutes.svg"
8+
"src": "media/logos/deschutes.svg"
99
},
1010
{
1111
"alt": "Obama '08",
12-
"src": "media/client-logos/logo-obama.svg"
12+
"src": "media/logos/obama.svg"
1313
},
1414
{
1515
"alt": "Treasure Coast Hospice",
16-
"src": "media/client-logos/logo-treasurecoast.svg"
16+
"src": "media/logos/treasurecoast.svg"
1717
},
1818
{
1919
"alt": "Entertainment",
20-
"src": "media/client-logos/logo-entertainment.svg"
20+
"src": "media/logos/entertainment.svg"
2121
},
2222
{
2323
"alt": "Hautelook",
24-
"src": "media/client-logos/logo-hautelook.svg"
24+
"src": "media/logos/hautelook.svg"
2525
},
2626
{
2727
"alt": "Ceasefire Oregon",
28-
"src": "media/client-logos/logo-ceasefire.svg"
28+
"src": "media/logos/ceasefire.svg"
2929
}
3030
]
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)