<div class="n7-card grid auto-rows-min
  
 
 
 
 
 
  shadow-sm hover:shadow-lg">

    <div class="w-24 h-24 rounded n7-background-02 p-6">
        <svg class="n7-icon inline-block align-middle fill-current w-12 h-12" aria-hidden="true" focusable="false" role="img">
            <use href="../../icons.svg#mini--information-circle" />
        </svg>

    </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" href="">
                    Componente card esempio

                </a>
            </h3>

        </div>

        <p class="n7-card__description text-lg">
            Neque blandit pellentesque nunc sed amet. Nisl, semper sed aliquam amet proin purus augue et.
        </p>

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

            <a href="#" 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>

            </a>

        </div>

    </div>
    </article>
{% extends '@card' %}
{% block classes %} auto-rows-min{% if classes %} {{ classes }}{% endif %}{% endblock %}
{
  "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": ""
  },
  "icon": "mini--information-circle",
  "description": "Neque blandit pellentesque nunc sed amet. Nisl, semper sed aliquam amet proin purus augue et.",
  "actionArea": true
}
  • 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)