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

Storybook v8 publish #95

Closed
wants to merge 29 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
1907572
Storybook changes for v8. Simplifying package.json
garethfoote May 13, 2024
0b3e21e
Corrected config
garethfoote May 13, 2024
d83e461
Hearless accessibility tests
garethfoote May 13, 2024
5286251
Prettier fixes
garethfoote May 30, 2024
07567d8
stylelint fixes
garethfoote May 30, 2024
3f35da6
es link fixes
garethfoote May 30, 2024
630b820
ESlint fixes
garethfoote May 30, 2024
2d3539a
ESlint fix
garethfoote May 30, 2024
06371ba
eslint fixes
garethfoote May 30, 2024
291876b
eslint fixes
garethfoote May 30, 2024
0d52fd5
Prettier
garethfoote May 30, 2024
8f7277a
ESLint, prettier and stylelint + TS
garethfoote May 30, 2024
554b2d2
eslint fix
garethfoote Jun 3, 2024
c0f136e
Jest and babel config
garethfoote Jun 3, 2024
a64d200
Fixed unit tests and linted
garethfoote Jun 3, 2024
8614c1a
Script compilation config
garethfoote Jun 3, 2024
c8d41c1
Fix unit tests
garethfoote Jun 3, 2024
b21e611
More unit test fixing
garethfoote Jun 3, 2024
8c06e1b
Code formatting
garethfoote Jun 3, 2024
207a20d
Script naming
garethfoote Jun 3, 2024
261cf4c
Node version for github actions tests
garethfoote Jun 3, 2024
163db96
Missing nunjucks dependency
garethfoote Jun 3, 2024
605b1f9
Organised github workflow and actions
garethfoote Jun 3, 2024
9ecff3e
Not supporting IE11
garethfoote Jun 3, 2024
b9be0f7
Redundant config
garethfoote Jun 3, 2024
415c63d
Removing comments
garethfoote Jun 3, 2024
a94dad0
Changed sass includes so each component exports a sass file
garethfoote Jun 4, 2024
b78ed6e
Github pages build config
garethfoote Jun 4, 2024
0584acb
Prettifying
garethfoote Jun 4, 2024
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: 10 additions & 0 deletions .browserslistrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# https://github.com/alphagov/govuk-frontend/blob/main/packages/govuk-frontend/.browserslistrc

> 0.1% in GB and not dead
last 6 Chrome versions
last 6 Firefox versions
last 6 Edge versions
last 2 Samsung versions
Firefox ESR
Safari >= 11
iOS >= 11
20 changes: 0 additions & 20 deletions .eslintrc.json

This file was deleted.

18 changes: 18 additions & 0 deletions .github/actions/lint/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Lint

on:
workflow_call:

runs:
using: "composite"
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: .nvmrc
- name: Install dependencies
run: npm ci
shell: bash
- name: Lint
run: npm run test:lint
shell: bash
33 changes: 33 additions & 0 deletions .github/actions/storybook-tests/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Tests

on:
workflow_call:

runs:
using: "composite"
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: .nvmrc
- name: Install dependencies
run: npm ci
shell: bash
- name: Build Storybook
run: npm run build:storybook:tests
shell: bash
- name: Start Storybook
run: npm run start:storybook &
shell: bash
- name: Install Playwright
run: npx playwright install
shell: bash
- uses: nev7n/wait_for_response@v1
with:
url: "http://localhost:6006"
responseCode: 200
timeout: 30000
interval: 500
- name: Run Storybook tests
run: npm run test:storybook
shell: bash
18 changes: 18 additions & 0 deletions .github/actions/tests/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Tests

on:
workflow_call:

runs:
using: "composite"
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: .nvmrc
- name: Install dependencies
run: npm ci
shell: bash
- name: Run unit tests
run: npm run test:unit
shell: bash
10 changes: 5 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: "16.x"
node-version-file: .nvmrc
- name: Install dependencies
run: yarn
run: npm ci
- name: Build Storybook
run: |
yarn sass-compile
yarn build-storybook --quiet
npm run compile:sass
npm run build:storybook --quiet
- name: Deploy 🚀
uses: JamesIves/github-pages-deploy-action@v4
with:
folder: storybook-static # The folder the action should deploy.
folder: storybook # The folder the action should deploy.
50 changes: 25 additions & 25 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,34 +5,34 @@ on:
branches-ignore:
- main
- release-*
paths-ignore:
- 'CHANGELOG.md'
- 'LICENCE'
- 'README.md'

permissions:
id-token: write
contents: read


jobs:
unit-tests:
uses: nationalarchives/tdr-github-actions/.github/workflows/tdr_test.yml@main
with:
repo-name: tdr-components
test-command: |
npm ci
npm t
secrets:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
interaction-and-accessibility:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: "16.x"
- name: Install dependencies
run: yarn
- name: Install Playwright
run: npx playwright install --with-deps
- name: Build Storybook
run: yarn build-storybook
- name: Serve Storybook and run tests
run: |
npx concurrently -k -s first -n "SB,TEST" -c "magenta,blue" \
"npx http-server storybook-static --port 6006 --silent" \
"npx wait-on tcp:6006 && yarn test-storybook"
- uses: actions/checkout@v4
- name: Lint
uses: ./.github/actions/lint

