1 звезда на GitHub = 1 новый компонент.

Доставка еды и рестораны

Food Hero Plate

Главный экран в стиле поп-стикеров: большая тарелка меняет блюда в такт заголовку, ингредиенты вращаются по орбите, проезжает курьер и тарелка крутится при скролле; поиск адреса и пауза анимации.

foodherodeliveryanimationscroll-drivenmarquee
Живое превью

Abierto ahora · entrega en ~24 min

Hambre de algo rico

Cocinamos al momento en Lavapiés y te lo llevamos caliente. Sin comisiones escondidas, con seguimiento en directo hasta tu puerta.

Использование

Скопируйте и вставьте этот код на вашу страницу Astro:

astro
---
import { FoodHeroPlate } from 'astro-component-kit/sections';
---

<FoodHeroPlate menuHref="/carta" trackHref="/pedido" words={['smash burgers', 'ramen', 'tacos']} />
--- import { FoodHeroPlate } from 'astro-component-kit/sections'; --- <FoodHeroPlate menuHref="/carta" trackHref="/pedido" words={['smash burgers', 'ramen', 'tacos']} />

Примеры в контексте

Реальный код из набора: как этот элемент используется в шаблонах, секциях и других компонентах.

Шаблон BiteFlow · Доставка еды & Kitchen OS FoodHomePage.astro
astro
<FoodHeroPlate menuHref={routes.menu} trackHref={routes.tracking} dishes={heroDishes} minutes={data.brand.avgMinutes} freeFrom={data.brand.freeDeliveryFrom} />
<FoodHeroPlate menuHref={routes.menu} trackHref={routes.tracking} dishes={heroDishes} minutes={data.brand.avgMinutes} freeFrom={data.brand.freeDeliveryFrom} />

Используется в

Хорошо сочетается с

Ручная установка

Если вы не используете пакет npm, создайте файл и вставьте следующий код: src/components/sections/FoodHeroPlate.astro:

astro
---
/**
 * FoodHeroPlate — Pop "sticker" hero for a food delivery brand. A giant plate swaps dishes in
 * sync with the headline word, ingredient stickers orbit it, a rider zips along a dashed road and
 * the plate spins as the hero scrolls away (scroll-driven animation). Includes an address field
 * that sends the visitor to the menu and a marquee of dishes.
 *
 * @param {string} menuHref - Menu page; the address form submits here with ?dir=.
 * @param {string} trackHref - Order tracking page (secondary link).
 * @param {Array<{name: string, art: FoodArt, price: number}>} dishes - Dishes for the plate carousel and marquee.
 * @param {string[]} words - Rotating words after "Hambre de".
 * @param {number} minutes - Average delivery time shown in the badge.
 * @param {number} freeFrom - Free delivery threshold (EUR).
 * @param {string} variant - 'centered' (monumental poster stage) | 'split' (plate on the right). Default 'centered'.
 * @param {string} size - 'md' | 'lg' headline size. Default 'lg'.
 * @param {string} class - Extra class for the root.
 *
 * Accessibility: the headline has a static accessible name ("Hambre de algo rico"); the rotating
 * word and every decorative layer are aria-hidden. A visible pause button stops all motion
 * (WCAG 2.2.2) and prefers-reduced-motion disables it from the start. The marquee copy is hidden
 * from screen readers; the address input has a visible label.
 */
import type { HTMLAttributes } from 'astro/types';
import '../templates/food-delivery/food-theme.css';
import { foodArt } from '../templates/food-delivery/food-art';
import type { FoodArt } from '../templates/food-delivery/data';

interface Dish { name: string; art: FoodArt; price: number }

interface OwnProps {
  menuHref?: string;
  trackHref?: string;
  dishes?: Dish[];
  words?: string[];
  minutes?: number;
  freeFrom?: number;
  variant?: 'centered' | 'split';
  size?: 'md' | 'lg';
}

type Props = OwnProps & Omit<HTMLAttributes<'section'>, keyof OwnProps | 'class'> & { class?: string };

const {
  menuHref = '#carta',
  trackHref = '#pedido',
  dishes = [
    { name: 'Doble Smash', art: 'burger', price: 12.9 },
    { name: 'Tonkotsu 18 h', art: 'ramen', price: 14.5 },
    { name: 'Tacos al pastor', art: 'taco', price: 10.9 },
    { name: 'Diavola', art: 'pizza', price: 13.9 },
    { name: 'Poke de salmón', art: 'poke', price: 13.5 },
  ],
  words = ['smash burgers', 'ramen', 'tacos', 'pizza', 'poke'],
  minutes = 24,
  freeFrom = 25,
  variant = 'centered',
  size = 'lg',
  class: classAttr,
  ...rest
} = Astro.props;

const plates = dishes.slice(0, Math.max(1, words.length));
const eur = (n: number) => n.toLocaleString('es-ES', { minimumFractionDigits: 2, maximumFractionDigits: 2 });
const marquee = [...dishes, ...dishes];
const orbit: FoodArt[] = ['drink', 'dessert', 'salad', 'taco'];
---

<section
  class:list={['bf-ui', 'bf-hero', `bf-hero--${variant}`, `bf-hero--${size}`, classAttr]}
  aria-labelledby="bf-hero-title"
  data-bf-hero
  {...rest}
