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

feat(storybook): storybook 7 #2533

Merged
merged 25 commits into from
Jan 18, 2024
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
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
10 changes: 7 additions & 3 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,19 @@ name: Build and Test

on:
push:
branches: [main]
branches: [ main ]
pull_request:
branches: [main]
branches: [ main ]
workflow_dispatch:


jobs:
build-and-test:
runs-on: ubuntu-latest

strategy:
matrix:
node: ['16', '18']
node: [ '16', '18' ]

name: Node ${{ matrix.node }} tests

Expand Down Expand Up @@ -59,6 +60,9 @@ jobs:
- name: Check format
run: yarn format:check

- name: Build Storybook
run: yarn build-storybook

- name: Happo
run: yarn happo-ci
env:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy-storybook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
run: yarn install

- name: Build Storybook
run: yarn build-storybook --modern
run: yarn build-storybook

- name: Deploy 🚀
uses: JamesIves/github-pages-deploy-action@v4
Expand Down
5 changes: 4 additions & 1 deletion .happo.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ module.exports = {
},
plugins: [
// see https://github.com/happo/happo-plugin-storybook for a list of options you can pass to the plugin
happoPluginStorybook(),
happoPluginStorybook({
outputDir: 'storybook-static',
usePrebuiltPackage: true,
}),
],
}
17 changes: 12 additions & 5 deletions .storybook/main.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import type { StorybookConfig } from '@storybook/react-webpack5'

const path = require('path')

