Skip to main content

Rules every theme follows

Your theme runs as a guest on a shop page you don't control. These rules keep the theme from changing that page, and that page from changing the theme. The project checks most of them for you with the gates.

AGENTS.md, in the root of your project, holds the full list. It is written for AI coding assistants, which read it on their own. This page is the short version for people.

Keep your styles to yourself​

  • Scope every style. Write component styles in <style scoped>, so no rule reaches the page around the advisor.
  • Prefix what can leak with zv-. Classes, ids, keyframes and CSS custom properties start with zv-, so they can't clash with a name the shop already uses.
  • Use tokens, not raw values. Take colours, sizes and spacing from the variables in src/css/variables.css. You rebrand the theme by changing src/css/tokens.css, and every component follows.
  • Give teleported elements a font root. A modal, toast or tooltip that you teleport to <body> goes into the list of roots at the end of src/css/variables.css. Shop pages style bare tags such as a and div, and the root resets those fonts.

yarn lint:css reports a broken rule with its file and line, for example [hex-color] Hex color '#ff0000' in 'color'.

Leave the page to the shop​

  • No <h1>. Start your headings at <h2>, because the shop's page has its own <h1>.
  • No <main>, <header> or <footer>. The page already has these landmarks.
  • Don't lock the page's scroll. Put overflow: hidden on your own overlay, never on body.
  • Don't change document.title. The tab title belongs to the shop.

Make every text editable​

  • Every text a shopper sees is translatable. It has a field in the component's configuration, a default in its preset, and the component shows it with useT(). An Experience Designer user can then change and translate it without you.
  • Add settings only for what that user must change. Texts, labels and on/off switches get a configuration and preset field. Everything else, such as your cart call or a link to your shop, is code, not a setting: put calls to your shop in src/helpers.
  • Sanitize HTML. Show HTML that comes from the advisor with the v-dompurify-html directive, never with v-html.

Build for keyboard and screen reader​

Anything a shopper can click is a real button, link or input. It has an accessible name, a visible focus style and works from the keyboard.

Let the runner do the tracking​

The runner is the part of Zoovu that loads the advisor and reports what shoppers do. It tracks what goes through its API, so a shortcut of your own drops events without any error.

  • Product links use the tracked address from useTrackedOfferUrl and call recordClickout from useProductClickout on click.
  • Add to cart calls recordAddToCart from useProductAddToCart only after your cart call succeeds.
  • Navigation goes through advisor.advisorNavigation.next() and back(), not through your own history.
  • Selections and pages live on the advisor. Show what it holds and don't keep your own copy.

yarn start loads the advisor with tracking off. To check events, upload the theme to a test advisor and compare the event requests in the browser's network tab before and after your change.

Keep the code small and typed​

yarn lint fails on a single warning. It allows no any, no console.log, at most 30 lines per function and at most 300 lines per file. HTTP calls don't go in a *.component.vue file: put them in src/helpers or src/composables and call them from the component.

The gates​

Four commands tell you that a change is done. Run them after every change:

yarn lint:css && yarn lint && yarn typecheck && yarn test
CommandWhat it checks
yarn lint:cssStyle isolation and tokens
yarn lintCode rules, with no warnings allowed
yarn typecheckTypes in .ts and .vue files
yarn testThe unit tests

yarn build doesn't run them, so a theme with lint errors still builds. Run the gates before you build.

Then look at your theme at a phone width and a desktop width. The gates can't see how it looks.