>
  <div class="bf-hero__grid">
    <div class="bf-hero__copy">
      <p class="bf-hero__kicker">
        <span class="bf-hero__live" aria-hidden="true"></span>
        Abierto ahora · entrega en ~{minutes} min
      </p>
      <h1 id="bf-hero-title" class="bf-hero__title">
        <span class="bf-hero__line">Hambre de</span>
        <span class="bf-hero__swap" aria-hidden="true">
          {words.map((w, i) => <span class:list={['bf-hero__word', { 'is-on': i === 0 }]}>{w}</span>)}
        </span>
        <span class="bf-sr">algo rico</span>
      </h1>
      <p class="bf-hero__lead">
        Cocinamos al momento en Lavapiés y te lo llevamos caliente. Sin comisiones escondidas,
        con seguimiento en directo hasta tu puerta.
      </p>

      <form class="bf-hero__form" action={menuHref} method="get" role="search">
        <label for="bf-hero-dir" class="bf-hero__label">¿Dónde te lo llevamos?</label>
        <div class="bf-hero__field">
          <svg class="bf-hero__pin" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" aria-hidden="true"><path d="M12 21s-7-6.2-7-12a7 7 0 0 1 14 0c0 5.8-7 12-7 12z" /><circle cx="12" cy="9" r="2.5" /></svg>
          <input id="bf-hero-dir" name="dir" type="text" autocomplete="street-address" placeholder="Calle, número y piso" />
          <button type="submit" class="bf-hero__go">Ver carta</button>
        </div>
      </form>

      <ul class="bf-hero__facts" role="list">
        <li><strong>{minutes} min</strong> de media</li>
        <li><strong>Envío gratis</strong> desde {freeFrom} €</li>
        <li><a href={trackHref}>Seguir mi pedido</a></li>
      </ul>
    </div>

    <div class="bf-hero__stage" aria-hidden="true">
      <div class="bf-hero__sun"></div>
      <div class="bf-hero__plate">
        {plates.map((d, i) => (
          <figure class:list={['bf-hero__dish', { 'is-on': i === 0 }]}>
            <svg class="bf-art" viewBox="0 0 120 120" set:html={foodArt(d.art)} />
            <figcaption class="bf-hero__tag">
              <span>{d.name}</span>
              <b>{eur(d.price)} €</b>
            </figcaption>
          </figure>
        ))}
      </div>
      <div class="bf-hero__orbit">
        {orbit.map((a, i) => (
          <span class={`bf-hero__sticker bf-hero__sticker--${i}`}>
            <svg class="bf-art" viewBox="0 0 120 120" set:html={foodArt(a)} />
          </span>
        ))}
      </div>
      <p class="bf-hero__note">¡Envío gratis<br />desde {freeFrom} €!</p>
      <div class="bf-hero__road">
        <span class="bf-hero__rider">
          <svg width="64" height="44" viewBox="0 0 64 44" fill="none" stroke-linecap="round" stroke-linejoin="round">
            <circle cx="14" cy="34" r="8" class="r-wheel" />
            <circle cx="50" cy="34" r="8" class="r-wheel" />
            <path d="M14 34l10-16h14l6 16M24 18l-4-6h-6" class="r-frame" />
            <rect x="30" y="4" width="18" height="14" rx="3" class="r-box" />
            <circle cx="28" cy="8" r="4" class="r-head" />
          </svg>
        </span>
      </div>
    </div>
  </div>

  <button type="button" class="bf-hero__pause" aria-pressed="false" data-bf-pause>
    <svg width="16" height="16" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true" class="bf-hero__pause-i"><rect x="6" y="5" width="4" height="14" rx="1" /><rect x="14" y="5" width="4" height="14" rx="1" /></svg>
    <svg width="16" height="16" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true" class="bf-hero__play-i"><path d="M8 5v14l11-7z" /></svg>
    <span data-bf-pause-label>Pausar animación</span>
  </button>

  <div class="bf-hero__marquee" aria-hidden="true">
    <div class="bf-hero__track">
      {marquee.map((d) => (
        <span class="bf-hero__chip">
          <svg class="bf-art" viewBox="0 0 120 120" width="34" height="34" set:html={foodArt(d.art)} />
          {d.name}
          <b>{eur(d.price)} €</b>
        </span>
      ))}
    </div>
  </div>
</section>

<script>
  function initFoodHero() {
    document.querySelectorAll<HTMLElement>('[data-bf-hero]').forEach((root) => {
      if (root.dataset.bound) return;
      root.dataset.bound = 'true';
      const words = [...root.querySelectorAll<HTMLElement>('.bf-hero__word')];
      const dishes = [...root.querySelectorAll<HTMLElement>('.bf-hero__dish')];
      const btn = root.querySelector<HTMLButtonElement>('[data-bf-pause]');
      const label = root.querySelector<HTMLElement>('[data-bf-pause-label]');
      const reduce = window.matchMedia('(prefers-reduced-motion: reduce)').matches;
      let i = 0;
      let timer: number | undefined;

      const show = (n: number) => {
        words.forEach((w, k) => w.classList.toggle('is-on', k === n));
        dishes.forEach((d, k) => d.classList.toggle('is-on', k === n % dishes.length));
      };
      const play = () => {
        stop();
        timer = window.setInterval(() => {
          i = (i + 1) % words.length;
          show(i);
        }, 2600);
      };
      const stop = () => window.clearInterval(timer);
      const setPaused = (paused: boolean) => {
        root.classList.toggle('is-paused', paused);
        btn?.setAttribute('aria-pressed', String(paused));
        if (label) label.textContent = paused ? 'Reanudar animación' : 'Pausar animación';
        paused ? stop() : play();
      };

      btn?.addEventListener('click', () => setPaused(btn.getAttribute('aria-pressed') !== 'true'));
      document.addEventListener('visibilitychange', () => {
        if (root.classList.contains('is-paused')) return;
        document.hidden ? stop() : play();
      });
      setPaused(reduce);
    });
  }
  initFoodHero();
  document.addEventListener('astro:page-load', initFoodHero);
