Product editor side panel — Form block

Pro

form-product-editor-side-panel · for app pages

Product editor side panel

Edit a product in a narrow workspace with a compact product preview above stacked controls.

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/form-product-editor-side-panel

Usage

Its demo data, shortened (Using blocks).

<script setup lang="ts">
import FormProductEditorSidePanel from '@/components/trame/blocks/form/form-product-editor-side-panel.vue'

const props = {
title: "Edit the rain jacket",
product: {
id: "veste",
name: "Rain jacket",
summary: "A relaxed fit and an adjustable hood for getting around on foot. The outer fabric keeps light showers out.",
price: 8900,
compareAt: 10900,
status: "draft",
slug: "veste-de-pluie",
collectionIds: [
"plein-air"
],
image: "https://images.unsplash.com/photo-1591047139829-d91aecb6caea?w=800&q=80",
images: [
"https://images.unsplash.com/photo-1591047139829-d91aecb6caea?w=800&q=80",
"https://images.unsplash.com/photo-1673712060934-34358642511b?w=800&q=80"
],
alt: "Jackets displayed on hangers",
seoTitle: "A rain jacket for everyday outings",
seoDescription: "Discover our lightweight jacket, its sizes and its colors. Read the care tips before you order.",
variants: [
{
id: "0-0",
size: "S",
colour: "Orange",
sku: "VPL-S-OR",
stock: 4
},
{
id: "0-1",
size: "S",
colour: "Olive",
sku: "VPL-S-OL",
stock: 5
}
]
},
collections: [
{
id: "plein-air",
name: "Outdoors"
},
{
id: "quotidien",
name: "Everyday essentials"
}
],
save: "product.save"
}
</script>

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

Props

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

PropTypeDescription
title*stringWordsthe section’s heading
product*ProductDatathe product being edited
collections*Collection[]Datathe collections the product can belong to
savestringActionsaves the edits: through the host it receives `{ id, patch }` (the fields changed, prices in cents); posted natively, the form sends the fields by name (prices in the main unit)
optionsOptionsthe block’s settings: layout choices and secondary words, read by every variant
Product product · 25 props
PropTypeDescription
id*string | numberDatathe record’s id in the tool that answers it
name*stringWordsthe product’s name
price*numberan amount in cents
compareAtnumberthe price before the merchant’s reduction
currencystringDesignISO 4217, EUR by default
imagestring | nullPicturethe main picture; null or absent: the product has none yet
imagesstring[]Picturea picture: a root-relative path (/media/…) or an absolute URL
altstringWordswhat the main picture shows
brandstringWordsthe brand or maker
categorystringWordsthe product’s category, e.g. "Knitwear"
summarystringWordsone short line on the product
badgestringWordsa short tag the merchant set ("New", "Handmade")
ratingnumberthe average of the shop’s own stored reviews
reviewCountnumberhow many stored reviews the rating averages
availablebooleanfalse: sold out; true or absent: can be bought
stocknumberthe real stock, when the merchant shows it
maxQuantitynumberthe most one order may hold of it, as the merchant set it (one per customer, a limited run)
optionsOption[]the product’s options and their values, e.g. sizes
highlightsHighlight[]a few key facts the merchant set, shown on the product’s card
status*'draft' | 'active' | 'archived'the product’s status: draft, active, archived
collectionIds*(string | number)[]Datathe ids of the collections it belongs to
seoTitlestringWordsthe title search engines show
seoDescriptionstringWordsthe description search engines show
slug*stringDesignthe last part of the product’s address
variants*Variant[]Datathe product’s variants, each with its size, colour and stock
Option product.options[] · 2 props
PropTypeDescription
name*stringWordsthe option’s name, e.g. "Size"
values*string[]Wordsits values, e.g. "S", "M", "L"
Highlight product.highlights[] · 2 props
PropTypeDescription
label*stringWordsthe property ("Material", "Capacity")
value*stringWordsits value, as the merchant states it ("Washed linen", "50 cl")
Variant product.variants[] · 5 props
PropTypeDescription
id*stringDatathe variant’s id
size*stringWordsthe variant’s size
colour*stringWordsthe variant’s colour
sku*stringDatathe variant’s stock reference
stock*numberhow many are in stock
Collection collections[] · 6 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
Options options · 1 props
PropTypeDescription
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
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
  • No motion; still under reduced motion
  • Real buttons and links, a visible focus
  • Asks your app through actions: record.save
  • Reads products, categories from your app

A form section, for app pages; it uses @vueuse/core, class-variance-authority, clsx, tailwind-merge.

More form blocks

  • Multi step wizard vertical: six steps or more, or long ones: a vertical step list on the left and a single card on the right.
  • Option group editor inline: every group as a card, one under the other, beside a preview of the whole product as the buyer will choose it: the options section of a product’s own edit page.
  • Option group editor list: one ruled row per group with its rule and options in words, moved up or down, opened one at a time to edit: a menu with many groups to put in order.
  • Option group editor sheet: the groups listed on the page and the one chosen open in a side sheet, its fields above the buyer’s preview and the save bar: a back office where a dish or a product is edited in a panel over its list.
  • Record label left: a record with many plain fields, as in settings: each label and its help on the left, its field on the right.
  • Record page: create or edit one record on its own page: titled sections as cards, short fields paired, a sticky save bar.
  • Record panel: the same form in a drawer or a narrow column: one field per row, no cards, a sticky save bar.
  • Record sections collapsible: a long record with optional parts (SEO, shipping, advanced): sections that fold, all open without script.

All 17 form blocks