@recursica/storybook-template
v0.6.0
Published
Common Storybook configuration and templates for Recursica packages and apps
Maintainers
Readme
@recursica/storybook-template
Common Storybook configuration and templates for Recursica packages and apps.
Features
- Centralized Configuration: Common Storybook configurations for all Recursica projects
- Flexible Templates: Easy-to-use templates for main and preview configurations
- Theme Support: Built-in support for light/dark themes with any UI framework
- Accessibility: Pre-configured accessibility testing
- Deployment Ready: Support for GitHub Pages and iframe embedding
Installation
npm install @recursica/storybook-templateUsage
Quick Start
Copy the template files to your .storybook directory:
cp node_modules/@recursica/storybook-template/templates/main.ts .storybook/main.ts
cp node_modules/@recursica/storybook-template/templates/preview.tsx .storybook/preview.tsxCustom Configuration
Main Configuration
import { createMainConfig } from "@recursica/storybook-template/configs/main";
const config = createMainConfig({
stories: ["../src/**/*.stories.@(js|jsx|mjs|ts|tsx)"],
basePath: "/your-app/", // For GitHub Pages deployment
enableCORS: true, // For iframe embedding
enablePostcssVars: true, // Enable Recursica PostCSS variables
recursicaCSSPath: "../recursica_variables_scoped.css", // Path to variables
postCSSStrictMode: true, // Enforce strict CSS variable parsing
});
export default config;Preview Configuration
import { createPreviewConfig } from "@recursica/storybook-template";
import { MantineProvider } from "@mantine/core";
// or import { ThemeProvider } from "@mui/material/styles";
// or import { ChakraProvider } from "@chakra-ui/react";
const preview = createPreviewConfig({
defaultTheme: "dark",
enableProvider: true,
Provider: MantineProvider,
providerProps: {
/* your provider props */
},
enableThemeProvider: true,
// ThemeProvider: ThemeProvider,
lightThemeClass: "light-theme",
darkThemeClass: "dark-theme",
});
export default preview;Individual Components
You can also import individual components:
import { withProvider, withTheme } from "@recursica/storybook-template";
import {
commonParameters,
accessibilityParameters,
} from "@recursica/storybook-template";Configuration Options
MainConfigOptions
stories: Array of story file patternsaddons: Array of Storybook addons (defaults to common addons)basePath: Base path for deployment (default: "/")enableCORS: Enable CORS headers and remove X-Frame-Options to allow iframe embedding (default: true)enablePostcssVars: Enable injection of the@recursica/recursica-postcss-varsplugin into the Vite CSS pipeline (default: false)recursicaCSSPath: Absolute path to the Recursica scoped variables CSS file. Used if enablePostcssVars is truepostCSSStrictMode: Enforces strict mode for postcss vars plugin (throws on missing vars). Defaults to true in PRODUCTION mode
PreviewConfigOptions
defaultTheme: Default theme ("light" | "dark", default: "dark")enableProvider: Enable UI framework provider (default: false)Provider: UI framework provider component (e.g., MantineProvider, ThemeProvider)providerProps: Props to pass to the providerenableThemeProvider: Enable custom theme provider (default: false)ThemeProvider: Custom theme provider componentlightThemeClass: CSS class for light themedarkThemeClass: CSS class for dark themecustomParameters: Additional Storybook parameters
Available Parameters
commonParameters: Common story sorting and optionsaccessibilityParameters: Accessibility testing configurationbackgroundParameters: Dark theme backgroundslightBackgroundParameters: Light theme backgroundscontrolParameters: Control matchers for colors and dates
Available Decorators
withProvider: Generic provider wrapper for any UI frameworkwithTheme: Theme provider wrapper with customizable options
License
MIT