</script>

<style>
  .bf-hero {
    position: relative;
    overflow: hidden;
    padding: clamp(2rem, 6vw, 5rem) var(--sp-4, 1rem) 0;
    background:
      radial-gradient(circle at 85% 10%, color-mix(in srgb, var(--bf-mustard) 40%, transparent) 0, transparent 40%),
      var(--bf-bg);
    color: var(--bf-ink);
    font-family: var(--bf-font-body);
  }

  .bf-hero__grid {
    max-width: 1240px;
    margin: 0 auto;
    display: grid;
    gap: clamp(2rem, 5vw, 4rem);
    align-items: center;
  }

  @media (min-width: 900px) {
    .bf-hero--split .bf-hero__grid {
      grid-template-columns: 1.05fr 1fr;
    }
  }

  .bf-hero--centered .bf-hero__grid {
    gap: clamp(1.5rem, 4vw, 2.5rem);
    justify-items: center;
  }

  .bf-hero--centered .bf-hero__copy {
    text-align: center;
    margin: 0 auto;
    max-width: 820px;
  }

  .bf-hero--centered .bf-hero__swap {
    justify-items: center;
  }

  .bf-hero--centered .bf-hero__stage {
    width: min(100%, 400px);
    margin-top: -0.5rem;
  }

  .bf-hero__kicker {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2, 0.5rem);
    margin: 0 0 var(--sp-5, 1.25rem);
    padding: 0.4rem 0.9rem;
    border: 2px solid var(--bf-outline);
    border-radius: 999px;
    background: var(--bf-paper);
    box-shadow: 3px 3px 0 var(--bf-outline);
    font-weight: 700;
    font-size: 0.9rem;
    transform: rotate(-2deg);
  }

  .bf-hero__live {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--bf-mint);
    animation: bf-hero-pulse 1.6s ease-in-out infinite;
  }

  .bf-hero__title {
    margin: 0;
    font-family: var(--bf-font-display);
    font-weight: 800;
    line-height: 0.95;
    letter-spacing: -0.03em;
    font-size: clamp(2.6rem, 9vw, 4.2rem);
  }

  .bf-hero--lg .bf-hero__title {
    font-size: clamp(2.8rem, 10vw, 5.6rem);
  }

  .bf-hero__line {
    display: block;
  }

  .bf-hero__swap {
    position: relative;
    display: grid;
    min-height: 1.05em;
  }

  .bf-hero__word {
    grid-area: 1 / 1;
    color: var(--bf-tomato);
    opacity: 0;
    transform: translateY(0.4em) rotate(4deg);
    transition: opacity 0.35s ease, transform 0.45s var(--bf-ease-pop);
    white-space: nowrap;
  }

  .bf-hero__word.is-on {
    opacity: 1;
    transform: none;
  }

  .bf-hero__lead {
    margin: var(--sp-5, 1.25rem) 0 0;
    max-width: 34rem;
    font-size: 1.1rem;
    line-height: 1.6;
    color: var(--bf-ink-2);
  }

  .bf-hero--centered .bf-hero__lead {
    margin-inline: auto;
  }

  .bf-hero__form {
    margin-top: var(--sp-6, 1.5rem);
    max-width: 34rem;
  }

  .bf-hero--centered .bf-hero__form {
    margin-inline: auto;
  }

  .bf-hero__label {
    display: block;
    margin-bottom: var(--sp-2, 0.5rem);
    font-weight: 700;
  }

  .bf-hero__field {
    display: flex;
    align-items: center;
    gap: var(--sp-2, 0.5rem);
    padding: 6px 6px 6px 14px;
    border: 3px solid var(--bf-outline);
    border-radius: 999px;
    background: var(--bf-paper);
    box-shadow: var(--bf-shadow);
  }

  .bf-hero__field:focus-within {
    outline: 3px solid var(--bf-sky);
    outline-offset: 3px;
  }

  .bf-hero__pin {
    flex: none;
    color: var(--bf-tomato);
  }

  .bf-hero__field input {
    flex: 1;
    min-width: 0;
    min-height: 44px;
    border: 0;
    background: transparent;
    color: var(--bf-ink);
    font: inherit;
    font-size: 1rem;
  }

  .bf-hero__field input:focus {
    outline: none;
  }

  .bf-hero__field input::placeholder {
    color: var(--bf-ink-3);
  }

  .bf-hero__go {
    flex: none;
    min-height: 48px;
    padding: 0 1.3rem;
    border: 2px solid var(--bf-outline);
    border-radius: 999px;
    background: var(--bf-tomato);
    color: var(--bf-on-tomato);
    font: inherit;
    font-weight: 800;
    cursor: pointer;
    transition: transform 0.2s var(--bf-ease-pop), background 0.2s ease;
  }

  .bf-hero__go:hover {
    background: var(--bf-tomato-hover);
    transform: translateY(-2px) rotate(-2deg);
  }

  .bf-hero__go:focus-visible,
  .bf-hero__facts a:focus-visible,
  .bf-hero__pause:focus-visible {
    outline: 3px solid var(--bf-sky);
    outline-offset: 3px;
  }

  .bf-hero__facts {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-2, 0.5rem) var(--sp-5, 1.25rem);
    margin: var(--sp-5, 1.25rem) 0 0;
    padding: 0;
    list-style: none;
    color: var(--bf-ink-2);
    font-size: 0.95rem;
  }

  .bf-hero--centered .bf-hero__facts {
    justify-content: center;
  }

  .bf-hero__facts strong {
    color: var(--bf-ink);
  }

  .bf-hero__facts a {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    margin-block: -12px;
    color: var(--bf-ink);
    font-weight: 700;
    text-decoration-thickness: 2px;
    text-underline-offset: 4px;
  }

  /* ── Stage ─────────────────────────────── */
  .bf-hero__stage {
    position: relative;
    width: min(100%, 520px);
    aspect-ratio: 1;
    margin: 0 auto;
  }

  .bf-hero--centered .bf-hero__stage {
    width: min(100%, 420px);
  }

  .bf-hero__sun {
    position: absolute;
    inset: 8%;
    border-radius: 50%;
    background: repeating-conic-gradient(var(--bf-mustard) 0 10deg, color-mix(in srgb, var(--bf-mustard) 55%, var(--bf-bg)) 10deg 20deg);
    border: 3px solid var(--bf-outline);
    animation: bf-hero-spin 40s linear infinite;
  }

  .bf-hero__plate {
    position: absolute;
    inset: 16%;
    display: grid;
  }

  .bf-hero__dish {
    grid-area: 1 / 1;
    margin: 0;
    opacity: 0;
    transform: rotate(-120deg) scale(0.6);
    transition: opacity 0.4s ease, transform 0.7s var(--bf-ease-pop);
    filter: drop-shadow(8px 10px 0 var(--bf-outline));
  }

  .bf-hero__dish.is-on {
    opacity: 1;
    transform: none;
  }

  .bf-hero__dish > svg {
    width: 100%;
    height: 100%;
  }

  .bf-hero__tag {
    position: absolute;
    right: -6%;
    bottom: 4%;
    display: grid;
    padding: 0.5rem 0.9rem;
    border: 2px solid var(--bf-outline);
    border-radius: var(--bf-radius-sm);
    background: var(--bf-paper);
    color: var(--bf-ink);
    font-weight: 700;
    font-size: 0.9rem;
    transform: rotate(5deg);
    box-shadow: 3px 3px 0 var(--bf-outline);
  }

  .bf-hero__tag b {
    font-family: var(--bf-font-display);
    font-size: 1.25rem;
    color: var(--bf-tomato);
  }

  .bf-hero__orbit {
    position: absolute;
    inset: 0;
    animation: bf-hero-spin 26s linear infinite;
  }

  .bf-hero__sticker {
    position: absolute;
    width: 19%;
    aspect-ratio: 1;
    padding: 2%;
    border: 2px solid var(--bf-outline);
    border-radius: 50%;
    background: var(--bf-paper);
    animation: bf-hero-spin 26s linear infinite reverse;
  }

  .bf-hero__sticker svg {
    width: 100%;
    height: 100%;
  }

  .bf-hero__sticker--0 { top: 0; left: 40%; }
  .bf-hero__sticker--1 { top: 40%; right: 0; }
  .bf-hero__sticker--2 { bottom: 0; left: 40%; }
  .bf-hero__sticker--3 { top: 40%; left: 0; }

  .bf-hero__note {
    position: absolute;
    top: 4%;
    left: -2%;
    margin: 0;
    padding: 0.7rem 0.9rem;
    border: 2px solid var(--bf-outline);
    background: var(--bf-mint-soft);
    color: var(--bf-ink);
    font-family: var(--bf-font-display);
    font-weight: 800;
    line-height: 1.1;
    transform: rotate(-8deg);
    box-shadow: 3px 3px 0 var(--bf-outline);
  }

  .bf-hero__road {
    position: absolute;
    left: -10%;
    right: -10%;
    bottom: -2%;
    height: 48px;
    border-bottom: 3px dashed var(--bf-ink-3);
  }

  .bf-hero__rider {
    position: absolute;
    bottom: 2px;
    left: 0;
    animation: bf-hero-ride 7s cubic-bezier(0.6, 0, 0.4, 1) infinite;
  }

  .bf-hero__rider .r-wheel { stroke: var(--bf-outline); stroke-width: 3; fill: var(--bf-paper); }
  .bf-hero__rider .r-frame { stroke: var(--bf-tomato); stroke-width: 3.5; }
  .bf-hero__rider .r-box { fill: var(--bf-tomato); stroke: var(--bf-outline); stroke-width: 2.5; }
  .bf-hero__rider .r-head { fill: var(--bf-mustard); stroke: var(--bf-outline); stroke-width: 2.5; }

  /* ── Pause ─────────────────────────────── */
  .bf-hero__pause {
    position: absolute;
    top: var(--sp-3, 0.75rem);
    right: var(--sp-3, 0.75rem);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 44px;
    padding: 0 0.9rem;
    border: 2px solid var(--bf-outline);
    border-radius: 999px;
    background: var(--bf-paper);
    color: var(--bf-ink);
    font: inherit;
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
  }

  .bf-hero__play-i,
  .bf-hero.is-paused .bf-hero__pause-i {
    display: none;
  }

  .bf-hero.is-paused .bf-hero__play-i {
    display: block;
  }

  /* ── Marquee ───────────────────────────── */
  .bf-hero__marquee {
    margin-top: clamp(2rem, 5vw, 3.5rem);
    margin-inline: calc(var(--sp-4, 1rem) * -1);
    border-block: 3px solid var(--bf-outline);
    background: var(--bf-night);
    color: var(--bf-on-night);
    overflow: hidden;
    transform: rotate(-1.2deg) scale(1.02);
  }

  .bf-hero__track {
    display: flex;
    gap: var(--sp-6, 1.5rem);
    width: max-content;
    padding: 0.7rem 0;
    animation: bf-hero-marquee 38s linear infinite;
  }

  .bf-hero__chip {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    font-family: var(--bf-font-display);
    font-weight: 800;
    font-size: 1.15rem;
    white-space: nowrap;
  }

  .bf-hero__chip b {
    color: var(--bf-mustard);
  }

  .bf-hero.is-paused *,
  .bf-hero.is-paused *::before {
    animation-play-state: paused !important;
  }

  /* Scroll-driven: the plate spins and lifts as the hero leaves the viewport. */
  @supports (animation-timeline: view()) {
    .bf-hero__plate {
      animation: bf-hero-scrollspin linear both;
      animation-timeline: view();
      animation-range: exit 0% exit 100%;
    }
  }

  @keyframes bf-hero-scrollspin {
    to { transform: rotate(160deg) scale(0.8) translateY(-10%); }
  }

  @keyframes bf-hero-spin {
    to { transform: rotate(360deg); }
  }

  @keyframes bf-hero-pulse {
    50% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--bf-mint) 25%, transparent); }
  }

  @keyframes bf-hero-ride {
    0% { transform: translateX(-80px); }
    45%, 55% { transform: translateX(calc(min(520px, 90vw) * 0.55)) translateY(-2px); }
    100% { transform: translateX(calc(min(620px, 110vw))); }
  }

  @keyframes bf-hero-marquee {
    to { transform: translateX(-50%); }
  }

  @media (max-width: 899px) {
    .bf-hero__stage {
      width: min(86%, 420px);
    }
  }

  @media (prefers-reduced-motion: reduce) {
    .bf-hero *,
    .bf-hero *::before {
      animation: none !important;
      transition: none !important;
    }
  }
