Skip to content

Commit

Permalink
chore: setup design system playground
Browse files Browse the repository at this point in the history
  • Loading branch information
hussedev committed Oct 14, 2024
1 parent be11887 commit 6986a94
Show file tree
Hide file tree
Showing 60 changed files with 11,281 additions and 0 deletions.
18 changes: 18 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
module.exports = {
root: true,
env: { browser: true, es2020: true },
extends: [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:react-hooks/recommended",
"plugin:storybook/recommended",
"plugin:tailwindcss/recommended",
"prettier",
],
ignorePatterns: ["dist", ".eslintrc.cjs"],
parser: "@typescript-eslint/parser",
plugins: ["react-refresh"],
rules: {
"react-refresh/only-export-components": ["warn", { allowConstantExport: true }],
},
};
39 changes: 39 additions & 0 deletions .github/workflows/storybook-tests-after-deployment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Storybook Tests After Deployment
on: deployment_status # deployment_status is triggered when a deployment is created or updated, for example on vercel, and you can get the URL from there
jobs:
test:
timeout-minutes: 60
runs-on: ubuntu-latest
if: github.event.deployment_status.state == 'success'
steps:
- uses: actions/checkout@v4

- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 9
run_install: false

- uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"
cache: "pnpm"

- name: Install dependencies
run: pnpm install

- name: Cache Playwright browsers
uses: actions/cache@v4
with:
path: ~/.cache/ms-playwright
key: ${{ runner.os }}-playwright-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-playwright-
- name: Install Playwright
run: npx playwright install --with-deps

- name: Run Storybook tests
run: pnpm test
env:
TARGET_URL: "${{ github.event.deployment_status.target_url }}"
50 changes: 50 additions & 0 deletions .github/workflows/storybook-tests-on-push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: "Storybook Tests"
on: push
jobs:
test:
timeout-minutes: 60
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 9
run_install: false

- uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"
cache: "pnpm"

- name: Install dependencies
run: pnpm install

- name: Cache Playwright browsers
uses: actions/cache@v4
with:
path: ~/.cache/ms-playwright
key: ${{ runner.os }}-playwright-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-playwright-
- name: Install Playwright
run: npx playwright install --with-deps

- name: Cache Storybook build
uses: actions/cache@v4
with:
path: storybook-static
key: ${{ runner.os }}-storybook-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-storybook-
- name: Build Storybook
run: pnpm build-storybook --quiet

- 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:127.0.0.1:6006 && pnpm test-storybook"
28 changes: 28 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?


.env
storybook-static
1 change: 1 addition & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pnpm exec lint-staged
3 changes: 3 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Use pnpm for package management
package-manager=pnpm@9

1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
20
8 changes: 8 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"useTabs": false,
"singleQuote": false,
"trailingComma": "all",
"semi": true,
"printWidth": 100,
"plugins": ["prettier-plugin-tailwindcss"]
}
22 changes: 22 additions & 0 deletions .storybook/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import type { StorybookConfig } from "@storybook/react-vite";

const config: StorybookConfig = {
stories: ["../src/**/*.mdx", "../src/**/*.stories.@(js|jsx|mjs|ts|tsx)"],
addons: [
"@storybook/addon-links",
"@storybook/addon-essentials",
"@chromatic-com/storybook",
"@storybook/addon-interactions",
"@storybook/addon-themes",
"@storybook/addon-a11y",
],
framework: {
name: "@storybook/react-vite",
options: {},
},
docs: {},
core: {
disableTelemetry: true, // 👈 Used to ignore update notifications.
},
};
export default config;
38 changes: 38 additions & 0 deletions .storybook/preview.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import type { Preview } from "@storybook/react";
import { withThemeByDataAttribute } from "@storybook/addon-themes";
import { initialize, mswLoader } from "msw-storybook-addon";
import { handlers } from "../src/mocks/handlers";

initialize();

