Skip to content
nebula-page-stories logo

Example page stories with Storybook

nebula-page-stories

Page stories showcase how components work together in realistic layouts. They should closely mirror what end users will experience in Drupal Canvas, so avoid patterns that won't be available in Canvas.

NeverSight/skills_feed0installs215starsOther

SKILL.md

Full skill instructions

Example page stories with Storybook

Page stories showcase how components work together in realistic layouts. They should closely mirror what end users will experience in Drupal Canvas, so avoid patterns that won't be available in Canvas.

Location and naming

  • Page stories MUST be placed in src/​stories/​example-pages/
  • Page story files should be named <page-name>.stories.jsx
  • The Storybook title MUST use this format: title: "Example pages/[Page Title]"

Single-story hoisting

Use single-story hoisting for cleaner navigation. Page stories should use Storybook's single-story hoisting feature to avoid unnecessary nesting in the sidebar. This is achieved by:

  1. Including the full page name in the title
  2. Exporting only one story (typically Default)
  3. Setting the story's name property to match the last segment of the title
// src/​stories/​example-pages/​product-detail.stories.jsx
export default {
  title: "Example pages/​Product: Detail",
  component: ProductDetailPage,
  parameters: {
    layout: "fullscreen",
  },
};

export const Default = {
  name: "Product: Detail",
};

This results in a flat sidebar entry "Product: Detail" under "Example pages", rather than a nested "Product: Detail" → "Default" structure.

  • When creating new components, consider adding them to existing page stories if they fit naturally, or create new page stories to demonstrate the component in context.
  • When modifying existing components, review page stories in src/​stories/​example-pages/ to ensure changes work well in composed layouts and update them if needed.

PageLayout component

All page stories must use a shared PageLayout component from src/​stories/​example-pages/​page-layout.jsx.

Create PageLayout when

  • Creating the first page story, OR
  • It doesn't exist in src/​stories/​example-pages/

PageLayout structure

// src/​stories/​example-pages/​page-layout.jsx
import Footer from "@/​components/​footer";
import Header from "@/​components/​header";
import Section from "@/​components/​section";

const footerData = {
  // Shared footer data
};

const PageLayout = ({ children }) => (
  <>
    <Section width="wide" content={<Header />} />
    {children}
    <Section width="wide" content={<Footer {...footerData} />} />
  </>
);

export default PageLayout;

Using PageLayout

// src/​stories/​example-pages/​about-page.stories.jsx
import Section from "@/​components/​section";
import Text from "@/​components/​text";

import PageLayout from "./​page-layout";

const AboutPage = () => (
  <PageLayout>
    <Section width="normal" content={<Text text="<p>About us...</​p>" />} />
  </​PageLayout>
);

export default {
  title: "Example pages/​About",
  component: AboutPage,
  parameters: { layout: "fullscreen" },
};

export const Default = { name: "About" };

Composition rules

Page stories must only import and compose components.

Allowed

  • Import from @/​components/<name>
  • Pass props and compose together
  • Define sample data (strings, objects, arrays)

Not allowed

  • Define React components inline
  • Use raw HTML elements (<div>, <span>) for layout
  • Duplicate existing component code
// Wrong - defines inline components and uses raw HTML elements
const Logo = ({ color }) => <div className="flex">...</​div>;

const Page = () => (
  <div className="flex flex-col gap-8">
    <Logo color="#000" />
    <div className="mx-auto max-w-3xl">Content</​div>
  </​div>
);
// Correct - imports and composes existing components
import Footer from "@/​components/​footer";
import Header from "@/​components/​header";
import Section from "@/​components/​section";
import Text from "@/​components/​text";

const Page = () => (
  <>
    <Header />
    <Section width="normal" content={<Text text="<p>Content here</​p>" />} />
    <Footer />
  </>
);

If you need a <div>, look for an existing component. If none exists, create it in src/​components/ first.

No className in page stories

The className prop is not exposed in Canvas. Page stories should not pass it.

// Wrong
const AboutPage = () => (
  <PageLayout>
    <Section width="normal">
      <Text className="mt-8 mb-12" content="..." />
    </​Section>
    <Card className="shadow-xl" title="Mission" />
  </​PageLayout>
);

// Correct
const AboutPage = () => (
  <PageLayout>
    <Section width="normal">
      <Text content="..." />
    </​Section>
    <Card title="Mission" />
  </​PageLayout>
);

When className IS appropriate:

  • Inside a component's index.jsx when composing other components
  • In individual component stories (not page stories)

Spacing with Spacer component

Control spacing between components using spacer, not margins or padding.

If spacer doesn't exist, copy it:

cp -r examples/​components/​spacer src/​components/
cp examples/​stories/​spacer.stories.jsx src/​stories/
// Correct
import Spacer from "@/​components/​spacer";

const AboutPage = () => (
  <PageLayout>
    <Hero title="About Us" />
    <Spacer height="large" />
    <Section width="normal">
      <Text content="<p>Our story...</​p>" />
    </​Section>
    <Spacer height="medium" />
    <Section width="normal">
      <Text content="<p>Our mission...</​p>" />
    </​Section>
  </​PageLayout>
);

// Wrong
const AboutPage = () => (
  <PageLayout>
    <Hero title="About Us" />
    <div className="mt-16">
      <Section width="normal">
        <Text content="<p>Our story...</​p>" />
      </​Section>
    </​div>
  </​PageLayout>
);

Layout components

Use existing layout components instead of inline styles.

Check src/​components/ and examples/​components/ for:

  • Width constraints: section, container
  • Column layouts: grid-container, columns
  • Spacing: spacer, divider
// Correct
<WidthConstraintComponent variant="wide">
  <ColumnLayoutComponent columns="sidebar-main">
    {/​* Content */​}
  </​ColumnLayoutComponent>
</​WidthConstraintComponent>

// Wrong
<div className="mx-auto max-w-6xl px-4">
  <div className="grid grid-cols-[300px_1fr] gap-8">
    {/​* Content */​}
  </​div>
</​div>

More Other skills

Delegate independent tasks to specialized agents working concurrently with isolated context.

295.4K 206.3K
View

Applies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand colors or style guidelines, visual formatting, or company design standards apply.

179.7K 100.1K
View

Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with colors/fonts that you can apply to any artifact that has been creating, or can generate a new theme on-the-fly.

179.7K 89.5K
View

A set of resources to help me write all kinds of internal communications, using the formats that my company likes to use. Claude should use this skill whenever asked to write some sort of internal communications (status reports, leadership updates, 3P updates, company newsletters, FAQs, incident reports, project updates, etc.).

179.7K 76.1K
View

Fundamental design principles for writing maintainable, testable Python code.

40.2K 21.9K
View

Modern responsive layouts using container queries, fluid typography, CSS Grid, and mobile-first strategies.

40.2K 20K
View

Generate Playwright tests from scenarios using interactive browser exploration and validation.

39.7K 18.2K
View

Modern React state management with Redux Toolkit, Zustand, Jotai, and React Query for every state category.

40.2K 14.7K
View

GDPR-compliant data handling with consent management, data subject rights, and privacy controls.

40.2K 14.3K
View

Python error handling patterns including input validation, exception hierarchies, and partial failure handling. Use when implementing validation logic, designing exception strategies, handling batch processing failures, or building robust APIs.

40.2K 13.5K
View

Detailed multi-file refactor planning with safety checks and rollback guidance.

39.7K 13K
View