@spillway-cms/brand
v0.1.24
Published
The brand of a Spillway CMS site for front ends of their own: a Tailwind preset (v3) and theme (v4) over Spillway's CSS variables, and a build step that writes the brand stylesheet from GET /api/public/brand.
Readme
@spillway-cms/brand
The brand of a Spillway CMS site for a front end of its own. MIT licensed.
Colors, fonts, the type scale, radius, shadow and spacing come from GET /api/public/brand as CSS variables (--sw-color-primary, --sw-text-xl, ...). This package points Tailwind at those variables and writes the stylesheet that defines them, so the front end looks like the site Spillway renders and follows the brand when someone publishes a change under Structure → Brand. Dark mode and high contrast keep working through the stylesheet's media blocks.
The stylesheet
npm install -D @spillway-cms/brand
npx spillway-brand --url https://cms.example.org --out src/spillway-brand.cssRun it before the build (a prebuild script) and again when the brand.published webhook arrives. SPILLWAY_URL works in place of --url, --json brand.json also writes the brand as JSON, and --site <key> picks a site of a multisite instance (with SPILLWAY_TOKEN). A run that finds the same brand version writes nothing. Import the file once, in your global CSS or root layout.
Tailwind v4
npx spillway-brand --url https://cms.example.org --out src/spillway-brand.css --tailwind v4The file then ends with an @theme inline block, so bg-primary, text-primary-700, font-heading, text-xl, rounded-brand, shadow-brand and max-w-content follow the brand. Import it after @import "tailwindcss";.
Tailwind v3
// tailwind.config.mjs
import { fetchBrand, tailwindPreset } from '@spillway-cms/brand';
const brand = await fetchBrand(process.env.SPILLWAY_URL);
export default { presets: [tailwindPreset(brand)], content: ['./src/**/*.{astro,tsx,ts}'] };Load the stylesheet as well: the preset names the variables, the stylesheet sets them.
API
fetchBrand(baseUrl, options?): the published brand (PublicBrand), through@spillway-cms/client.tailwindPreset(brand): a Tailwind v3 preset.tailwindTheme(brand): the Tailwind v4@theme inlineblock.brandStylesheet(brand, { tailwind: 'v4' }?): the stylesheet the command writes.brandColors(brand),brandFontSizes(brand): the pieces the preset is made of.
