Aller au contenu

🌅 HérosGratuit · 0 NahnahPar NAHNAH AI

Héros image parallaxe

Image de fond qui glisse plus lentement que la page au défilement (parallaxe légère et réglable), coupée si le visiteur réduit les animations.

Aperçu en direct

Données de démonstration (produits, menus, textes d’exemple) : dans ta boutique, ce sont les tiennes.

Photos : Unsplash / Pexels (exemples de l’aperçu, jamais inclus dans le code).

Code à copier

Fichier complet sections/nahnah-hero-parallaxe.liquid (Liquid, CSS et JS inclus).

{%- comment -%} NAHNAH AI · Héros image parallaxe (bibliothèque Sections & effets) {%- endcomment -%}
<nn-hero-parallaxe class="nn-hero-parallaxe" 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 }}; --nn-debord: {{ section.settings.force }}%;" data-force="{{ section.settings.force }}">
  <div class="nn-hero-parallaxe__cadre nn-hero-parallaxe--h-{{ section.settings.hauteur }} nn-hero-parallaxe--{{ section.settings.alignement }}">
    <div class="nn-hero-parallaxe__media" data-nn-parallaxe>
      {%- if section.settings.image != blank -%}
        {{ section.settings.image | image_url: width: 1600 | image_tag: class: 'nn-hero-parallaxe__img', sizes: '100vw', widths: '600, 900, 1200, 1600', loading: 'eager' }}
      {%- else -%}
        {{ 'lifestyle-1' | placeholder_svg_tag: 'nn-hero-parallaxe__img nn-hero-parallaxe__img--vide' }}
      {%- endif -%}
    </div>
    <div class="nn-hero-parallaxe__voile" aria-hidden="true"></div>
    <div class="nn-hero-parallaxe__contenu">
    {%- if section.settings.surtitre != blank -%}
      <p class="nn-hero-parallaxe__surtitre">{{ section.settings.surtitre | escape }}</p>
    {%- endif -%}
    {%- if section.settings.titre != blank -%}
      <h2 class="nn-hero-parallaxe__titre">{{ section.settings.titre }}</h2>
    {%- endif -%}
    {%- if section.settings.texte != blank -%}
      <div class="nn-hero-parallaxe__texte">{{ section.settings.texte }}</div>
    {%- endif -%}
    {%- if section.settings.bouton_texte != blank or section.settings.bouton2_texte != blank -%}
      <div class="nn-hero-parallaxe__boutons">
        {%- if section.settings.bouton_texte != blank -%}
          <a class="nn-hero-parallaxe__bouton" href="{{ section.settings.bouton_lien | default: routes.all_products_collection_url }}">{{ section.settings.bouton_texte | escape }}</a>
        {%- endif -%}
        {%- if section.settings.bouton2_texte != blank -%}
          <a class="nn-hero-parallaxe__bouton nn-hero-parallaxe__bouton--second" href="{{ section.settings.bouton2_lien | default: routes.collections_url }}">{{ section.settings.bouton2_texte | escape }}</a>
        {%- endif -%}
      </div>
    {%- endif -%}
    </div>
  </div>
</nn-hero-parallaxe>

{% schema %}
{
  "name": "Héros image parallaxe",
  "tag": "section",
  "class": "nn-section-hero-parallaxe",
  "settings": [
    {
      "type": "image_picker",
      "id": "image",
      "label": "Image de fond"
    },
    {
      "type": "range",
      "id": "force",
      "label": "Intensité de la parallaxe",
      "min": 0,
      "max": 30,
      "step": 2,
      "default": 14,
      "unit": "%"
    },
    {
      "type": "range",
      "id": "voile",
      "label": "Opacité du voile",
      "min": 0,
      "max": 90,
      "step": 5,
      "default": 45,
      "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": "select",
      "id": "alignement",
      "label": "Alignement du texte",
      "options": [
        {
          "value": "gauche",
          "label": "Gauche"
        },
        {
          "value": "centre",
          "label": "Centre"
        }
      ],
      "default": "centre"
    },
    {
      "type": "text",
      "id": "surtitre",
      "label": "Sur-titre (vide : masqué)",
      "default": "Collection automne"
    },
    {
      "type": "inline_richtext",
      "id": "titre",
      "label": "Titre",
      "default": "Prends le temps de bien choisir"
    },
    {
      "type": "richtext",
      "id": "texte",
      "label": "Texte",
      "default": "<p>Des matières douces, des couleurs profondes et des pièces qui traversent les saisons.</p>"
    },
    {
      "type": "header",
      "content": "Boutons"
    },
    {
      "type": "text",
      "id": "bouton_texte",
      "label": "Texte du bouton (vide : masqué)",
      "default": "Explorer la collection"
    },
    {
      "type": "url",
      "id": "bouton_lien",
      "label": "Lien du bouton (vide : tous les produits)"
    },
    {
      "type": "text",
      "id": "bouton2_texte",
      "label": "Texte du bouton secondaire (vide : masqué)",
      "default": "Notre histoire"
    },
    {
      "type": "url",
      "id": "bouton2_lien",
      "label": "Lien du bouton secondaire (vide : collections)"
    },
    {
      "type": "header",
      "content": "Couleurs"
    },
    {
      "type": "color",
      "id": "couleur_fond",
      "label": "Fond",
      "default": "#14110F"
    },
    {
      "type": "color",
      "id": "couleur_texte",
      "label": "Texte",
      "default": "#FFFFFF"
    },
    {
      "type": "color",
      "id": "couleur_accent",
      "label": "Accent",
      "default": "#E8B86D"
    },
    {
      "type": "color",
      "id": "couleur_bouton",
      "label": "Bouton",
      "default": "#E8B86D"
    },
    {
      "type": "color",
      "id": "couleur_texte_bouton",
      "label": "Texte du bouton",
      "default": "#14110F"
    },
    {
      "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
    }
  ],
  "presets": [
    {
      "name": "Héros image parallaxe"
    }
  ]
}
{% endschema %}

