Skip to content

API Overview

The addon exports the following from its main entry point:

ts
import {
  definePattern,
  renderTwig,
  initTwig,
  colorArgType,
  CONTEXT_COLORS,
} from '@pdrittenhouse/storybook-addon-twig-wordpress';

import type {
  AddonOptions,
  WordPressContextMock,
  ContextColor,
} from '@pdrittenhouse/storybook-addon-twig-wordpress';

Exports

ExportKindDescription
definePatternfunctionCreates render + args fields for a Storybook Meta object
renderTwigfunctionRenders a registered template with args — used internally by definePattern
initTwigfunctionRegisters templates and applies shims — called once by preview.ts
colorArgTypefunctionReturns a Storybook argType config for contextual color fields
CONTEXT_COLORSconstReadonly array of default contextual color names
AddonOptionsinterfaceOptions object for the addon's main.ts config
WordPressContextMockinterfaceShape of the WP context mock injected into every story
ContextColortypeUnion type of all default contextual color string literals

Preset exports

The addon also exports Storybook preset hooks from @pdrittenhouse/storybook-addon-twig-wordpress/preset:

ExportDescription
viteFinalMerges namespace aliases, SCSS additionalData, and the twig-registry Vite plugin into the Vite config
webpackFinalSame for webpack — adds raw-loader for .twig files and namespace aliases
previewAnnotationsRegisters preview.ts as a global decorator entry

These are consumed automatically by Storybook when the addon is listed in addons — you do not need to call them directly.

Released under the MIT License.