🌅 HérosGratuit · 0 NahnahPar NAHNAH AI
Héros diaporama
Diaporama plein écran : fondu entre les diapositives, flèches, points et bouton pause accessibles, glissement au doigt, pause au survol et au focus.
Aperçu en direct
Données de démonstration (produits, menus, textes d’exemple) : dans ta boutique, ce sont les tiennes.
Code à copier
Fichier complet sections/nahnah-hero-diaporama.liquid (Liquid, CSS et JS inclus).
{%- comment -%} NAHNAH AI · Héros diaporama (bibliothèque Sections & effets) {%- endcomment -%}
<nn-hero-diaporama class="nn-hero-diaporama" style="--nn-mh: {{ section.settings.marge_haut }}px; --nn-mb: {{ section.settings.marge_bas }}px; --nn-fond: {{ section.settings.couleur_fond }}; --nn-texte: {{ section.settings.couleur_texte }}; --nn-accent: {{ section.settings.couleur_accent }}; --nn-bouton: {{ section.settings.couleur_bouton }}; --nn-texte-bouton: {{ section.settings.couleur_texte_bouton }}; --nn-voile: {{ section.settings.voile | divided_by: 100.0 }};" role="region" aria-roledescription="carrousel" aria-label="{{ section.settings.libelle | escape }}" data-auto="{{ section.settings.auto }}" data-delai="{{ section.settings.delai }}">
<div class="nn-hero-diaporama__piste nn-hero-diaporama--h-{{ section.settings.hauteur }}" data-nn-piste>
{%- for block in section.blocks -%}
<div class="nn-hero-diaporama__diapo{% if forloop.first %} nn-hero-diaporama__diapo--active{% endif %}" role="group" aria-roledescription="diapositive" aria-label="{{ forloop.index }} sur {{ forloop.length }}" data-nn-diapo{% unless forloop.first %} aria-hidden="true" inert{% endunless %} {{ block.shopify_attributes }}>
<div class="nn-hero-diaporama__media">
{%- if block.settings.image != blank -%}
{{ block.settings.image | image_url: width: 1800 | image_tag: class: 'nn-hero-diaporama__img', sizes: '100vw', widths: '600, 900, 1200, 1800' }}
{%- else -%}
{{ 'lifestyle-2' | placeholder_svg_tag: 'nn-hero-diaporama__img nn-hero-diaporama__img--vide' }}
{%- endif -%}
</div>
<div class="nn-hero-diaporama__voile" aria-hidden="true"></div>
<div class="nn-hero-diaporama__contenu">
{%- if block.settings.surtitre != blank -%}<p class="nn-hero-diaporama__surtitre">{{ block.settings.surtitre | escape }}</p>{%- endif -%}
{%- if block.settings.titre != blank -%}<h2 class="nn-hero-diaporama__titre">{{ block.settings.titre }}</h2>{%- endif -%}
{%- if block.settings.texte != blank -%}<div class="nn-hero-diaporama__texte">{{ block.settings.texte }}</div>{%- endif -%}
{%- if block.settings.bouton_texte != blank -%}
<div class="nn-hero-diaporama__boutons"><a class="nn-hero-diaporama__bouton" href="{{ block.settings.bouton_lien | default: routes.all_products_collection_url }}">{{ block.settings.bouton_texte | escape }}</a></div>
{%- endif -%}
</div>
</div>
{%- endfor -%}
</div>
{%- if section.blocks.size > 1 -%}
<div class="nn-hero-diaporama__commandes">
<button type="button" class="nn-hero-diaporama__fleche" data-nn-prec aria-label="Diapositive précédente"><svg aria-hidden="true" focusable="false" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M15 6l-6 6 6 6"/></svg></button>
<div class="nn-hero-diaporama__points">
{%- for block in section.blocks -%}
<button type="button" class="nn-hero-diaporama__point" data-nn-point="{{ forloop.index0 }}" aria-label="Aller à la diapositive {{ forloop.index }}"{% if forloop.first %} aria-current="true"{% endif %}></button>
{%- endfor -%}
</div>
<button type="button" class="nn-hero-diaporama__fleche" data-nn-suiv aria-label="Diapositive suivante"><svg aria-hidden="true" focusable="false" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M9 6l6 6-6 6"/></svg></button>
<button type="button" class="nn-hero-diaporama__fleche nn-hero-diaporama__lecture" data-nn-lecture aria-label="Mettre le défilement en pause" hidden><svg class="nn-hero-diaporama__ico-pause" aria-hidden="true" focusable="false" viewBox="0 0 24 24" fill="currentColor"><rect x="6" y="5" width="4" height="14" rx="1"/><rect x="14" y="5" width="4" height="14" rx="1"/></svg><svg class="nn-hero-diaporama__ico-lecture" aria-hidden="true" focusable="false" viewBox="0 0 24 24" fill="currentColor"><path d="M8 5.5v13a1 1 0 0 0 1.5.86l10.5-6.5a1 1 0 0 0 0-1.72L9.5 4.64A1 1 0 0 0 8 5.5z"/></svg></button>
</div>
{%- endif -%}
</nn-hero-diaporama>
{% schema %}
{
"name": "Héros diaporama",
"tag": "section",
"class": "nn-section-hero-diaporama",
"max_blocks": 6,
"settings": [
{
"type": "text",
"id": "libelle",
"label": "Nom du diaporama (lecteurs d’écran)",
"default": "Mises en avant"
},
{
"type": "checkbox",
"id": "auto",
"label": "Défilement automatique",
"default": true
},
{
"type": "range",
"id": "delai",
"label": "Durée d’une diapositive",
"min": 3,
"max": 12,
"step": 1,
"default": 6,
"unit": "s"
},
{
"type": "range",
"id": "voile",
"label": "Opacité du voile",
"min": 0,
"max": 90,
"step": 5,
"default": 40,
"unit": "%"
},
{
"type": "select",
"id": "hauteur",
"label": "Hauteur",
"options": [
{
"value": "petite",
"label": "Petite"
},
{
"value": "moyenne",
"label": "Moyenne"
},
{
"value": "grande",
"label": "Grande"
},
{
"value": "ecran",
"label": "Plein écran"
}
],
"default": "grande"
},
{
"type": "header",
"content": "Couleurs"
},
{
"type": "color",
"id": "couleur_fond",
"label": "Fond",
"default": "#0B1220"
},
{
"type": "color",
"id": "couleur_texte",
"label": "Texte",
"default": "#FFFFFF"
},
{
"type": "color",
"id": "couleur_accent",
"label": "Accent",
"default": "#2EE6A8"
},
{
"type": "color",
"id": "couleur_bouton",
"label": "Bouton",
"default": "#FFFFFF"
},
{
"type": "color",
"id": "couleur_texte_bouton",
"label": "Texte du bouton",
"default": "#0B1220"
},
{
"type": "header",
"content": "Espacement"
},
{
"type": "range",
"id": "marge_haut",
"label": "Marge haute",
"min": 0,
"max": 120,
"step": 4,
"unit": "px",
"default": 0
},
{
"type": "range",
"id": "marge_bas",
"label": "Marge basse",
"min": 0,
"max": 120,
"step": 4,
"unit": "px",
"default": 0
}
],
"blocks": [
{
"type": "diapo",
"name": "Diapositive",
"settings": [
{
"type": "image_picker",
"id": "image",
"label": "Image"
},
{
"type": "text",
"id": "surtitre",
"label": "Sur-titre (vide : masqué)"
},
{
"type": "inline_richtext",
"id": "titre",
"label": "Titre",
"default": "Titre de la diapositive"
},
{
"type": "richtext",
"id": "texte",
"label": "Texte",
"default": "<p>Un court texte pour donner envie de cliquer.</p>"
},
{
"type": "text",
"id": "bouton_texte",
"label": "Texte du bouton (vide : masqué)",
"default": "Découvrir"
},
{
"type": "url",
"id": "bouton_lien",
"label": "Lien du bouton"
}
]
}
],
"presets": [
{
"name": "Héros diaporama",
"blocks": [
{
"type": "diapo",
"settings": {
"surtitre": "Nouveautés",
"titre": "Les nouveautés sont arrivées",
"texte": "<p>Découvre les dernières pièces ajoutées à la boutique.</p>",
"bouton_texte": "Voir les nouveautés"
}
},
{
"type": "diapo",
"settings": {
"surtitre": "Idées cadeaux",
"titre": "Fais plaisir sans te tromper",
"texte": "<p>Une sélection facile à offrir, pour toutes les occasions.</p>",
"bouton_texte": "Trouver un cadeau"
}
},
{
"type": "diapo",
"settings": {
"surtitre": "Petits prix",
"titre": "Les bons plans du moment",
"texte": "<p>Des articles à prix réduit, dans la limite des stocks.</p>",
"bouton_texte": "Voir les offres"
}
}
]
}
]
}
{% endschema %}
{% stylesheet %}
.nn-hero-diaporama {
position: relative;
display: block;
padding: var(--nn-mh) 0 var(--nn-mb);
background: var(--nn-fond);
color: var(--nn-texte);
overflow-x: clip;
}
.nn-hero-diaporama *, .nn-hero-diaporama *::before, .nn-hero-diaporama *::after { box-sizing: border-box; }
.nn-hero-diaporama :where(a, button):focus-visible { outline: 3px solid var(--nn-accent); outline-offset: 3px; }
.nn-hero-diaporama__surtitre { margin: 0 0 12px; font-size: 13px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--nn-accent); }
.nn-hero-diaporama__titre { margin: 0 0 16px; font-size: clamp(32px, 6vw, 60px); line-height: 1.08; letter-spacing: -0.02em; overflow-wrap: anywhere; color: inherit; }
.nn-hero-diaporama__texte { margin: 0 0 28px; font-size: clamp(16px, 1.6vw, 19px); line-height: 1.6; opacity: 0.88; max-width: 560px; }
.nn-hero-diaporama__texte p { margin: 0 0 0.6em; }
.nn-hero-diaporama__boutons { display: flex; flex-wrap: wrap; gap: 12px; }
.nn-hero-diaporama__bouton {
display: inline-flex;
align-items: center;
justify-content: center;
min-height: 48px;
max-width: 100%;
padding: 14px 28px;
border-radius: var(--nn-arrondi-bouton, 8px);
background: var(--nn-bouton);
color: var(--nn-texte-bouton);
font-size: 16px;
font-weight: 700;
line-height: 1.2;
text-align: center;
text-decoration: none;
transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.nn-hero-diaporama__bouton--second { background: transparent; color: inherit; box-shadow: inset 0 0 0 2px currentColor; }
@media (hover: hover) {
.nn-hero-diaporama__bouton:hover { transform: translateY(-2px); box-shadow: 0 12px 26px color-mix(in srgb, var(--nn-bouton) 35%, transparent); }
.nn-hero-diaporama__bouton--second:hover { box-shadow: inset 0 0 0 2px currentColor, 0 12px 26px rgba(0, 0, 0, 0.12); }
}
.nn-hero-diaporama__vh { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.nn-hero-diaporama__piste { position: relative; display: grid; overflow: hidden; touch-action: pan-y; }
.nn-hero-diaporama--h-petite { min-height: 380px; }
.nn-hero-diaporama--h-moyenne { min-height: clamp(440px, 62vh, 620px); }
.nn-hero-diaporama--h-grande { min-height: clamp(520px, 80vh, 780px); }
.nn-hero-diaporama--h-ecran { min-height: 100vh; min-height: 100svh; }
.nn-hero-diaporama__diapo { position: relative; grid-area: 1 / 1; display: flex; align-items: center; isolation: isolate; opacity: 0; visibility: hidden; transition: opacity 0.8s ease, visibility 0s 0.8s; }
.nn-hero-diaporama__diapo--active { opacity: 1; visibility: visible; transition: opacity 0.8s ease, visibility 0s; }
.nn-hero-diaporama__media { position: absolute; inset: 0; z-index: -2; }
.nn-hero-diaporama__img { display: block; width: 100%; height: 100%; object-fit: cover; transform: scale(1.06); transition: transform 7s ease-out; }
.nn-hero-diaporama__diapo--active .nn-hero-diaporama__img { transform: scale(1); }
.nn-hero-diaporama__voile { position: absolute; inset: 0; z-index: -1; background: linear-gradient(90deg, var(--nn-fond), transparent 85%); opacity: var(--nn-voile); }
.nn-hero-diaporama__voile::after { content: ""; position: absolute; inset: 0; background: var(--nn-fond); opacity: 0.45; }
.nn-hero-diaporama__contenu { width: 100%; max-width: 1240px; margin: 0 auto; padding: clamp(40px, 8vw, 96px) 16px clamp(96px, 12vw, 120px); transform: translateY(16px); opacity: 0; transition: transform 0.8s 0.2s ease, opacity 0.8s 0.2s ease; }
.nn-hero-diaporama__contenu > * { max-width: 620px; }
.nn-hero-diaporama__diapo--active .nn-hero-diaporama__contenu { transform: none; opacity: 1; }
@media (min-width: 750px) { .nn-hero-diaporama__contenu { padding-inline: 32px; } }
.nn-hero-diaporama__commandes { position: absolute; left: 0; right: 0; bottom: 20px; display: flex; align-items: center; justify-content: center; gap: 8px; padding: 0 16px; }
.nn-hero-diaporama__fleche {
display: inline-grid;
place-items: center;
flex: none;
width: 44px;
height: 44px;
border: 1px solid color-mix(in srgb, var(--nn-texte) 35%, transparent);
border-radius: 50%;
background: color-mix(in srgb, var(--nn-fond) 55%, transparent);
color: var(--nn-texte);
cursor: pointer;
-webkit-backdrop-filter: blur(6px);
backdrop-filter: blur(6px);
transition: background-color 0.2s ease;
}
.nn-hero-diaporama__fleche[hidden] { display: none; }
.nn-hero-diaporama__fleche svg { width: 20px; height: 20px; }
@media (hover: hover) { .nn-hero-diaporama__fleche:hover { background: color-mix(in srgb, var(--nn-fond) 80%, transparent); } }
.nn-hero-diaporama__points { display: flex; gap: 2px; }
.nn-hero-diaporama__point { position: relative; width: 28px; height: 44px; padding: 0; border: 0; background: none; cursor: pointer; }
.nn-hero-diaporama__point::before { content: ""; position: absolute; left: 4px; right: 4px; top: 50%; height: 4px; margin-top: -2px; border-radius: 4px; background: var(--nn-texte); opacity: 0.4; transition: opacity 0.3s ease, transform 0.3s ease; }
.nn-hero-diaporama__point[aria-current="true"]::before { opacity: 1; background: var(--nn-accent); }
.nn-hero-diaporama__ico-lecture { display: none; }
.nn-hero-diaporama__lecture--arret .nn-hero-diaporama__ico-pause { display: none; }
.nn-hero-diaporama__lecture--arret .nn-hero-diaporama__ico-lecture { display: block; }
@media (prefers-reduced-motion: reduce) {
.nn-hero-diaporama, .nn-hero-diaporama *, .nn-hero-diaporama *::before, .nn-hero-diaporama *::after {
animation: none !important;
transition: none !important;
}
}
{% endstylesheet %}
{% javascript %}
if (!customElements.get("nn-hero-diaporama")) {
// Diaporama : fondu, flèches, points, glissement, clavier ; pause au survol, au focus, onglet caché ou bouton pause ;
// pas de défilement automatique si le visiteur réduit les animations
customElements.define("nn-hero-diaporama", class extends HTMLElement {
connectedCallback() {
if (this.dataset.nnPret) return;
this.dataset.nnPret = "1";
var moi = this;
this.diapos = Array.prototype.slice.call(this.querySelectorAll("[data-nn-diapo]"));
this.points = Array.prototype.slice.call(this.querySelectorAll("[data-nn-point]"));
this.index = 0;
if (this.diapos.length < 2) return;
var reduit = window.matchMedia && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
this.delai = Math.max(3, Number(this.dataset.delai) || 6) * 1000;
this.auto = this.dataset.auto === "true" && !reduit;
this.arret = false;
this.survol = false;
this.bouton = this.querySelector("[data-nn-lecture]");
var prec = this.querySelector("[data-nn-prec]");
var suiv = this.querySelector("[data-nn-suiv]");
if (prec) prec.addEventListener("click", function () { moi.aller(moi.index - 1); });
if (suiv) suiv.addEventListener("click", function () { moi.aller(moi.index + 1); });
this.points.forEach(function (pt) {
pt.addEventListener("click", function () { moi.aller(Number(pt.getAttribute("data-nn-point"))); });
});
if (this.auto && this.bouton) {
this.bouton.hidden = false;
this.bouton.addEventListener("click", function () {
moi.arret = !moi.arret;
moi.bouton.classList.toggle("nn-hero-diaporama__lecture--arret", moi.arret);
moi.bouton.setAttribute("aria-label", moi.arret ? "Relancer le défilement" : "Mettre le défilement en pause");
moi.relancer();
});
}
this.addEventListener("mouseenter", function () { moi.survol = true; moi.relancer(); });
this.addEventListener("mouseleave", function () { moi.survol = false; moi.relancer(); });
this.addEventListener("focusin", function () { moi.focus = true; moi.relancer(); });
this.addEventListener("focusout", function (e) {
if (!moi.contains(e.relatedTarget)) { moi.focus = false; moi.relancer(); }
});
this.addEventListener("keydown", function (e) {
if (e.key === "ArrowLeft") moi.aller(moi.index - 1);
else if (e.key === "ArrowRight") moi.aller(moi.index + 1);
});
var piste = this.querySelector("[data-nn-piste]");
var x0 = null;
if (piste) {
piste.addEventListener("pointerdown", function (e) { x0 = e.clientX; });
piste.addEventListener("pointerup", function (e) {
if (x0 === null) return;
var dx = e.clientX - x0;
x0 = null;
if (Math.abs(dx) > 40) moi.aller(moi.index + (dx < 0 ? 1 : -1));
});
}
this._visibilite = function () { moi.relancer(); };
document.addEventListener("visibilitychange", this._visibilite);
// Éditeur de thème : la diapositive sélectionnée s'affiche et le défilement s'arrête
this.addEventListener("shopify:block:select", function (e) {
var i = moi.diapos.indexOf(e.target);
if (i >= 0) { moi.arret = true; moi.aller(i); }
});
this.relancer();
}
disconnectedCallback() {
clearInterval(this.minuterie);
if (this._visibilite) document.removeEventListener("visibilitychange", this._visibilite);
}
aller(i) {
var n = this.diapos.length;
this.index = ((i % n) + n) % n;
var actif = this.index;
this.diapos.forEach(function (d, k) {
var oui = k === actif;
d.classList.toggle("nn-hero-diaporama__diapo--active", oui);
if (oui) { d.removeAttribute("aria-hidden"); d.removeAttribute("inert"); }
else { d.setAttribute("aria-hidden", "true"); d.setAttribute("inert", ""); }
});
this.points.forEach(function (pt, k) {
if (k === actif) pt.setAttribute("aria-current", "true");
else pt.removeAttribute("aria-current");
});
this.relancer();
}
relancer() {
clearInterval(this.minuterie);
if (!this.auto || this.arret || this.survol || this.focus || document.hidden) return;
var moi = this;
this.minuterie = setInterval(function () { moi.aller(moi.index + 1); }, this.delai);
}
});
}
{% endjavascript %}
Licence NAHNAH AI : utilisation libre dans tes boutiques (y compris commerciales), modification permise, revente de l’élément seul interdite.
Installer dans ma boutique
En un clic, la section est ajoutée à un thème de ta boutique Shopify connectée (un thème non publié par défaut).
Chargement de tes boutiques…
Installer dans Shopify
- Dans Shopify : Boutique en ligne → Thèmes → bouton « … » du thème → Modifier le code.
- Dossier « sections » → « Ajouter une section » (ou « Nouveau fichier ») → nomme-la « nahnah-hero-diaporama ».
- Efface le contenu proposé, colle le code de l’onglet Liquid (fichier complet), puis Enregistrer.
- Ouvre Personnaliser → Ajouter une section → choisis-la, règle les textes et les couleurs, puis Enregistrer.
Installer via le MCP
Depuis Claude, Claude Code ou ChatGPT connecté à NAHNAH AI, demande : « Donne-moi le code de l’élément hero-diaporama de la bibliothèque NAHNAH AI et les étapes pour l’installer ». L’assistant récupère le code et les étapes (outil obtenir_code_element), gratuitement.
Boutique connectée à NAHNAH AI : l’assistant peut aussi l’installer directement (outil installer_element).
Connecter le MCP