{% stylesheet %}
.nn-hero-parallaxe {
  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-parallaxe *, .nn-hero-parallaxe *::before, .nn-hero-parallaxe *::after { box-sizing: border-box; }
.nn-hero-parallaxe :where(a, button):focus-visible { outline: 3px solid var(--nn-accent); outline-offset: 3px; }
.nn-hero-parallaxe__surtitre { margin: 0 0 12px; font-size: 13px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--nn-accent); }
.nn-hero-parallaxe__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-parallaxe__texte { margin: 0 0 28px; font-size: clamp(16px, 1.6vw, 19px); line-height: 1.6; opacity: 0.88; max-width: 560px; }
.nn-hero-parallaxe__texte p { margin: 0 0 0.6em; }
.nn-hero-parallaxe__boutons { display: flex; flex-wrap: wrap; gap: 12px; }
.nn-hero-parallaxe__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-parallaxe__bouton--second { background: transparent; color: inherit; box-shadow: inset 0 0 0 2px currentColor; }
@media (hover: hover) {
  .nn-hero-parallaxe__bouton:hover { transform: translateY(-2px); box-shadow: 0 12px 26px color-mix(in srgb, var(--nn-bouton) 35%, transparent); }
  .nn-hero-parallaxe__bouton--second:hover { box-shadow: inset 0 0 0 2px currentColor, 0 12px 26px rgba(0, 0, 0, 0.12); }
}
.nn-hero-parallaxe__vh { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.nn-hero-parallaxe__cadre { position: relative; display: flex; align-items: center; overflow: hidden; isolation: isolate; }
.nn-hero-parallaxe--h-petite { min-height: 380px; }
.nn-hero-parallaxe--h-moyenne { min-height: clamp(440px, 62vh, 620px); }
.nn-hero-parallaxe--h-grande { min-height: clamp(520px, 80vh, 780px); }
.nn-hero-parallaxe--h-ecran { min-height: 100vh; min-height: 100svh; }
.nn-hero-parallaxe__media { position: absolute; left: 0; right: 0; top: calc(-1 * var(--nn-debord)); bottom: calc(-1 * var(--nn-debord)); z-index: -2; will-change: transform; }
.nn-hero-parallaxe__img { display: block; width: 100%; height: 100%; object-fit: cover; }
.nn-hero-parallaxe__voile { position: absolute; inset: 0; z-index: -1; background: var(--nn-fond); opacity: var(--nn-voile); }
.nn-hero-parallaxe__contenu { width: 100%; max-width: 1240px; margin: 0 auto; padding: clamp(56px, 10vw, 120px) 16px; }
@media (min-width: 750px) { .nn-hero-parallaxe__contenu { padding-inline: 32px; } }
.nn-hero-parallaxe--gauche .nn-hero-parallaxe__contenu > * { max-width: 620px; }
.nn-hero-parallaxe--centre .nn-hero-parallaxe__contenu { text-align: center; }
.nn-hero-parallaxe--centre .nn-hero-parallaxe__contenu > * { max-width: 760px; margin-inline: auto; }
.nn-hero-parallaxe--centre .nn-hero-parallaxe__boutons { justify-content: center; }
.nn-hero-parallaxe__titre { font-size: clamp(36px, 7vw, 82px); text-shadow: 0 2px 30px rgba(0, 0, 0, 0.3); }
.nn-hero-parallaxe__surtitre { display: inline-block; padding: 6px 14px; border: 1px solid currentColor; border-radius: 999px; }
@media (prefers-reduced-motion: reduce) {
  .nn-hero-parallaxe, .nn-hero-parallaxe *, .nn-hero-parallaxe *::before, .nn-hero-parallaxe *::after {
    animation: none !important;
    transition: none !important;
  }
}
{% endstylesheet %}

{% javascript %}
if (!customElements.get("nn-hero-parallaxe")) {
  // Parallaxe légère : l'image (agrandie de « force » % en haut et en bas) glisse de -force à +force pendant que la
  // section traverse l'écran ; calcul limité à une image par rafraîchissement, seulement si la section est visible
  customElements.define("nn-hero-parallaxe", class extends HTMLElement {
    connectedCallback() {
      if (this.dataset.nnPret) return;
      this.dataset.nnPret = "1";
      var media = this.querySelector("[data-nn-parallaxe]");
      var force = Math.min(30, Math.max(0, Number(this.dataset.force) || 0)) / 100;
      if (!media || !force) return;
      if (window.matchMedia && window.matchMedia("(prefers-reduced-motion: reduce)").matches) return;
      var moi = this;
      var attente = false;
      var visible = true;
      var maj = function () {
        attente = false;
        var r = moi.getBoundingClientRect();
        var h = window.innerHeight || 1;
        var k = (r.top + r.height / 2 - h / 2) / (h / 2 + r.height / 2);
        k = Math.max(-1, Math.min(1, k));
        media.style.transform = "translate3d(0, " + (-k * force * r.height).toFixed(1) + "px, 0)";
      };
      this._defile = function () {
        if (!visible || attente) return;
        attente = true;
        requestAnimationFrame(maj);
      };
      if ("IntersectionObserver" in window) {
        this._obs = new IntersectionObserver(function (e) {
          visible = e[0].isIntersecting;
          if (visible) moi._defile();
        });
        this._obs.observe(this);
      }
      window.addEventListener("scroll", this._defile, { passive: true });
      window.addEventListener("resize", this._defile);
      maj();
    }
    disconnectedCallback() {
      if (this._obs) this._obs.disconnect();
      if (this._defile) {
        window.removeEventListener("scroll", this._defile);
        window.removeEventListener("resize", this._defile);
      }
    }
  });
}
{% endjavascript %}
Télécharger le fichier .liquid

Licence NAHNAH AI : utilisation libre dans tes boutiques (y compris commerciales), modification permise, revente de l’élément seul interdite.

Prompt à copier

À coller dans Claude ou ChatGPT avec le fichier téléchargé (ou le code copié) : l’assistant t’aide à l’installer et à l’adapter à ta marque.

Tu es un expert des thèmes Shopify Online Store 2.0. Aide-moi à installer puis à adapter à ma marque cet élément gratuit de la bibliothèque NAHNAH AI.

Élément : « Héros image parallaxe » (Héros)
Description : Image de fond qui glisse plus lentement que la page au défilement (parallaxe légère et réglable), coupée si le visiteur réduit les animations.
Page de l’élément (aperçu en direct) : https://ai.nahnah.shop/bibliotheque-shopify/hero-parallaxe
Fichier : nahnah-hero-parallaxe.liquid (bouton « Télécharger » de la page) ou le code copié avec le bouton « Copier » : je te le joins ou je le colle après ce message.
Emplacement dans le thème : sections/nahnah-hero-parallaxe.liquid (Liquid, puis {% stylesheet %} et {% javascript %}, dans ce seul fichier).

Étapes d’installation :
1. Dans Shopify : Boutique en ligne → Thèmes → bouton « … » du thème → Modifier le code.
2. Dossier « sections » → « Ajouter une section » (ou « Nouveau fichier ») → nomme-la « nahnah-hero-parallaxe ».
3. Efface le contenu proposé, colle le code de l’onglet Liquid (fichier complet), puis Enregistrer.
4. Ouvre Personnaliser → Ajouter une section → choisis-la, règle les textes et les couleurs, puis Enregistrer.

Ce que j’attends de toi :
- Guide-moi pas à pas dans Shopify : Boutique en ligne → Thèmes → « … » → Modifier le code → dossier sections → Ajouter une section, puis Personnaliser → Ajouter une section.
- Propose-moi d’adapter les couleurs, les textes et les liens à ma marque : demande d’abord mes couleurs (codes hexadécimaux), mon ton et mes liens.
- Garde le bloc {% schema %} et tous ses réglages (identifiants, types, presets) : je dois pouvoir tout régler ensuite dans l’éditeur de thème.
- Rends-moi le fichier complet modifié, prêt à coller, sans faux avis, fausse urgence ni chiffre inventé.

Si tu as le connecteur NAHNAH AI (MCP), récupère directement le code exact avec l’outil obtenir_code_element (id : hero-parallaxe).

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

  1. Dans Shopify : Boutique en ligne → Thèmes → bouton « … » du thème → Modifier le code.
  2. Dossier « sections » → « Ajouter une section » (ou « Nouveau fichier ») → nomme-la « nahnah-hero-parallaxe ».
  3. Efface le contenu proposé, colle le code de l’onglet Liquid (fichier complet), puis Enregistrer.
  4. 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-parallaxe 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

Dans la même catégorie