Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

USWDS-Next - Storybook: Add initial implementation #14

Merged
merged 19 commits into from
Jun 14, 2024
Merged
Show file tree
Hide file tree
Changes from 18 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
2 changes: 2 additions & 0 deletions web-components/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,5 @@ dist-ssr
*.njsproj
*.sln
*.sw?

*storybook.log
10 changes: 10 additions & 0 deletions web-components/.storybook/UswdsTheme.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { create } from '@storybook/theming/create';

export default create({
base: 'light',
brandTitle: "USWDS Next",
fontBase: '"Public Sans Web", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"',
colorPrimary: '#4a77b4',
colorSecondary: '#2672de',
textColor: '#1b1b1b',
});
5 changes: 5 additions & 0 deletions web-components/.storybook/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
:where(p:not(.sb-anchor, .sb-unstyled, .sb-unstyled p)),
:where(li:not(.sb-anchor, .sb-unstyled, .sb-unstyled li)) {
font-size: 22px !important;
line-height: 1.4 !important;
}
17 changes: 17 additions & 0 deletions web-components/.storybook/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/** @type { import('@storybook/web-components-vite').StorybookConfig } */
const config = {
stories: [
"../src/**/*.mdx",
"../src/components/**/*.stories.@(js|jsx|mjs|ts|tsx)",
],
addons: [
"@storybook/addon-links",
"@storybook/addon-essentials",
"@chromatic-com/storybook",
],
framework: {
name: "@storybook/web-components-vite",
options: {},
},
};
export default config;
6 changes: 6 additions & 0 deletions web-components/.storybook/manager.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { addons } from '@storybook/manager-api';
import UswdsTheme from './UswdsTheme';

addons.setConfig({
theme: UswdsTheme,
});
29 changes: 29 additions & 0 deletions web-components/.storybook/preview.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import UswdsTheme from "./UswdsTheme";

// Global component styles.
import "../src/index.css";
// Theme overrides.
import "./index.css";


/** @type { import('@storybook/web-components').Preview } */
const preview = {
parameters: {
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/i,
},
},
docs: {
toc: true, // Autogenerate table of contents.
theme: UswdsTheme,
canvas: {
sourceState: 'shown'
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note

Not a blocker, but indentation can be off in some previews. There's a workaround in this issue DocsPage code preview indentation is wrong · Issue #8078 · storybookjs/storybook.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI, I got this working on the MD WDS project I'm working on!

Here are my notes on the workaround:
storybookjs/storybook#8078 (comment)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@caseywatts thanks for sharing. Created an issue to give this a try 😄

}
}
},
tags: ['autodocs'],
};

export default preview;
Loading
Loading