<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__image
  ">
        <img class="w-full aspect-video object-cover " alt="" src="/images/feathers.jpg" />
    </div>

    <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 default con click su tutta la card

                </a>
            </h3>

            <div class="flex items-baseline justify-between">

                <div class="n7-card__categories">
                    <span class="n7-category n7-content-placeholder ">
                        Categoria
                    </span>
                </div>

                <div class="n7-card__date text-sm">
                    <time datetime="2023-09-30">30.09.2023</time>
                </div>

            </div>

        </div>

        <p class="n7-card__description text-lg">
            testo da configurazione
        </p>

        <div class="n7-card__action-area ">

            <span class="n7-btn 
    n7-btn--icon-right group/button cursor-pointer n7-btn--primary">

                Card Cta

                <svg class="n7-icon inline-block align-middle fill-current w-4 h-4 md:w-5 md:h-5 transition-all duration-200 ease-out transform group-hover/button:translate-x-1" aria-hidden="true" focusable="false" role="img">
                    <use href="../../icons.svg#mini--chevron-right" />
                </svg>

            </span>

        </div>

        <ul class="flex gap-2 flex-wrap mt-auto" aria-label="Categorie">

            <li><span class="n7-chip   n7-chip--sm">
                    label</span></li>

            <li><span class="n7-chip   n7-chip--sm">
                    label</span></li>

            <li><span class="n7-chip   n7-chip--sm">
                    label</span></li>

            <li><span class="n7-chip   n7-chip--sm">
                    label</span></li>

        </ul>

    </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 default con click su tutta la card",
  "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": ""
  },
  "fullClick": true,
  "image": true,
  "imageAspectRatio": "aspect-video",
  "category": true,
  "actionArea": true,
  "chips": true,
  "date": true,
  "description": "testo da configurazione"
}
  • Content:
    /**
     * 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 ;
        } */
    }
  • URL: /components/raw/card/card.css
  • Filesystem Path: components/03-molecules/card/card.css
  • Size: 594 Bytes
  • Content:
    /* 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();
                }
            }
        }
    });
    
    
  • URL: /components/raw/card/card.js
  • Filesystem Path: components/03-molecules/card/card.js
  • Size: 1.1 KB

Card component configurations

Card component configurations.

Card markup

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.

NOTES FOR CARD MARKUP

Card markup

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).

Heading

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.

Settings for development in nunjucks - TO BE USED IF WORKING WITH NJK AND RAW COMPONENTS

For development - Variable and configuration settings:

  • classes: value - add eventual classes
  • categoryText: value - override category text if needed (default is “Categoria”)
  • heading: value - card title
  • headingClasses: value - add/change heading classes if needed
  • titleClasses: value - add/change title classes if needed
  • thumbClasses: value - add/change thumb classes if needed
  • contentGap: value - change content gap class if needed, default gap-4
  • contentClasses: value - add more classes to content wrapper if needed
  • headingGap: value - change heading elements gap class if needed, default gap-4
  • headingLinkIcon: icon id - use if card heading link needs icon (arrow etc)
  • description: value - description text - text set in config
  • descriptionClasses: value - add/change description classes if needed
  • icon: iconId - set top icon id and manage top icon visualization
  • iconSize: value - set icon width and height classes if needed (defaults are w-24 h-24)
  • iconRadius: value - manage top icon border radius - default rounded
  • iconBg: value - manage top icon background color - default n7-background-02
  • ctaIcon: iconId - icon id for cta
  • ctaWrapperClasses: value - classes for cta wrapper if needed
  • ctaLinkLabel: value - cta link text - text set in config
  • boxShadow: value - manage card shadow - default shadow-sm hover:shadow-lg
  • cardHeight: value - use if card has hasBgImage true, set the card height

Add the component in the card with “true” value

  • category: true (shows category)
  • ctaLink: true (shows cta link)
  • action_area: true (shows cta button)
  • chips: true (shows tags list)
  • date: true (shows date)
  • image: true (shows image)
  • hasSideImage: true (manage card class for side image - card grid class)
  • hasRightSideImage: true (manage card class for right side image - card grid class)
  • fullClick: true (Add the script which manage fullcard clickable area )
  • fileDetails: true - adds file infos (format/weight) if document link card
  • hasBgImage: true (shows image background)

Manage image thumb settings:

  • img:
    • path: /pathto/image.jpg
    • alt: value - ‘Eventual alternative text if image is not descriptive’
    • imgObjectFit: value - manage img object fit if needed (default is cover)
  • imageSize: value - manage thumb size if needed (for side thumb especially)
  • imageAspectRatio: value - set aspect ratio classes if needed (used by default in has-thumb variant)

Blocks:

  • classes
  • image
  • fileDetails
  • contentWrapperStart (add a wrapper if needed around content)
  • headingLinkIcon
  • fullClickable: for fullclick card classes
  • content
  • category
  • date
  • actionArea
  • chips
  • address (add place information)
  • contentWrapperEnd (close wrapper around content)
  • additionalContent (if other content is needed in card variant)