</style>
--- /** * FoodHeroPlate — Pop "sticker" hero for a food delivery brand. A giant plate swaps dishes in * sync with the headline word, ingredient stickers orbit it, a rider zips along a dashed road and * the plate spins as the hero scrolls away (scroll-driven animation). Includes an address field * that sends the visitor to the menu and a marquee of dishes. * * @param {string} menuHref - Menu page; the address form submits here with ?dir=. * @param {string} trackHref - Order tracking page (secondary link). * @param {Array<{name: string, art: FoodArt, price: number}>} dishes - Dishes for the plate carousel and marquee. * @param {string[]} words - Rotating words after "Hambre de". * @param {number} minutes - Average delivery time shown in the badge. * @param {number} freeFrom - Free delivery threshold (EUR). * @param {string} variant - 'centered' (monumental poster stage) | 'split' (plate on the right). Default 'centered'. * @param {string} size - 'md' | 'lg' headline size. Default 'lg'. * @param {string} class - Extra class for the root. * * Accessibility: the headline has a static accessible name ("Hambre de algo rico"); the rotating * word and every decorative layer are aria-hidden. A visible pause button stops all motion * (WCAG 2.2.2) and prefers-reduced-motion disables it from the start. The marquee copy is hidden * from screen readers; the address input has a visible label. */ import type { HTMLAttributes } from 'astro/types'; import '../templates/food-delivery/food-theme.css'; import { foodArt } from '../templates/food-delivery/food-art'; import type { FoodArt } from '../templates/food-delivery/data'; interface Dish { name: string; art: FoodArt; price: number } interface OwnProps { menuHref?: string; trackHref?: string; dishes?: Dish[]; words?: string[]; minutes?: number; freeFrom?: number; variant?: 'centered' | 'split'; size?: 'md' | 'lg'; } type Props = OwnProps & Omit<HTMLAttributes<'section'>, keyof OwnProps | 'class'> & { class?: string }; const { menuHref = '#carta', trackHref = '#pedido', dishes = [ { name: 'Doble Smash', art: 'burger', price: 12.9 }, { name: 'Tonkotsu 18 h', art: 'ramen', price: 14.5 }, { name: 'Tacos al pastor', art: 'taco', price: 10.9 }, { name: 'Diavola', art: 'pizza', price: 13.9 }, { name: 'Poke de salmón', art: 'poke', price: 13.5 }, ], words = ['smash burgers', 'ramen', 'tacos', 'pizza', 'poke'], minutes = 24, freeFrom = 25, variant = 'centered', size = 'lg', class: classAttr, ...rest } = Astro.props; const plates = dishes.slice(0, Math.max(1, words.length)); const eur = (n: number) => n.toLocaleString('es-ES', { minimumFractionDigits: 2, maximumFractionDigits: 2 }); const marquee = [...dishes, ...dishes]; const orbit: FoodArt[] = ['drink', 'dessert', 'salad', 'taco']; --- <section class:list={['bf-ui', 'bf-hero', `bf-hero--${variant}`, `bf-hero--${size}`, classAttr]} aria-labelledby="bf-hero-title" data-bf-hero {...rest} > <div class="bf-hero__grid"> <div class="bf-hero__copy"> <p class="bf-hero__kicker"> <span class="bf-hero__live" aria-hidden="true"></span> Abierto ahora · entrega en ~{minutes} min </p> <h1 id="bf-hero-title" class="bf-hero__title"> <span class="bf-hero__line">Hambre de</span> <span class="bf-hero__swap" aria-hidden="true"> {words.map((w, i) => <span class:list={['bf-hero__word', { 'is-on': i === 0 }]}>{w}</span>)} </span> <span class="bf-sr">algo rico</span> </h1> <p class="bf-hero__lead"> Cocinamos al momento en Lavapiés y te lo llevamos caliente. Sin comisiones escondidas, con seguimiento en directo hasta tu puerta. </p> <form class="bf-hero__form" action={menuHref} method="get" role="search"> <label for="bf-hero-dir" class="bf-hero__label">¿Dónde te lo llevamos?</label> <div class="bf-hero__field"> <svg class="bf-hero__pin" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" aria-hidden="true"><path d="M12 21s-7-6.2-7-12a7 7 0 0 1 14 0c0 5.8-7 12-7 12z" /><circle cx="12" cy="9" r="2.5" /></svg> <input id="bf-hero-dir" name="dir" type="text" autocomplete="street-address" placeholder="Calle, número y piso" /> <button type="submit" class="bf-hero__go">Ver carta</button> </div> </form> <ul class="bf-hero__facts" role="list"> <li><strong>{minutes} min</strong> de media</li> <li><strong>Envío gratis</strong> desde {freeFrom} €</li> <li><a href={trackHref}>Seguir mi pedido</a></li> </ul> </div> <div class="bf-hero__stage" aria-hidden="true"> <div class="bf-hero__sun"></div> <div class="bf-hero__plate"> {plates.map((d, i) => ( <figure class:list={['bf-hero__dish', { 'is-on': i === 0 }]}> <svg class="bf-art" viewBox="0 0 120 120" set:html={foodArt(d.art)} /> <figcaption class="bf-hero__tag"> <span>{d.name}</span> <b>{eur(d.price)} €</b> </figcaption> </figure> ))} </div> <div class="bf-hero__orbit"> {orbit.map((a, i) => ( <span class={`bf-hero__sticker bf-hero__sticker--${i}`}> <svg class="bf-art" viewBox="0 0 120 120" set:html={foodArt(a)} /> </span> ))} </div> <p class="bf-hero__note">¡Envío gratis<br />desde {freeFrom} €!</p> <div class="bf-hero__road"> <span class="bf-hero__rider"> <svg width="64" height="44" viewBox="0 0 64 44" fill="none" stroke-linecap="round" stroke-linejoin="round"> <circle cx="14" cy="34" r="8" class="r-wheel" /> <circle cx="50" cy="34" r="8" class="r-wheel" /> <path d="M14 34l10-16h14l6 16M24 18l-4-6h-6" class="r-frame" /> <rect x="30" y="4" width="18" height="14" rx="3" class="r-box" /> <circle cx="28" cy="8" r="4" class="r-head" /> </svg> </span> </div> </div> </div> <button type="button" class="bf-hero__pause" aria-pressed="false" data-bf-pause> <svg width="16" height="16" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true" class="bf-hero__pause-i"><rect x="6" y="5" width="4" height="14" rx="1" /><rect x="14" y="5" width="4" height="14" rx="1" /></svg> <svg width="16" height="16" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true" class="bf-hero__play-i"><path d="M8 5v14l11-7z" /></svg> <span data-bf-pause-label>Pausar animación</span> </button> <div class="bf-hero__marquee" aria-hidden="true"> <div class="bf-hero__track"> {marquee.map((d) => ( <span class="bf-hero__chip"> <svg class="bf-art" viewBox="0 0 120 120" width="34" height="34" set:html={foodArt(d.art)} /> {d.name} <b>{eur(d.price)} €</b> </span> ))} </div> </div> </section> <script> function initFoodHero() { document.querySelectorAll<HTMLElement>('[data-bf-hero]').forEach((root) => { if (root.dataset.bound) return; root.dataset.bound = 'true'; const words = [...root.querySelectorAll<HTMLElement>('.bf-hero__word')]; const dishes = [...root.querySelectorAll<HTMLElement>('.bf-hero__dish')]; const btn = root.querySelector<HTMLButtonElement>('[data-bf-pause]'); const label = root.querySelector<HTMLElement>('[data-bf-pause-label]'); const reduce = window.matchMedia('(prefers-reduced-motion: reduce)').matches; let i = 0; let timer: number | undefined; const show = (n: number) => { words.forEach((w, k) => w.classList.toggle('is-on', k === n)); dishes.forEach((d, k) => d.classList.toggle('is-on', k === n % dishes.length)); }; const play = () => { stop(); timer = window.setInterval(() => { i = (i + 1) % words.length; show(i); }, 2600); }; const stop = () => window.clearInterval(timer); const setPaused = (paused: boolean) => { root.classList.toggle('is-paused', paused); btn?.setAttribute('aria-pressed', String(paused)); if (label) label.textContent = paused ? 'Reanudar animación' : 'Pausar animación'; paused ? stop() : play(); }; btn?.addEventListener('click', () => setPaused(btn.getAttribute('aria-pressed') !== 'true')); document.addEventListener('visibilitychange', () => { if (root.classList.contains('is-paused')) return; document.hidden ? stop() : play(); }); setPaused(reduce); }); } initFoodHero(); document.addEventListener('astro:page-load', initFoodHero); </script> <style> .bf-hero { position: relative; overflow: hidden; padding: clamp(2rem, 6vw, 5rem) var(--sp-4, 1rem) 0; background: radial-gradient(circle at 85% 10%, color-mix(in srgb, var(--bf-mustard) 40%, transparent) 0, transparent 40%), var(--bf-bg); color: var(--bf-ink); font-family: var(--bf-font-body); } .bf-hero__grid { max-width: 1240px; margin: 0 auto; display: grid; gap: clamp(2rem, 5vw, 4rem); align-items: center; } @media (min-width: 900px) { .bf-hero--split .bf-hero__grid { grid-template-columns: 1.05fr 1fr; } } .bf-hero--centered .bf-hero__grid { gap: clamp(1.5rem, 4vw, 2.5rem); justify-items: center; } .bf-hero--centered .bf-hero__copy { text-align: center; margin: 0 auto; max-width: 820px; } .bf-hero--centered .bf-hero__swap { justify-items: center; } .bf-hero--centered .bf-hero__stage { width: min(100%, 400px); margin-top: -0.5rem; } .bf-hero__kicker { display: inline-flex; align-items: center; gap: var(--sp-2, 0.5rem); margin: 0 0 var(--sp-5, 1.25rem); padding: 0.4rem 0.9rem; border: 2px solid var(--bf-outline); border-radius: 999px; background: var(--bf-paper); box-shadow: 3px 3px 0 var(--bf-outline); font-weight: 700; font-size: 0.9rem; transform: rotate(-2deg); } .bf-hero__live { width: 10px; height: 10px; border-radius: 50%; background: var(--bf-mint); animation: bf-hero-pulse 1.6s ease-in-out infinite; } .bf-hero__title { margin: 0; font-family: var(--bf-font-display); font-weight: 800; line-height: 0.95; letter-spacing: -0.03em; font-size: clamp(2.6rem, 9vw, 4.2rem); } .bf-hero--lg .bf-hero__title { font-size: clamp(2.8rem, 10vw, 5.6rem); } .bf-hero__line { display: block; } .bf-hero__swap { position: relative; display: grid; min-height: 1.05em; } .bf-hero__word { grid-area: 1 / 1; color: var(--bf-tomato); opacity: 0; transform: translateY(0.4em) rotate(4deg); transition: opacity 0.35s ease, transform 0.45s var(--bf-ease-pop); white-space: nowrap; } .bf-hero__word.is-on { opacity: 1; transform: none; } .bf-hero__lead { margin: var(--sp-5, 1.25rem) 0 0; max-width: 34rem; font-size: 1.1rem; line-height: 1.6; color: var(--bf-ink-2); } .bf-hero--centered .bf-hero__lead { margin-inline: auto; } .bf-hero__form { margin-top: var(--sp-6, 1.5rem); max-width: 34rem; } .bf-hero--centered .bf-hero__form { margin-inline: auto; } .bf-hero__label { display: block; margin-bottom: var(--sp-2, 0.5rem); font-weight: 700; } .bf-hero__field { display: flex; align-items: center; gap: var(--sp-2, 0.5rem); padding: 6px 6px 6px 14px; border: 3px solid var(--bf-outline); border-radius: 999px; background: var(--bf-paper); box-shadow: var(--bf-shadow); } .bf-hero__field:focus-within { outline: 3px solid var(--bf-sky); outline-offset: 3px; } .bf-hero__pin { flex: none; color: var(--bf-tomato); } .bf-hero__field input { flex: 1; min-width: 0; min-height: 44px; border: 0; background: transparent; color: var(--bf-ink); font: inherit; font-size: 1rem; } .bf-hero__field input:focus { outline: none; } .bf-hero__field input::placeholder { color: var(--bf-ink-3); } .bf-hero__go { flex: none; min-height: 48px; padding: 0 1.3rem; border: 2px solid var(--bf-outline); border-radius: 999px; background: var(--bf-tomato); color: var(--bf-on-tomato); font: inherit; font-weight: 800; cursor: pointer; transition: transform 0.2s var(--bf-ease-pop), background 0.2s ease; } .bf-hero__go:hover { background: var(--bf-tomato-hover); transform: translateY(-2px) rotate(-2deg); } .bf-hero__go:focus-visible, .bf-hero__facts a:focus-visible, .bf-hero__pause:focus-visible { outline: 3px solid var(--bf-sky); outline-offset: 3px; } .bf-hero__facts { display: flex; flex-wrap: wrap; gap: var(--sp-2, 0.5rem) var(--sp-5, 1.25rem); margin: var(--sp-5, 1.25rem) 0 0; padding: 0; list-style: none; color: var(--bf-ink-2); font-size: 0.95rem; } .bf-hero--centered .bf-hero__facts { justify-content: center; } .bf-hero__facts strong { color: var(--bf-ink); } .bf-hero__facts a { display: inline-flex; align-items: center; min-height: 44px; margin-block: -12px; color: var(--bf-ink); font-weight: 700; text-decoration-thickness: 2px; text-underline-offset: 4px; } /* ── Stage ─────────────────────────────── */ .bf-hero__stage { position: relative; width: min(100%, 520px); aspect-ratio: 1; margin: 0 auto; } .bf-hero--centered .bf-hero__stage { width: min(100%, 420px); } .bf-hero__sun { position: absolute; inset: 8%; border-radius: 50%; background: repeating-conic-gradient(var(--bf-mustard) 0 10deg, color-mix(in srgb, var(--bf-mustard) 55%, var(--bf-bg)) 10deg 20deg); border: 3px solid var(--bf-outline); animation: bf-hero-spin 40s linear infinite; } .bf-hero__plate { position: absolute; inset: 16%; display: grid; } .bf-hero__dish { grid-area: 1 / 1; margin: 0; opacity: 0; transform: rotate(-120deg) scale(0.6); transition: opacity 0.4s ease, transform 0.7s var(--bf-ease-pop); filter: drop-shadow(8px 10px 0 var(--bf-outline)); } .bf-hero__dish.is-on { opacity: 1; transform: none; } .bf-hero__dish > svg { width: 100%; height: 100%; } .bf-hero__tag { position: absolute; right: -6%; bottom: 4%; display: grid; padding: 0.5rem 0.9rem; border: 2px solid var(--bf-outline); border-radius: var(--bf-radius-sm); background: var(--bf-paper); color: var(--bf-ink); font-weight: 700; font-size: 0.9rem; transform: rotate(5deg); box-shadow: 3px 3px 0 var(--bf-outline); } .bf-hero__tag b { font-family: var(--bf-font-display); font-size: 1.25rem; color: var(--bf-tomato); } .bf-hero__orbit { position: absolute; inset: 0; animation: bf-hero-spin 26s linear infinite; } .bf-hero__sticker { position: absolute; width: 19%; aspect-ratio: 1; padding: 2%; border: 2px solid var(--bf-outline); border-radius: 50%; background: var(--bf-paper); animation: bf-hero-spin 26s linear infinite reverse; } .bf-hero__sticker svg { width: 100%; height: 100%; } .bf-hero__sticker--0 { top: 0; left: 40%; } .bf-hero__sticker--1 { top: 40%; right: 0; } .bf-hero__sticker--2 { bottom: 0; left: 40%; } .bf-hero__sticker--3 { top: 40%; left: 0; } .bf-hero__note { position: absolute; top: 4%; left: -2%; margin: 0; padding: 0.7rem 0.9rem; border: 2px solid var(--bf-outline); background: var(--bf-mint-soft); color: var(--bf-ink); font-family: var(--bf-font-display); font-weight: 800; line-height: 1.1; transform: rotate(-8deg); box-shadow: 3px 3px 0 var(--bf-outline); } .bf-hero__road { position: absolute; left: -10%; right: -10%; bottom: -2%; height: 48px; border-bottom: 3px dashed var(--bf-ink-3); } .bf-hero__rider { position: absolute; bottom: 2px; left: 0; animation: bf-hero-ride 7s cubic-bezier(0.6, 0, 0.4, 1) infinite; } .bf-hero__rider .r-wheel { stroke: var(--bf-outline); stroke-width: 3; fill: var(--bf-paper); } .bf-hero__rider .r-frame { stroke: var(--bf-tomato); stroke-width: 3.5; } .bf-hero__rider .r-box { fill: var(--bf-tomato); stroke: var(--bf-outline); stroke-width: 2.5; } .bf-hero__rider .r-head { fill: var(--bf-mustard); stroke: var(--bf-outline); stroke-width: 2.5; } /* ── Pause ─────────────────────────────── */ .bf-hero__pause { position: absolute; top: var(--sp-3, 0.75rem); right: var(--sp-3, 0.75rem); display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 0.9rem; border: 2px solid var(--bf-outline); border-radius: 999px; background: var(--bf-paper); color: var(--bf-ink); font: inherit; font-size: 0.82rem; font-weight: 700; cursor: pointer; } .bf-hero__play-i, .bf-hero.is-paused .bf-hero__pause-i { display: none; } .bf-hero.is-paused .bf-hero__play-i { display: block; } /* ── Marquee ───────────────────────────── */ .bf-hero__marquee { margin-top: clamp(2rem, 5vw, 3.5rem); margin-inline: calc(var(--sp-4, 1rem) * -1); border-block: 3px solid var(--bf-outline); background: var(--bf-night); color: var(--bf-on-night); overflow: hidden; transform: rotate(-1.2deg) scale(1.02); } .bf-hero__track { display: flex; gap: var(--sp-6, 1.5rem); width: max-content; padding: 0.7rem 0; animation: bf-hero-marquee 38s linear infinite; } .bf-hero__chip { display: inline-flex; align-items: center; gap: 0.6rem; font-family: var(--bf-font-display); font-weight: 800; font-size: 1.15rem; white-space: nowrap; } .bf-hero__chip b { color: var(--bf-mustard); } .bf-hero.is-paused *, .bf-hero.is-paused *::before { animation-play-state: paused !important; } /* Scroll-driven: the plate spins and lifts as the hero leaves the viewport. */ @supports (animation-timeline: view()) { .bf-hero__plate { animation: bf-hero-scrollspin linear both; animation-timeline: view(); animation-range: exit 0% exit 100%; } } @keyframes bf-hero-scrollspin { to { transform: rotate(160deg) scale(0.8) translateY(-10%); } } @keyframes bf-hero-spin { to { transform: rotate(360deg); } } @keyframes bf-hero-pulse { 50% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--bf-mint) 25%, transparent); } } @keyframes bf-hero-ride { 0% { transform: translateX(-80px); } 45%, 55% { transform: translateX(calc(min(520px, 90vw) * 0.55)) translateY(-2px); } 100% { transform: translateX(calc(min(620px, 110vw))); } } @keyframes bf-hero-marquee { to { transform: translateX(-50%); } } @media (max-width: 899px) { .bf-hero__stage { width: min(86%, 420px); } } @media (prefers-reduced-motion: reduce) { .bf-hero *, .bf-hero *::before { animation: none !important; transition: none !important; } } </style>
Входит в состав шаблона

Эта секция разработана как ключевой блок для следующего шаблона. Вы можете открыть полный многостраничный интерактивный сайт или изучить все связанные компоненты.

Готовые шаблоны 11 страниц · 16 компонентов

BiteFlow · Доставка еды & Kitchen OS

Яркая витрина в стиле стикеров: блюда летят в корзину, курьер едет по анимированной карте; плюс Kitchen OS с KDS, стоп-листом, заказами и диспетчером курьеров.

Ещё секции для изучения

Откройте для себя другие готовые блоки для лендингов и страниц из нашей библиотеки.

Все секции