Skip to content

Commit

Permalink
Add storybook integration (#94)
Browse files Browse the repository at this point in the history
* Add storybook and create initial setup...

* Rename example button (to avoid name collision)

* Add some basic v3 components

* Redesign icon storybook component

* Add github pages action

* Fix linter issues and remove content param from organism/content now

* Ready to address lock conflicts

* Cleanup some example files.
  • Loading branch information
clementinelove authored Jan 20, 2025
1 parent 955905c commit 02d8b26
Show file tree
Hide file tree
Showing 46 changed files with 7,734 additions and 1,986 deletions.
1 change: 1 addition & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ module.exports = {
"standard-with-typescript",
"prettier",
"next",
"plugin:storybook/recommended"
],
overrides: [],
parserOptions: {
Expand Down
35 changes: 35 additions & 0 deletions .github/workflows/deploy-github-pages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Workflow name
name: Build and Publish Storybook to GitHub Pages

on:
# Event for the workflow to run on
push:
branches:
- 'dev' # Replace with the branch you want to deploy from

permissions:
contents: read
pages: write
id-token: write

# List of jobs
jobs:
deploy:
runs-on: ubuntu-latest
# Job steps
steps:
# Manual Checkout
- uses: actions/checkout@v4
with:
fetch-depth: 0
# Set up Node
- uses: actions/setup-node@v4
with:
node-version: '20'
#👇 Add Storybook build and deploy to GitHub Pages as a step in the workflow
- uses: bitovi/[email protected]
with:
install_command: yarn install # default: npm ci
build_command: yarn build-storybook # default: npm run build-storybook
path: storybook-static # default: dist/storybook
checkout: false # default: true
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,6 @@ dist-ssr
*.sw?

.next/

*storybook.log
/storybook-static
29 changes: 29 additions & 0 deletions .storybook/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import type { StorybookConfig } from "@storybook/nextjs";

const config: StorybookConfig = {
stories: ["../src/**/*.mdx", "../src/**/*.stories.@(js|jsx|mjs|ts|tsx)"],
addons: [
"@storybook/addon-onboarding",
"@storybook/addon-essentials",
"@chromatic-com/storybook",
"@storybook/addon-interactions",
"@storybook/addon-themes",
// "storybook-addon-pseudo-states"
],
framework: {
name: "@storybook/nextjs",
options: {},
},
staticDirs: [
"../public",
{
from: "../src/assets/fonts",
to: "src/assets/fonts"
}
],
managerHead: (head) => `
${head}
<meta name="robots" content="noindex" />
`,
};
export default config;
70 changes: 70 additions & 0 deletions .storybook/preview.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import type { Preview } from "@storybook/react";
import localFont from "next/font/local";
import "../src/app/globals.css";

import {
withThemeByClassName,
withThemeByDataAttribute,
} from "@storybook/addon-themes";

// Include font using next/font
const ppPangram = localFont({
src: [
{
path: "../src/assets/fonts/PPPangramSansRounded-Regular/PPPangramSansRounded-Regular.woff2",
weight: "400",
style: "normal",
},
{
path: "../src/assets/fonts/PPPangramSansRounded-Medium/PPPangramSansRounded-Medium.woff2",
weight: "500",
style: "normal",
},
{
path: "../src/assets/fonts/PPPangramSansRounded-Semibold/PPPangramSansRounded-Semibold.woff2",
weight: "600",
style: "normal",
},
{
path: "../src/assets/fonts/PPPangramSansRounded-Bold/PPPangramSansRounded-Bold.woff2",
weight: "700",
style: "normal",
},
],
variable: "--font-pppangram",
});

const preview: Preview = {
parameters: {
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/i,
},
},
},
decorators: [
(Story) => (
<main className={ppPangram.className}>
<Story />
</main>
),
withThemeByClassName({
themes: {
light: 'light',
dark: 'dark',
},
defaultTheme: 'light',
}),
withThemeByDataAttribute({
themes: {
light: "light",
dark: "dark",
},
defaultTheme: "light",
attributeName: "data-mode",
}),
],
};

export default preview;
11 changes: 5 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@ pnpm install
pnpm run dev
```

## TODO
## Storybook

- Blog view page -> add header image and way to go back
- Blog list page -> fix tile heights not matching
- Home fix all partner images
- Fix copy on all pages
- FAQ page for mobile
We use storybook to smooth our component testing process.

For a newer version of component (for example, a redesign of button and button states),
always create stories and component inside the `src/stories` folder.
20 changes: 17 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
"lint": "next lint",
"lint:fix": "next lint --fix",
"generate": "pnpm run generate-api-client",
"generate-api-client": "npx openapi-typescript https://causes.dev.apiv2.now-u.com/api/schema/ --output src/services/apiTypes.ts"
"generate-api-client": "npx openapi-typescript https://causes.dev.apiv2.now-u.com/api/schema/ --output src/services/apiTypes.ts",
"storybook": "storybook dev -p 6006",
"build-storybook": "storybook build"
},
"dependencies": {
"@fortawesome/fontawesome-svg-core": "^6.6.0",
Expand All @@ -21,7 +23,7 @@
"@headlessui/react": "^1.7.19",
"@heroicons/react": "^2.1.5",
"@mailchimp/mailchimp_marketing": "^3.0.80",
"@meilisearch/instant-meilisearch": "^0.21.1",
"@meilisearch/instant-meilisearch": "^0.23.0",
"@next/third-parties": "^14.2.13",
"@radix-ui/react-toast": "^1.2.1",
"@tailwindcss/typography": "^0.5.15",
Expand All @@ -42,7 +44,7 @@
"openapi-fetch": "^0.12.2",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-instantsearch": "^7.13.6",
"react-instantsearch": "^7.15.0",
"react-mobile-store-button": "^0.0.6",
"sharp": "^0.33.5",
"tailwind-merge": "^2.5.2",
Expand All @@ -52,6 +54,16 @@
"zod": "^3.23.8"
},
"devDependencies": {
"@chromatic-com/storybook": "^3.2.2",
"@storybook/addon-essentials": "^8.4.5",
"@storybook/addon-interactions": "^8.4.5",
"@storybook/addon-onboarding": "^8.4.5",
"@storybook/addon-styling-webpack": "^1.0.1",
"@storybook/addon-themes": "^8.4.5",
"@storybook/blocks": "^8.4.5",
"@storybook/nextjs": "^8.4.5",
"@storybook/react": "^8.4.5",
"@storybook/test": "^8.4.5",
"@types/gtag.js": "0.0.19",
"@types/html-to-text": "^9.0.4",
"@types/mailchimp__mailchimp_marketing": "^3.0.20",
Expand All @@ -61,8 +73,10 @@
"autoprefixer": "^10.4.20",
"eslint-config-prettier": "^9.1.0",
"eslint-config-standard-with-typescript": "^39.1.1",
"eslint-plugin-storybook": "^0.11.1",
"postcss": "^8.4.47",
"prettier": "^3.3.3",
"storybook": "^8.4.5",
"tailwindcss": "^3.4.13"
}
}
Loading

0 comments on commit 02d8b26

Please sign in to comment.