Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .storybook/preview.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,27 @@
* into the published library. The published library is pure CSS Modules
* with hashed class names — see Decision D9. */

/* Design-system base typography for the story canvas.
*
* Pharos components set their own `font-family`, but raw markup in a story
* (a bare `<label>`, prose) and any element that only inherits font fell back
* to Storybook's DEFAULT base — so Chromatic snapshotted that text in the
* wrong typeface. Per the DS contract (D8/D9) the *consumer* provides the base
* typography; this makes the canvas render like a real consumer whose app sets
* the DS type (e.g. examples/saas-demo). Scoped to `#storybook-root` (canvas)
* so docs pages (`#storybook-docs`) keep their own typography.
*
* DELIBERATE re-baseline: this shifts the inherited text (and its color) of
* every component snapshot to the DS type — ~50 Chromatic changes to accept
* knowingly (typography/color only, no behaviour). The webfonts load in
* preview.ts. */
#storybook-root {
font-family: var(--pharos-font-family-sans);
font-size: var(--pharos-font-size-sm);
line-height: 1.43;
color: var(--pharos-color-neutral-900);
}

.storybook-matrix {
display: grid;
grid-template-columns: auto repeat(3, auto);
Expand Down
18 changes: 3 additions & 15 deletions src/components/Checkbox.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,9 @@ import { Checkbox } from './Checkbox';
const meta: Meta<typeof Checkbox> = {
title: 'Components/Checkbox',
component: Checkbox,
// Give the stories the DS base typography so the raw <label> text renders in
// Outfit — a real consumer's app sets this as its base. Scoped to this meta
// (not the global story root) so it never re-bases other components' stories.
decorators: [
(Story) => (
<div
style={{
fontFamily: 'var(--pharos-font-family-sans)',
fontSize: 'var(--pharos-font-size-sm)',
}}
>
<Story />
</div>
),
],
// The raw <label> text now inherits the DS base typography from the story
// canvas (#storybook-root, set in preview.css) — no per-story decorator
// needed.
};

export default meta;
Expand Down
Loading