<div class="n7-card grid
is-card-fullclickable transition hover:ring-2 hover:ring-white/20 group/card
shadow-sm hover:shadow-lg">
<div class="n7-card__content grid gap-4
">
<div class="n7-card__heading flex flex-col-reverse gap-4">
<h3 class="n7-card__title text-2xl font-bold">
<a class="hover:underline group-hover/card:underline" href="">
Componente card esempio
</a>
</h3>
</div>
<span class="n7-link
n7-card__action-link n7-action-link--has-icon n7-link--sm
">
Leggi di più
<svg class="n7-icon inline-block align-middle fill-current w-4 h-4 transition-all group-hover/card:translate-x-1" aria-hidden="true" focusable="false" role="img">
<use href="../../icons.svg#mini--arrow-small-right" />
</svg>
</span>
</div>
</article>
<div
class="n7-card grid{% block classes %}{% if classes %} {{ classes }}{% endif %}{% endblock %}
{% block sideImageClasses %}
{% if hasSideImage %} sm:grid-cols-[1fr_1fr] sm:[grid-template-areas:'thumb_content']{% endif %}
{% if hasRightSideImage %} sm:grid-cols-[1fr_1fr] sm:[grid-template-areas:'content_thumb']{% endif %}
{% endblock sideImageClasses %}
{% block fullClickable %}{% if fullClick %} is-card-fullclickable transition hover:ring-2 hover:ring-white/20 group/card{% endif %}{% endblock fullClickable %}
{% if hasBgImage %} text-white rounded-2xl overflow-hidden {{ cardHeight }}{% endif %}
{% if boxShadow %} {{ boxShadow }}{% endif %}"
>
{% block image %}
{% if image %}
<div class="n7-card__image{% if imageClasses %} {{ imageClasses }}{% endif %}{% if imageSize %} {{ imageSize }}{% endif %}
{% if hasSideImage or hasRightSideImage %} sm:[grid-area:thumb]{% endif %}">
<img class="w-full{% if imageAspectRatio %} {{ imageAspectRatio }}{% endif %}{% if img.imgObjectFit %} {{ img.imgObjectFit }}{% else %} object-cover{% endif %} {% if imageFullHeight %} h-full{% endif %}" alt="{{ img.alt }}" src="{{ img.path }}"/>
</div>
{% endif %}
{% endblock image %}
{% if icon %}
<div class="{%- if hasSideImage or hasRightSideImage %} sm:[grid-area:thumb]{% endif %}{% if iconSize %}{{ iconSize }}{% endif %}{% if iconRadius %} {{ iconRadius }}{% else %} rounded{% endif %} {% if iconBg %} {{ iconBg }}{% else %}n7-background-02{% endif %} p-6">
{% render '@icon', { id: icon }, true %}
</div>
{% endif %}
{% if hasBgImage %}
<!-- Immagine di background -->
<img class="w-full h-full object-cover col-[overlay] row-[overlay] rounded-2xl" alt="{{ img.alt }}" src="{{ img.path }}"/>
<!-- Overlay scuro -->
<div class="bg-black-overlay w-full h-full col-[overlay] row-[overlay] rounded-2xl"></div>
{% endif %}
<div class="n7-card__content grid{% if contentGap %} {{ contentGap }}{% else %} gap-4{% endif %}
{% if hasBgImage %} col-[overlay] row-[overlay] relative z-10 p-6{% endif %}
{%- if hasSideImage or hasRightSideImage %} sm:[grid-area:content]{% endif %}{% if contentClasses %} {{ contentClasses }}{% endif %}">
{% block contentWrapperStart %}{% endblock contentWrapperStart %}
<div class="n7-card__heading {{ cardHeadingAlignment }} {% if headingGap %} {{ headingGap }}{% else %} gap-4{% endif %}{% if headingClasses %} {{ headingClasses }}{% endif %}">
<h3 class="n7-card__title {{ titleClasses }}">
<a class="hover:underline{% if fullClick %} group-hover/card:underline{% endif %}{% if headingLinkIcon %} flex items-end{% endif %}" href="">
{{ heading | safe }}
{% block fileDetails %}
{% if fileDetails %}
<span class="flex gap-0.5 items-center pt-1 md:pt-2 text-sm md:text-base font-medium n7-content-03">
{% render '@icon', { id: 'outline--document-text', size: 'w-4 h-4 md:w-5 md:h-5' }, true %}
<span class="sr-only">, </span>PDF - 120Kb
</span>
{% endif %}
{% endblock fileDetails %}
{% block headingLinkIcon %}
{% if headingLinkIcon %}
{% render '@icon', { id: headingLinkIcon, classes: 'ml-auto', size: 'w-4 h-4 md:w-5 md:h-5' }, true %}
{% endif %}
{% endblock headingLinkIcon %}
{% if ctaLink and not fullClick %}<span class="sr-only">: {{ ctaLinkLabel }}</span>{% endif %}
</a>
</h3>
{% block metadatas %}
{% if category or date %}
<div class="flex items-baseline justify-between">
{% block category %}
{% if category %}
<div class="n7-card__categories">
{% render '@category--overline', { text: categoryText, classes: 'n7-content-placeholder'}, true %}
</div>
{% endif %}
{% endblock category %}
{% block date %}
{% if date %}
<div class="n7-card__date text-sm">
<time datetime="2023-09-30">30.09.2023</time>
</div>
{% endif %}
{% endblock date %}
</div>
{% endif %}
{% endblock metadatas %}
</div>
{% block content %}
{% if description %}
<p class="n7-card__description {{ descriptionClasses }}{% if headingLinkIcon %} pr-8 sm:pr-12{% endif %}">
{{ description }}
</p>
{% endif %}
{% endblock %}
{% block address %}{% endblock address %}
{% if ctaLink %}
{% if fullClick %}
{% render '@link--sm', { classes: 'n7-card__action-link n7-action-link--has-icon', iconClasses: 'transition-all group-hover/card:translate-x-1', span: true, hasIcon: 'true', icon: ctaIcon, label: ctaLinkLabel } %}
{% else %}
{% render '@link--sm', { classes: 'n7-card__action-link n7-action-link--has-icon', iconClasses: 'transition-all group-hover/card:translate-x-1', hasIcon: 'true', icon: ctaIcon, label: ctaLinkLabel, href: '#', allyHidden: 'true' } %}
{% endif %}
{% endif %}
{% block actionArea %}
{% if actionArea %}
<div class="n7-card__action-area {{ ctaWrapperClasses }}">
{% if fullClick %}
{% render '@button--icon-right', { span: true, classes:'cursor-pointer n7-btn--primary', label: 'Card Cta'}, true %}
{% else %}
{% render '@button--icon-right', { href:'#', classes: 'cursor-pointer n7-btn--primary', label: 'Card Cta'}, true %}
{% endif %}
</div>
{% endif %}
{% endblock actionArea %}
{% block chips %}
{% if chips %}
<ul class="flex gap-2 flex-wrap mt-auto" aria-label="Categorie">
{% for i in range(0,4) %}
<li>{% render '@chip--sm' %}</li>
{% endfor %}
</ul>
{% endif %}
{% endblock chips %}
{% block contentWrapperEnd %}{% endblock contentWrapperEnd %}
{% block additionalContent %}{% endblock additionalContent %}
</div>
</article>
{
"categoryText": "Categoria",
"iconSize": "w-24 h-24",
"titleClasses": "text-2xl font-bold",
"heading": "Componente card esempio",
"text": "Testo",
"descriptionClasses": "text-lg",
"ctaIcon": "mini--arrow-small-right",
"ctaLinkLabel": "Leggi di più",
"cardHeadingAlignment": "flex flex-col-reverse",
"boxShadow": "shadow-sm hover:shadow-lg",
"img": {
"path": "/images/feathers.jpg",
"alt": ""
},
"ctaLink": true,
"fullClick": true
}
/**
* CARD
*
*/
@layer components {
.n7-card {
@apply p-6 grid gap-6 bg-white;
}
/* CARD IN GRID COL */
.n7-col .n7-card {
@apply h-full;
}
/*.n7-card__heading.flex-col-reverse {
@apply justify-end;
}
/* .n7-card--event .n7-card__heading {
@apply gap-3;
} */
/*
.n7-card--event .n7-card__title {
@apply font-normal text-base leading-tight uppercase;
} */
/* CARD EVENT */
/* .n7-card--event {
@apply p-0;
} */
/* .n7-card--event .n7-card__content {
@apply ;
} */
}
/* From INCLUSIVE COMPONENT LIBRARY by Heydon Pickering
* https://inclusive-components.design/
* card pattern:
* https://inclusive-components.design/cards/
* Create redundant click event on the whole card, using only
* card heading link
* A click handler on the card's container element
* simply triggers the click method on the link inside it
* Add also a delay in click, in order to detect if the user is selecting the text and not clicking
*/
const cards = document.querySelectorAll('.n7-card.is-card-fullclickable');
Array.prototype.forEach.call(cards, card => {
let down, up, link = card.querySelector('.n7-card__title a');
card.style.cursor = 'pointer';
card.onmousedown = (e) => {
// Verifica se è il tasto sinistro (0)
if (e.button === 0) {
down = +new Date();
}
}
card.onmouseup = (e) => {
// Procedi solo se è il tasto sinistro (0)
if (e.button === 0) {
up = +new Date();
if ((up - down) < 200) {
link.click();
}
}
}
});
Card component configurations.
Reference to card inclusive pattern by Heydon Pickering: https://inclusive-components.design/cards/
Fullclickable card is managed with a script; add the class
is-card-fullclickable
to the card and the script will manage the clickable area. Link is present only in card title <a>. In order to manage microinteractions and hover effects, Card has also transition hover:shadow-lg group classes; title link has also group-hover:underline class.
By default settings, card markup is made with article tag. However, that could not be always the right choice, article should be used for card representing a self-contained entity (e.g. a news item, a blog post, etc., with a heading, a date, an excerpt, a thumbnail, etc.). In some cases it might be better to use a div tag instead, and used in a list context (ul with role=”list”, and wrapped in a li item with class n7-col: e.g. in a list of links, for a card representing a link).
By default, card heading is h3. That means that card should be used in a section with a h2 heading labelling the section. This h2 could be visibile or sr-only. Sextions should always be labelled and identified by a heading. This should be discussed with the design team, if needed.
For development - Variable and configuration settings:
Add the component in the card with “true” value
Manage image thumb settings:
Blocks: