Category campaign banner in grid — Storefront block

Pro

storefront-category-campaign-banner-in-grid · for home, catalog pages

Category campaign banner in grid

Four or five tiles and the merchant’s own announcement tile in the last cell: a campaign among categories

Documentation

Installation

One command copies the block into your project with the shadcn CLI (the registry is set once: Installation).

pnpm dlx shadcn-vue@latest add @trame/storefront-category-campaign-banner-in-grid

Usage

Its demo data, shortened (Using blocks).

<script setup lang="ts">
import StorefrontCategoryCampaignBannerInGrid from '@/components/trame/blocks/storefront/storefront-category-campaign-banner-in-grid.vue'

const props = {
title: "Shop by department",
subtitle: "Six departments to gear up for a trip, from the jacket to the campsite.",
tiles: [
{
id: "1",
name: "Jackets",
summary: "Windbreakers, puffers and rain jackets for every season.",
image: "https://images.unsplash.com/photo-1673712060934-34358642511b?w=1600&q=80",
alt: "Jackets, category preview",
count: 38,
priceFrom: 8900
},
{
id: "2",
name: "Shoes",
summary: "From Sunday strolls to mountain running.",
image: "https://images.unsplash.com/photo-1575987116913-e96e7d490b8a?w=1600&q=80",
alt: "Shoes, category preview",
count: 24,
priceFrom: 6500
}
],
banner: {
title: "Refurbished pre-owned gear",
text: "Every piece is cleaned, inspected and guaranteed for six months.",
label: "See pre-owned gear",
action: "category",
record: {
id: "occasions"
}
},
open: "category",
allAction: "catalog",
options: {
unit: "models"
}
}
</script>

<template>
<StorefrontCategoryCampaignBannerInGrid v-bind="props" />
</template>

Props

Each prop says who changes it: Words, Picture, Action, Design, Data.* required.

PropTypeDescription
title*stringWordsthe section’s title ("Shop by department")
subtitlestringWordsone sentence under the title, if it helps
tiles*Tile[]Datathe categories (or materials, occasions, recipients) to show, in the order to show them; five at most are shown beside the banner
banner*Bannerthe merchant’s announcement shown with the category
openstringActionthe page action a tile opens; it receives the category
allActionstringActionthe page action of the "see all" link
optionsOptionsthe block’s settings: layout choices and secondary words, read by every variant
Tile tiles[] · 8 props
PropTypeDescription
id*string | numberDatathe record’s id in the tool that answers it
name*stringWordsthe category’s name
imagestringPicturea picture: a root-relative path (/media/…) or an absolute URL
altstringWordswhat the category’s picture shows
countnumberhow many products it holds
summarystringWordsone short line on the category
badgestringWordsa short tag the merchant set ("New"), only when it is true
priceFromnumberthe lowest price of the category in cents, computed from the catalogue
Banner banner · 5 props
PropTypeDescription
title*stringWordsthe merchant’s own announcement, in a few words
textstringWordsone sentence
label*stringWordsthe button’s words
action*stringActionwhere the button leads
recordRecord<string, unknown>Datathe record the action opens, if any
Options options · 3 props
PropTypeDescription
unitstringWordswhat a count counts ("models", "pieces"), written after the number
aspect'square' | 'portrait' | 'landscape'the pictures’ shape: square, portrait or landscape
mood'inverse' | 'brand' | 'warm' | 'tint' | stringa band of the page that redefines the theme surfaces inside it
What it asks your app for

The block never knows your app: it asks it, through one context provided once, where its links lead, what its actions do, how a price reads and which words to say (The host context).

MemberWhat it is for
hrefthe address an action leads to, or null to hide what leads there
actruns a change (subscribe, add to cart, save) and answers { ok } or { ok: false, error }
canwhether the page has this action
moneyformats a price, given in cents
asseta picture’s address as your app serves it
Linkyour router’s link component
cartCountthe cart badge’s number
cartDrawerwhether your app has a cart drawer
cartOpenwhether the cart drawer is open
labelyour word for an interface key, or undefined to keep the block’s own

The words it says itself, in English and French; label(key) replaces any of them:

KeyEnglishFrench
newsletter.alreadyYou are already subscribed.Vous êtes déjà inscrit.
newsletter.doneDone: you are subscribed.C’est noté : vous êtes inscrit.
newsletter.invalidCheck the email address.Vérifiez l’adresse e-mail.
newsletter.tooManyToo many attempts, try again in a moment.Trop de tentatives, réessayez dans un moment.

Features

  • Every word in the server HTML
  • Same markup in Vue and React
  • Theme tokens only: every theme, light and dark
  • Shows what you give it, invents nothing
  • Expressive motion, within its budget; still under reduced motion
  • Real buttons and links, a visible focus
  • Asks your app through actions: banner, open, allAction
  • Reads categories from your app

A storefront section, for home, catalog pages; it uses @lucide/vue, @vueuse/core, class-variance-authority, clsx, motion, reka-ui, tailwind-merge.

More storefront blocks

  • Catalog filters bar: a slim bar of facet menus over a grid that sits in its own section, sort on the right: for catalogues with two to five facets.
  • Catalog filters drawer: only a "Filters (n)" button that opens the drawer of facets and sort: for small catalogues and pages where the filters should stay out of the way.
  • Catalog sidebar: the facets in a column beside the grid on a wide screen, in a drawer on a phone: the standard catalogue page, for shops with several facets.
  • Catalog top bar: a bar of facet menus above a full-width grid: for catalogues with two to five facets, where the pictures should have all the room.
  • Category comparison compare table: three or four categories against the same specifications: a technical catalogue where the choice is a comparison.
  • Category index alphabet: a long or picture-poor catalogue: every category as a link under its letter, from 3 to 60 of them.
  • Category index inline: a short catalogue of 3 to 20 categories set large in one flowing paragraph, each count raised after its name: a confident, type-led way in for a shop with few or no pictures.
  • Category index ladder: categories that differ on one measure (capacity, size, price band): a bar per row, proportional to the real value.

All 409 storefront blocks