unit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Tests
uses: ./.github/actions/tests

storybook-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Tests
uses: ./.github/actions/storybook-tests
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
lts/iron
56 changes: 34 additions & 22 deletions .storybook/main.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,35 @@
const path = require("path");

module.exports = {
/** @type { import('@storybook/html-webpack5').StorybookConfig } */
const config = {
stories: [
"../src/**/*.mdx",
"../src/**/*.stories.@(js|jsx|ts|tsx)"
],
addons: [
"@chromatic-com/storybook",
"@storybook/addon-webpack5-compiler-babel",
"@storybook/addon-links",
"@storybook/addon-essentials",
"@storybook/addon-a11y",
"@storybook/addon-interactions",
],
framework: {
name: "@storybook/html-webpack5",
options: {},
},
staticDirs: ["../public", "../assets"],
features: {
interactionsDebugger: true,
buildStoriesJson: true,
},
typescript: {
check: false,
checkOptions: {},
skipCompiler: false,
},
webpackFinal: (config) => {
// Override browserslist settings here
// config.target = ["web", "es5"];

config.module.rules.push({
test: /\.njk$/,
use: "simple-nunjucks-loader",
Expand Down Expand Up @@ -31,24 +59,8 @@ module.exports = {

return config;
},
stories: [
"../src/**/*.stories.mdx",
"../src/**/*.stories.@(js|jsx|ts|tsx)",
"../src/nationalarchives/components/**/*.stories.@(js|jsx|ts|tsx)",
],
addons: [
"@storybook/addon-links",
"@storybook/addon-essentials",
"@storybook/addon-interactions",
"@storybook/addon-a11y",
],
framework: "@storybook/html",
core: {
builder: "@storybook/builder-webpack5",
docs: {
autodocs: "tag",
},
features: {
interactionsDebugger: true,
buildStoriesJson: true,
},
staticDirs: ["../public", "../assets"],
};
export default config;
2 changes: 1 addition & 1 deletion .storybook/preview-head.html
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
<!-- .storybook/preview-head.html -->
<link rel="stylesheet" media="screen" href="./govuk.css">
<link rel="stylesheet" media="screen" href="./govuk.css" />
15 changes: 12 additions & 3 deletions .storybook/preview.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
export const parameters = {
controls: {
expanded: true,
/** @type { import('@storybook/html').Preview } */
const preview = {
parameters: {
controls: {
expanded: true,
matchers: {
color: /(background|color)$/i,
date: /Date$/i,
},
},
},
};

export default preview;
9 changes: 4 additions & 5 deletions .storybook/test-runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@ const { injectAxe, checkA11y, configureAxe } = require("axe-playwright");
* to learn more about the test-runner hooks API.
*/
module.exports = {
async preRender(page) {
async preVisit(page) {
await injectAxe(page);
},
async postRender(page, context) {
// https://github.com/storybookjs/test-runner#getstorycontext
// Get entire context of a story, including parameters, args, argTypes, etc.
async postVisit(page, context) {
// Get the entire context of a story, including parameters, args, argTypes, etc.
const storyContext = await getStoryContext(page, context);

// Do not test a11y for stories that disable a11y
Expand All @@ -24,7 +23,7 @@ module.exports = {
rules: storyContext.parameters?.a11y?.config?.rules,
});

await checkA11y(page, "#root", {
await checkA11y(page, '#storybook-root', {
detailedReport: true,
detailedReportOptions: {
html: true,
Expand Down
1 change: 0 additions & 1 deletion .stylelintrc.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"extends": "stylelint-config-standard-scss",
"rules": {
"max-line-length": 170,
"selector-class-pattern": null,
"no-descending-specificity": null
}
Expand Down
5 changes: 5 additions & 0 deletions babel.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"sourceType": "unambiguous",
"presets": ["@babel/preset-env", "@babel/preset-typescript"],
"plugins": []
}
8 changes: 8 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const eslintConfigLove = require('eslint-config-love');

module.exports = [
{
...eslintConfigLove,
files: [ 'src/**/*.ts' ]
}
]
18 changes: 18 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@


/** @type {import('jest').Config} */
const config = {
clearMocks: true,
testEnvironment: "jsdom",
testMatch: [
"**/components/*/template.test.ts",
"**/components/*/*unit.test.ts",
"!package/**",
],
transform: {
"^.+\\.ts?$": "babel-jest",
},
modulePathIgnorePatterns: ["<rootDir>/package"],
};

module.exports = config;
19 changes: 0 additions & 19 deletions jest.config.ts

This file was deleted.

Loading
Loading