Skip to content

Commit 6fd9938

Browse files
committed
Add c-card--circle-cover modifier
1 parent 166c7c4 commit 6fd9938

File tree

6 files changed

+212
-172
lines changed

6 files changed

+212
-172
lines changed

.changeset/clean-tools-happen.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 the `c-card--circle-cover` modifier for circular card covers, intended for team member listings

src/components/card/card.scss

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,14 @@ $_focus-overflow: (size.$edge-large * -1);
7575
}
7676
}
7777

78+
/**
79+
* Center-align text content to better match a circular cover image
80+
*/
81+
82+
.c-card--circle-cover {
83+
text-align: center;
84+
}
85+
7886
/**
7987
* Responsive horizontal modifiers
8088
*
@@ -101,6 +109,21 @@ $_focus-overflow: (size.$edge-large * -1);
101109
'cover cover .';
102110
grid-template-columns: repeat(3, 1fr); /* 2 */
103111
grid-template-rows: 1fr repeat(3, minmax(0, auto)) 1fr; /* 3 */
112+
113+
/**
114+
* When the cover image is circular (and thus taller), give it a smaller
115+
* amount of space and keep the text left-aligned.
116+
*/
117+
118+
&.c-card--circle-cover {
119+
grid-template-areas:
120+
'cover . .'
121+
'cover header header'
122+
'cover content content'
123+
'cover footer footer'
124+
'cover . .';
125+
text-align: left;
126+
}
104127
}
105128
}
106129

@@ -204,6 +227,18 @@ $_focus-overflow: (size.$edge-large * -1);
204227
grid-area: cover;
205228
@include ratio-box.core-styles($ratio: aspect-ratio.$wide);
206229

230+
/**
231+
* Square aspect ratio + fully rounded corners = circular cover image
232+
*/
233+
234+
.c-card--circle-cover & {
235+
border-radius: size.$border-radius-full;
236+
237+
&::before {
238+
padding-bottom: 100%;
239+
}
240+
}
241+
207242
/**
208243
* Since this element is always visually on top, we can assume it needs a
209244
* bottom margin _unless_ it's an only child. Unfortunately we need to

src/components/card/card.stories.mdx

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ const singleDemoStory = (args) => {
2323
if (args.theme !== 'none') {
2424
classNames.push(`t-${args.theme}`);
2525
}
26+
if (args.class) {
27+
classNames.push(args.class);
28+
}
2629
if (classNames.length > 0) {
2730
props.class = classNames.join(' ');
2831
}
@@ -157,6 +160,41 @@ If a card with a cover is meant to occupy its full container width, it may be pr
157160

158161
Horizontal cards will attempt to span all available columns of a CSS Grid Layout. This comes in handy when displaying them [in a Deck](/docs/objects-deck--horizontal-card#with-horizontal-cards).
159162

163+
## With circular cover
164+
165+
The `c-card--circle-cover` modifier will change the appearance of the cover and adjacent content in the following ways:
166+
167+
- The cover image's aspect ratio will be square.
168+
- The cover image will be fully rounded into a circle shape.
169+
- When vertical, the card's text alignment will be centered to better align with the circle.
170+
- When horizontal, the card's content will occupy more room than its image to account for the taller aspect ratio of the cover image.
171+
172+
This variation is best suited for links to bio information, such as on our team page.
173+
174+
<Canvas>
175+
<Story
176+
name="Circular Cover Image"
177+
args={{ class: 'c-card--circle-cover', href: '#', horizontal: '@m' }}
178+
parameters={{
179+
docs: {
180+
source: {
181+
code: `{% embed '@cloudfour/components/card/card.twig' with {
182+
class: 'c-card--circle-cover c-card--horizontal@m',
183+
href: '#'
184+
} only %}
185+
{% block heading %}Lorem ipsum dolor sit amet{% endblock %}
186+
{% block cover %}<img src="https://placeimg.com/800/450/animals" alt="">{% endblock %}
187+
{% block content %}<p>Consectetur adipiscing elit...</p>{% endblock %}
188+
{% block footer %}<p>{{'now'|date('M j, Y')}}</p>{% endblock %}
189+
{% endembed %}`,
190+
},
191+
},
192+
}}
193+
>
194+
{singleDemoStory.bind({})}
195+
</Story>
196+
</Canvas>
197+
160198
## Contained
161199

162200
A card with the `c-card--contained` class will gain a background color, padding and rounded corners. This can be helpful for offsetting the card visually from its surroundings.
@@ -230,5 +268,4 @@ When the card is a focal point and more contrast is desired, you may also attach
230268

231269
## Coming soon
232270

233-
- Progressive enhancement based on CSS Grid support
234271
- Distinctly contained footers for PWA Stats (if necessary)

src/prototypes/team/example/team-list.scss

Lines changed: 0 additions & 34 deletions
This file was deleted.

0 commit comments

Comments
 (0)