import { Meta, StoryObj } from '@storybook/react-webpack5';
import {
createSandboxStory,
globalScope,
} from '../../../.storybook/components/sandbox/SandboxEditor';
import Button from '../../Button';
import Link from '../../Link';
import PocketSurface, { type PocketVariant } from '..';
const PocketCard = ({ variant }: { variant?: PocketVariant } = {}) => (
{variant && (
{variant}
)}
Some headline text
A bit of body copy
);
/**
* ⚠️ This component is not exposed in Figma and is not intended for use by product teams freely.
*
* PocketSurface is a polymorphic container component that scopes pocket design tokens
* as CSS custom properties and applies background and text colours for the selected
* pocket palette variant.
*/
const meta: Meta = {
component: PocketSurface,
title: 'Internal/PocketSurface',
tags: ['early-access'],
argTypes: {
pocket: {
control: 'select',
options: [
'bright-blue',
'bright-orange',
'bright-pink',
'bright-yellow',
'dark-charcoal',
'dark-gold',
'dark-maroon',
'dark-purple',
],
description: 'The pocket palette variant that determines the colour scheme',
table: {
type: { summary: 'PocketVariant' },
},
},
as: {
control: 'text',
description: 'The underlying HTML element to render.',
table: {
defaultValue: { summary: '"div"' },
type: { summary: 'string' },
},
},
className: {
table: { type: { summary: 'string' } },
control: 'text',
},
id: {
table: { type: { summary: 'string' } },
control: 'text',
},
'data-testid': {
control: 'text',
table: { type: { summary: 'string' } },
},
children: {
table: { type: { summary: 'ReactNode' } },
control: false,
},
},
args: {
pocket: 'bright-blue',
as: undefined,
className: undefined,
id: undefined,
'data-testid': undefined,
children: 'This is a pocket surface',
},
};
export default meta;
type Story = StoryObj;
/**
* The Playground story allows you to experiment with all the props of the PocketSurface component.
* Use the controls below to customise the pocket variant and content.
*/
export const Playground: Story = {
args: {
pocket: 'bright-blue',
children: ,
},
parameters: {
docs: {
source: {
code: `
Content that inherits pocket palette colours
`,
},
},
},
};
export const Sandbox = createSandboxStory({
code: `
This text and its inline links use pocket-matched colour.
`,
scope: { ...globalScope, Link, PocketSurface },
});
const variants: PocketVariant[] = [
'bright-blue',
'bright-orange',
'bright-pink',
'bright-yellow',
'dark-charcoal',
'dark-gold',
'dark-maroon',
'dark-purple',
];
/**
* All 8 pocket palette variants, each applying its own background and text colours via
* CSS custom properties scoped to the `.wds-pocket-{variant}` class.
*/
export const Variants: Story = {
render: () => (
{variants.map((variant) => (
))}
),
parameters: {
controls: { disable: true },
},
};
const tokenCategories = [
{
name: 'Content',
tokens: [
'--color-content-primary',
'--color-content-secondary',
'--color-content-link',
'--color-content-link-hover',
'--color-content-link-active',
],
},
{
name: 'Interactive',
tokens: [
'--color-interactive-primary',
'--color-interactive-primary-hover',
'--color-interactive-primary-active',
'--color-interactive-accent',
'--color-interactive-accent-hover',
'--color-interactive-accent-active',
'--color-interactive-control',
'--color-interactive-control-hover',
'--color-interactive-control-active',
],
},
{
name: 'Background',
tokens: ['--color-background-screen'],
},
];
const TokenSwatch = ({ token }: { token: string }) => (
);
/**
* All exposed CSS custom properties for each pocket variant.
*/
export const ExposedTokens: Story = {
render: () => (
{variants.map((variant) => (
{variant}
{tokenCategories.map((category) => (
{category.name}
{category.tokens.map((token) => (
))}
))}
))}
),
parameters: {
controls: { disable: true },
docs: {
canvas: { sourceState: 'hidden' },
},
},
decorators: [
(Story: () => JSX.Element) => (
),
],
};