import "../src/index.css";
const preview: Preview = {
parameters: {
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/i,
},
},
msw: {
handlers,
},
},
decorators: [
withThemeByDataAttribute({
defaultTheme: "light",
themes: { light: "light", dark: "dark" },
attributeName: "data-mode",
}),
],
loaders: [mswLoader],
};

// NOTE: Example of global loaders
// export const loaders = [
// async () => ({
// userData: await fetch('/api/user').then((res) => res.json()),
// }),
// ];

export default preview;
18 changes: 18 additions & 0 deletions .storybook/test-runner.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import type { TestRunnerConfig } from "@storybook/test-runner";
import { injectAxe, checkA11y } from "axe-playwright";

const config: TestRunnerConfig = {
async preVisit(page) {
await injectAxe(page);
},
async postVisit(page) {
await checkA11y(page, "#storybook-root", {
detailedReport: true,
detailedReportOptions: {
html: true,
},
});
},
};

export default config;
16 changes: 16 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>DeSy Example</title>
</head>
<body>
<div id="root">
<p>
Please start this project by running <code>npm run storybook</code> from the command line.
</p>
</div>
</body>
</html>
78 changes: 78 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
{
"name": "desy-example",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "npm run storybook",
"test": "test-storybook",
"build": "tsc && vite build",
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"format": "prettier --write --ignore-unknown .",
"preview": "vite preview",
"storybook": "storybook dev -p 6006",
"build-storybook": "storybook build",
"prepare": "husky",
"chromatic": "chromatic"
},
"lint-staged": {
"**/*": "prettier --write --ignore-unknown"
},
"msw": {
"workerDirectory": [
"public"
]
},
"dependencies": {
"@fontsource-variable/inter": "^5.0.18",
"lucide-react": "0.368.0",
"react": "18.3.1",
"react-dom": "18.3.1"
},
"devDependencies": {
"@chromatic-com/storybook": "^2.0.2",
"@storybook/addon-a11y": "^8.3.3",
"@storybook/addon-essentials": "^8.3.3",
"@storybook/addon-interactions": "^8.3.3",
"@storybook/addon-links": "^8.3.3",
"@storybook/addon-themes": "^8.3.3",
"@storybook/blocks": "^8.3.3",
"@storybook/react": "^8.3.3",
"@storybook/react-vite": "^8.3.3",
"@storybook/test": "^8.3.3",
"@storybook/test-runner": "^0.19.1",
"@types/react": "18.3.3",
"@types/react-dom": "18.3.0",
"@typescript-eslint/eslint-plugin": "7.12.0",
"@typescript-eslint/parser": "7.12.0",
"@vitejs/plugin-react": "4.3.0",
"autoprefixer": "10.4.19",
"axe-playwright": "2.0.1",
"chromatic": "^11.10.4",
"class-variance-authority": "0.7.0",
"clsx": "2.1.1",
"concurrently": "^9.0.1",
"eslint": "8.57.0",
"eslint-config-prettier": "8.10.0",
"eslint-plugin-react-hooks": "4.6.2",
"eslint-plugin-react-refresh": "0.4.7",
"eslint-plugin-storybook": "^0.9.0",
"eslint-plugin-tailwindcss": "^3.17.4",
"http-server": "^14.1.1",
"husky": "9.0.11",
"lint-staged": "15.2.5",
"msw": "2.3.1",
"msw-storybook-addon": "^2.0.3",
"playwright": "^1.47.2",
"postcss": "8.4.38",
"prettier": "3.3.1",
"prettier-plugin-tailwindcss": "0.5.14",
"storybook": "^8.3.3",
"tailwind-merge": "^2.5.2",
"tailwindcss": "3.4.4",
"typescript": "5.4.5",
"vite": "5.2.12",
"vitest": "1.6.0",
"wait-on": "^8.0.1"
}
}
Loading

0 comments on commit 6986a94

Please sign in to comment.