const webpackConfig = (config) => {
config.resolve.alias.uswds = path.resolve(__dirname, '../node_modules/@uswds/uswds')

config.module.rules = config.module.rules.filter(
(rule) => rule.test.toString() !== '/\\.css$/'
(rule) => rule.test && rule.test.toString() !== '/\\.css$/'
)
config.module.rules.push({
test: /\.(sa|sc|c)ss$/,
Expand Down Expand Up @@ -71,9 +73,6 @@ const webpackConfig = (config) => {
}

module.exports = {
core: {
builder: 'webpack5',
},
stories: ['../src/**/*.stories.@(ts|tsx)'],
addons: ['@storybook/addon-essentials', '@storybook/addon-a11y'],
typescript: {
Expand All @@ -87,4 +86,12 @@ module.exports = {
webpackFinal: async (config) => {
return webpackConfig(config)
},
}
framework: {
name: '@storybook/react-webpack5',
options: { strictMode: false },
},
docs: {
autodocs: 'tag',
},
staticDirs: ['./public'],
} as StorybookConfig
9 changes: 9 additions & 0 deletions .storybook/public/uswds.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions custom.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,9 @@ declare module '*.module.scss' {
const classes: { [key: string]: string }
export default classes
}

declare namespace globalThis {
interface Window {
MSStream: object
}
}
1 change: 1 addition & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ module.exports = {
testPathIgnorePatterns: ['/node_modules/', '/lib/'],
testRegex: '(/test/.*|\\.(test|spec))\\.(ts|tsx|js)$',
moduleFileExtensions: ['ts', 'tsx', 'js', 'json'],
testEnvironment: "jsdom",
moduleNameMapper: {
'^react$': '<rootDir>/node_modules/react',
'\\.svg\\?svgr$': '<rootDir>/__mocks__/svgrMock.js',
Expand Down
31 changes: 17 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
"test:watch": "jest --watch",
"test:coverage": "jest --coverage",
"test:serverside": "yarn build && node src/serverSideTest.js",
"storybook": "start-storybook -p 9009",
"storybook": "storybook dev -p 9009",
"build-storybook": "storybook build",
"build": "tsc -p tsconfig.build.json && webpack --progress",
"build:watch": "tsc -p tsconfig.build.json && webpack --watch",
"lint": "tsc && eslint --ext js,jsx,ts,tsx src && stylelint \"src/**/*.{css,scss}\"",
Expand Down Expand Up @@ -56,13 +57,12 @@
"@babel/eslint-parser": "^7.19.1",
"@babel/preset-react": "^7.10.4",
"@babel/preset-typescript": "^7.15.0",
"@storybook/addon-a11y": "^7.0.2",
"@storybook/addon-essentials": "^6.5.14",
"@storybook/addons": "^7.0.8",
"@storybook/builder-webpack5": "^6.5.14",
"@storybook/manager-webpack5": "^6.5.16",
"@storybook/react": "^6.5.16",
"@storybook/theming": "^7.0.8",
"@storybook/addon-a11y": "^7.1.1",
"@storybook/addon-essentials": "^7.1.1",
"@storybook/addons": "^7.1.1",
"@storybook/react": "^7.1.1",
"@storybook/react-webpack5": "^7.1.1",
"@storybook/theming": "^7.1.1",
"@svgr/webpack": "^8.0.1",
"@testing-library/dom": "^9.0.0",
"@testing-library/jest-dom": "^5.16.5",
Expand All @@ -74,8 +74,8 @@
"@types/react": "^17.0.0",
"@types/react-dom": "^17.0.0",
"@types/react-test-renderer": "^18.0.0",
"@typescript-eslint/eslint-plugin": "^5.40.0",
"@typescript-eslint/parser": "^5.40.0",
"@typescript-eslint/eslint-plugin": "^6.2.0",
"@typescript-eslint/parser": "^6.2.0",
"@uswds/uswds": "3.4.1",
"all-contributors-cli": "^6.24.0",
"babel-jest": "^29.4.3",
Expand All @@ -95,9 +95,10 @@
"eslint-plugin-security": "^1.4.0",
"focus-trap-react": "^8.8.1",
"fork-ts-checker-webpack-plugin": "^8.0.0",
"happo-plugin-storybook": "^3.0.0",
"happo-plugin-storybook": "^3.3.0",
"happo.io": "^8.3.1",
"jest": "^26.1.0",
"jest": "^29.6.1",
"jest-environment-jsdom": "^29.6.1",
"mini-css-extract-plugin": "^2.6.1",
"prettier": "^2.7.1",
"react": "^17.0.1",
Expand All @@ -108,6 +109,7 @@
"sass-loader": "^13.0.0",
"sass-resources-loader": "^2.0.1",
"source-map-loader": "^4.0.1",
"storybook": "^7.1.1",
"style-loader": "^3.2.1",
"stylelint": "^13.3.0",
"stylelint-config-css-modules": "^2.2.0",
Expand All @@ -116,14 +118,15 @@
"stylelint-config-sass-guidelines": "^8.0.0",
"stylelint-prettier": "^1.1.1",
"stylelint-scss": "^3.17.1",
"ts-jest": "^26.1.2",
"typescript": "^4.2.4",
"ts-jest": "^29.1.1",
"typescript": "^5.1.6",
"webpack": "^5.52.1",
"webpack-cli": "^5.0.1"
},
"resolutions": {
"loader-utils": "2.0.4",
"parse-url": "8.1.0",
"jackspeak": "2.1.1",
"json-schema": "0.4.0",
"glob-parent": "5.1.2",
"trim": "0.0.3",
Expand Down
53 changes: 28 additions & 25 deletions src/components/Footer/FooterNav/FooterNav.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,29 +44,32 @@ export const MediumFooterNav = (): React.ReactElement => (
/>
)

export const BigFooterNav = (): React.ReactElement => (
<Footer
size="big"
primary={
<FooterNav
aria-label="Footer navigation"
size="big"
links={[
['Topic', ...Array(3).fill(<a href="#">Secondary link</a>)],
[
'Topic',
<a key="2" href="#">
Secondary link that is pretty long
</a>,
...Array(2).fill(<a href="#">Secondary link</a>),
],
['Topic', ...Array(3).fill(<a href="#">Secondary link</a>)],
]}
/>
}
secondary={<></>}
/>
)
BigFooterNav.parameters = {
happo: { waitForContent: 'Secondary link that is pretty long' },
export const BigFooterNav = {
render: (): React.ReactElement => (
<Footer
size="big"
primary={
<FooterNav
aria-label="Footer navigation"
size="big"
links={[
['Topic', ...Array(3).fill(<a href="#">Secondary link</a>)],
[
'Topic',
<a key="2" href="#">
Secondary link that is pretty long
</a>,
...Array(2).fill(<a href="#">Secondary link</a>),
],
['Topic', ...Array(3).fill(<a href="#">Secondary link</a>)],
]}
/>
}
secondary={<></>}
/>
),

parameters: {
happo: { waitForContent: 'Secondary link that is pretty long' },
},
}
Loading
Loading