Recent purchases card and counts — Storefront block
Freestorefront-recent-purchases-card-and-counts · for product, home pages
Recent purchases card and counts
The corner card above a thin strip of the figures the shop measures (people viewing, sold today); on a phone the strip alone, the card on tap: a busy product page with real live figures; counts only when measured, orders real and never looped
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-recent-purchases-card-and-countsUsage
Its demo data, shortened (Using blocks).
<script setup lang="ts">
import StorefrontRecentPurchasesCardAndCounts from '@/components/trame/blocks/storefront/storefront-recent-purchases-card-and-counts.vue'
const props = {
title: "Recently ordered from the workshop",
purchases: [
{
id: "c-2041",
product: {
id: "bols-mouchetes",
name: "Speckled stoneware bowls, set of two",
image: "https://images.unsplash.com/photo-1530006498959-b7884e829a04?w=400&q=80",
alt: "Two speckled white stoneware bowls stacked on a dark background"
},
buyer: "Camille",
town: "Portland",
ago: "4 min ago"
},
{
id: "c-2040",
product: {
id: "mug-bleu",
name: "Blue stoneware mug and tumbler",
image: "https://images.unsplash.com/photo-1733046889345-25938f38c8e7?w=400&q=80",
alt: "A blue stoneware mug and small tumbler on a wooden place mat"
},
town: "Sacramento",
ago: "18 min ago"
}
],
counts: [
{
kind: "viewing",
value: 14,
label: "people are viewing this page"
},
{
kind: "sold",
value: 23,
label: "pieces sold today"
}
],
open: "product",
dismissLabel: "Hide recent orders",
options: {
floating: false
}
}
</script>
<template>
<StorefrontRecentPurchasesCardAndCounts v-bind="props" />
</template>Props
Each prop says who changes it: Words, Picture, Action, Design, Data.* required.
| Prop | Type | Description |
|---|---|---|
| title | string | Wordsthe card’s name for screen readers and the strip ("Recently ordered") |
| purchases* | Purchase[] | the shop’s latest real orders, newest first; none: the host renders no block |
| counts | Count[] | only the figures the shop really measures; none rather than a guess |
| open | string | Actionthe product page a purchase links to |
| dismissLabel | string | Wordsthe close button’s words for screen readers ("Hide recent purchases") |
| options | Options | the block’s settings: layout choices and secondary words, read by every variant |
Purchase purchases[] · 5 props
| Prop | Type | Description |
|---|---|---|
| id* | string | number | Datathe order’s id in the shop, never shown |
| product* | Product | the product bought |
| buyer | string | Wordsthe buyer’s first name, only when they agreed to show it; without it the block says "A customer" |
| town | string | Wordsthe delivery town, only when the buyer agreed to show it |
| ago* | string | Wordshow long ago, as the host writes it at render time ("12 min ago"); orders older than 48 h are not passed |
Product purchases[].product · 4 props
| Prop | Type | Description |
|---|---|---|
| id* | string | number | Datathe record’s id in the tool that answers it |
| name* | string | Wordsthe product’s name |
| image | string | null | Picturethe main picture; null or absent: the product has none yet |
| alt | string | Wordswhat the main picture shows |
Count counts[] · 3 props
| Prop | Type | Description |
|---|---|---|
| kind* | 'viewing' | 'sold' | viewing: people on the page now; sold: units sold today |
| value* | number | Datathe figure the shop measured, never estimated |
| label* | string | Wordsthe words after the figure ("people are looking", "sold today") |
Options options · 3 props
| Prop | Type | Description |
|---|---|---|
| position | 'start' | 'end' | the bottom corner it sits in, start by default |
| floating | boolean | fixed to the screen (the default); false sets it in the page flow, as in a preview |
| mood | 'inverse' | 'brand' | 'warm' | 'tint' | string | a 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).
| Member | What it is for |
|---|---|
| href | the address an action leads to, or null to hide what leads there |
| act | runs a change (subscribe, add to cart, save) and answers { ok } or { ok: false, error } |
| can | whether the page has this action |
| asset | a picture’s address as your app serves it |
| Link | your router’s link component |
| cartCount | the cart badge’s number |
| cartDrawer | whether your app has a cart drawer |
| cartOpen | whether the cart drawer is open |
| label | your 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:
| Key | English | French |
|---|---|---|
| newsletter.already | You are already subscribed. | Vous êtes déjà inscrit. |
| newsletter.done | Done: you are subscribed. | C’est noté : vous êtes inscrit. |
| newsletter.invalid | Check the email address. | Vérifiez l’adresse e-mail. |
| newsletter.tooMany | Too 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
- Subtle motion: one short reveal; still under reduced motion
- Real buttons and links, a visible focus
- Asks your app through actions:
open - Reads
ordersfrom your app
A storefront section, for product, home pages; it uses @lucide/vue.
Built with
The components this block is made of; each one installs on its own too.
More storefront blocks
- Quick estimate estimator: a quick estimate from the merchant’s own grid: a few choices, one large figure, the rule it uses written beside it.
- Quick order table: a trade buyer who knows what they want: every reference in a table, a quantity per line, the total running.
- Rate table: a grid of the merchant’s own rates (shipping by zone, repair pricing): rows against columns, stacked cards on a phone.
- Rating criteria bars: a product rated by several criteria: the overall note and one labelled bar per criterion; the merchant’s own only.
- Rating link inline: a buy box that is already full: just the stars and the count beside the title, linking to the reviews.
- Recently viewed grid: a history page or an empty search: the products in a grid, as many columns as the count allows.
- Recently viewed rail: under a product page or on the home page: full product cards in a scrolling row with arrows and a clear button.
- Recipient details opt in card: recipient name and phone in a bordered card under an opt-in checkbox, with a hide-prices choice only when the merchant supports it: a parcel that goes to someone else.