<article class="card card--cta card--critter">
<div class="card__body">
<h3 class="card__title">
<a href="#" class="card__link" aria-describedby="atlantic-ghost-crab">Atlantic Ghost Crab</a>
</h3>
<i lang="la" class="card__subtitle">Ocypode quadrata</i>
<div class="card__badge">Critter of the month</div>
<p>Also known as the sand crab, the Atlantic ghost crab is a sand-colored crustacean with a distinct pair of white claws. Ghost crabs are active on coastal beaches in the Chesapeake Bay region from spring through autumn.</p>
<span class="card__pseudoLink" id="atlantic-ghost-crab">View Critter<span class="appendedIcon">‍<i class="fas fa-angle-right"></i></span></span>
</div>
<figure class="card__imageCont">
<img srcset="https://placehold.co/410x249,
https://placehold.co/820x498 2x" src="https://placehold.co/820x498" class="card__image" alt="A yellow sand crab with large white front claws and two black eyes protruding on stalks from the top of its head." />
</figure>
<div class="card__footer">
<span class="card__category"><i class="prependedIcon fas fa-bee"></i>Insects</span>
</div>
</article>
<link media="all" rel="stylesheet" href="/card/card.css" />
<script src="/card/card.js"></script>
<article class="card card--cta card--{{ _self.name }}">
<div class="card__body">
<h3 class="card__title">
<a href="#" class="card__link" aria-describedby="{{ slug }}">{{ title }}</a>
</h3>
{% if subTitle %}<i lang="la" class="card__subtitle">{{ subTitle }}</i>{% endif %}
{% if badge %}<div class="card__badge">{{ badge }}</div>{% endif %}
{{ cardBody|raw }}
<span class="card__pseudoLink" id="{{ slug }}">{% render "@icon--appended" with linkIconArgs %}</span>
</div>
<figure class="card__imageCont">
<img
srcset="https://placehold.co/410x249,
https://placehold.co/820x498 2x"
src="https://placehold.co/820x498"
class="card__image"
alt="{{ cardImgAlt }}"
/>
{% if cardImgCredit %}<figcaption class="card__imgCaption selectableContent">Photo courtesy of {{ cardImgCredit }}</figcaption>{% endif %}
</figure>
<div class="card__footer">
<span class="card__category">{% render "@icon--prepended" with footerIconArgs %}</span>
</div>
</article>
{% import "_macros.twig" as h %}
{{ h.componentAssets('card') }}
{
"title": "Atlantic Ghost Crab",
"slug": "atlantic-ghost-crab",
"subTitle": "Ocypode quadrata",
"badge": "Critter of the month",
"cardBody": "<p>Also known as the sand crab, the Atlantic ghost crab is a sand-colored crustacean with a distinct pair of white claws. Ghost crabs are active on coastal beaches in the Chesapeake Bay region from spring through autumn.</p>",
"cardImgAlt": "A yellow sand crab with large white front claws and two black eyes protruding on stalks from the top of its head.",
"linkIconArgs": {
"text": "View Critter",
"iconClass": "fas fa-angle-right"
},
"footerIconArgs": {
"text": "Insects",
"iconClass": "fas fa-bee"
}
}
import "./card.scss";
@use "../_layout/mixins";
.card {
--card-bg: var(--neutral--light);
display: flex;
flex-direction: column;
max-width: var(--cardMaxWidth, 400px);
}
.card--selectableContent {
@at-root .selectableContent,
& p {
position: relative;
z-index: calc(var(--z) * 11);
}
.card__imgCaption {
pointer-events: auto;
}
}
.card__header {
background-color: var(--neutral--darker);
color: var(--neutral--ultraLight);
padding: 1rem;
display: flex;
flex: 1;
align-items: center;
justify-content: center;
}
.card__heading {
display: flex;
flex-direction: column;
gap: 0.5em;
}
.card__banner {
background-image: var(--cardBannerImage);
background-size: cover;
aspect-ratio: 19/6;
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
background-image: var(--cardBannerImage2x);
}
}
.card__postDate {
order: -1;
margin: 0;
}
.card__body {
padding: 1em;
background-color: var(--card-bg);
border: 1px solid var(--neutral--dark);
flex: 1;
margin: 0;
:where(& > *:not(:first-child)) {
margin-block: 0.7em 0;
}
}
.card__title {
font-size: var(--step-2);
margin: 0;
}
.card__description {
margin-block-start: 0;
}
.card__link {
background-image: none;
}
.card__subtitle {
font-size: var(--step-1);
font-style: italic;
line-height: 1.4;
font-weight: var(--normal-weight);
}
.card__attributes {
margin-block-start: 0;
}
.card__badge {
position: absolute;
top: 0;
left: 0;
max-width: 100%;
background-color: rgba(255, 205, 50, 0.8); //accent with 80% alpha
pointer-events: none;
margin: 0;
padding: var(--step--1);
border-radius: 0 0 10px 0;
font-size: calc(0.9 * var(--step--1));
font-weight: var(--cardBadgeFontWeight, var(--normal-weight));
line-height: 1;
text-transform: uppercase;
z-index: calc(var(--z) * 11);
}
.card__pseudoLink {
@include mixins.link();
@include mixins.blockLink($color: var(--blue--dark));
display: inline-block;
}
.card__moreLink {
font-size: var(--step-09);
@include mixins.blockLink();
display: inline-block;
}
.card__imageCont {
order: -1;
background-color: var(--neutral--ultraDark);
}
.card__image {
@include mixins.responsiveImg();
width: 100%;
vertical-align: top;
}
.card__imgCaption {
font-size: var(--step--2);
font-style: italic;
padding: 0.2rem 1rem 0;
background-color: var(--card-bg);
border-inline: 1px solid var(--neutral--dark);
margin-block-end: -0.4rem;
position: relative;
pointer-events: none;
}
.card__footer {
--footer-bg: var(--neutral--dark);
--footer-color: var(--neutral--ultraDark);
background-color: var(--footer-bg);
padding: 0.7em 1em;
text-align: center;
color: var(--footer-color);
}
.card__category {
font-size: var(--step--1);
line-height: 0.8;
text-transform: uppercase;
display: flex;
justify-content: center;
align-items: center;
.prependedIcon {
font-size: var(--step-1);
}
}
.card--cta {
position: relative;
.card__link {
&:after {
content: "";
z-index: calc(var(--z) * 10);
@include mixins.fillParent();
}
}
.card__image {
transition: opacity 0.2s ease-out;
}
.card__footer {
transition: color 0.2s ease-out, background-color 0.2s ease-out;
}
.card__body,
.card__imgCaption {
transition: background-color 0.2s ease-out;
}
&:hover {
--card-bg: var(--neutral--dark);
.card__image {
opacity: 0.4;
}
.card__footer {
--footer-bg: var(--neutral--ultraDark);
--footer-color: var(--neutral--ultraLight);
}
}
}
.card--public-access {
.card__title {
font-weight: var(--normal-weight);
text-align: center;
}
}
.card--fact {
.card__title {
text-align: center;
color: var(--white);
font-size: var(--step-3);
text-shadow: 0 2px 3px var(--neutral--ultraDark);
}
.card__link {
color: inherit;
}
.card__banner--inverse {
.card__title {
color: var(--type);
font-size: var(--step-4);
font-weight: var(--normal-weight);
text-shadow: none;
}
}
}
Add .card__banner--inverse if the banner image is a lighter color to set the card title to a dark color and alternate style.