Skip to content

Commit fcd54d9

Browse files
authored
Merge pull request #151 from rcaferati/feat/v8
Implemented v8
2 parents c24c8a2 + 874f425 commit fcd54d9

61 files changed

Lines changed: 7539 additions & 10311 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.eslintrc.json

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
11
{
22
"parser": "babel-eslint",
3-
"extends": ["airbnb", "prettier"],
3+
"extends": [
4+
"airbnb",
5+
"prettier",
6+
"plugin:storybook/recommended"
7+
],
48
"env": {
59
"browser": true,
610
"node": true,
711
"jest": true,
812
"es6": true
913
},
10-
"plugins": ["react", "jsx-a11y"],
14+
"plugins": [
15+
"react",
16+
"jsx-a11y"
17+
],
1118
"parserOptions": {
1219
"ecmaVersion": 6,
1320
"sourceType": "module",
@@ -35,4 +42,4 @@
3542
"jsx-a11y/click-events-have-key-events": 0,
3643
"import/no-extraneous-dependencies": 0
3744
}
38-
}
45+
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Deploy Storybook to GitHub Pages
2+
3+
on:
4+
push:
5+
branches: [main]
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: read
10+
pages: write
11+
id-token: write
12+
13+
concurrency:
14+
group: 'pages'
15+
cancel-in-progress: true
16+
17+
jobs:
18+
build:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: Checkout
22+
uses: actions/checkout@v4
23+
24+
- name: Setup Pages
25+
uses: actions/configure-pages@v5
26+
27+
- name: Setup Node
28+
uses: actions/setup-node@v4
29+
with:
30+
node-version: 20
31+
cache: npm
32+
33+
- name: Install deps
34+
run: npm ci
35+
36+
- name: Build Storybook
37+
run: npm run build-storybook
38+
39+
- name: Upload Pages artifact
40+
uses: actions/upload-pages-artifact@v3
41+
with:
42+
path: ./storybook-static
43+
44+
deploy:
45+
environment:
46+
name: github-pages
47+
url: ${{ steps.deployment.outputs.page_url }}
48+
runs-on: ubuntu-latest
49+
needs: build
50+
steps:
51+
- name: Deploy to GitHub Pages
52+
id: deployment
53+
uses: actions/deploy-pages@v4

.github/workflows/publish-npm.yml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Publish package to npm
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: read
11+
12+
concurrency:
13+
group: npm-publish-${{ github.ref }}
14+
cancel-in-progress: false
15+
16+
jobs:
17+
publish:
18+
runs-on: ubuntu-latest
19+
20+
# Only publish from this repository (prevents accidental runs in forks)
21+
if: github.repository == 'rcaferati/react-awesome-button'
22+
23+
steps:
24+
- name: Checkout
25+
uses: actions/checkout@v4
26+
27+
- name: Setup Node
28+
uses: actions/setup-node@v4
29+
with:
30+
node-version: 20
31+
registry-url: 'https://registry.npmjs.org'
32+
cache: npm
33+
34+
- name: Install dependencies
35+
run: npm ci
36+
37+
- name: Verify package identity
38+
run: |
39+
node -p "require('./package.json').name"
40+
node -p "require('./package.json').version"
41+
42+
- name: Run tests
43+
run: npm test -- --passWithNoTests
44+
45+
- name: Build package
46+
run: npm run build:all
47+
48+
- name: Verify tag matches package version
49+
if: startsWith(github.ref, 'refs/tags/')
50+
run: |
51+
TAG="${GITHUB_REF#refs/tags/}"
52+
PKG_VERSION="v$(node -p "require('./package.json').version")"
53+
echo "Git tag: $TAG"
54+
echo "Package version tag: $PKG_VERSION"
55+
if [ "$TAG" != "$PKG_VERSION" ]; then
56+
echo "Tag/version mismatch"
57+
exit 1
58+
fi
59+
60+
- name: Publish to npm (scoped public package)
61+
env:
62+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
63+
run: npm publish --access public

.gitignore

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,25 @@
1-
node_modules
2-
npm-debug.log
1+
# Dependencies
2+
node_modules/
3+
4+
# Logs
5+
npm-debug.log*
6+
yarn-debug.log*
7+
yarn-error.log*
8+
pnpm-debug.log*
9+
10+
# OS
311
.DS_Store
4-
dist
5-
storybook-static
12+
13+
# Build outputs
14+
dist/
15+
storybook-static/
16+
coverage/
17+
18+
# TypeScript
19+
*.tsbuildinfo
20+
21+
# Env files
22+
.env
23+
.env.*
24+
!.env.example
25+
*storybook.log

.storybook/main.js

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,35 @@
1-
module.exports = {
2-
stories: ['../src/**/*.stories.mdx', '../src/**/*.stories.@(js|jsx|ts|tsx)'],
1+
// .storybook/main.js
2+
3+
/** @type { import('@storybook/react-webpack5').StorybookConfig } */
4+
const config = {
5+
stories: ['../src/**/*.mdx', '../src/**/*.stories.@(js|jsx|mjs|ts|tsx)'],
6+
37
addons: [
4-
'@storybook/addon-links',
5-
'@storybook/addon-essentials',
6-
'@storybook/addon-interactions',
8+
'@storybook/addon-webpack5-compiler-swc',
9+
'@storybook/addon-a11y',
10+
'@storybook/addon-docs',
11+
'@storybook/addon-onboarding',
712
'@storybook/preset-scss',
813
],
9-
framework: '@storybook/react',
10-
core: {
11-
builder: '@storybook/builder-webpack5',
14+
15+
framework: '@storybook/react-webpack5',
16+
17+
webpackFinal: async (config) => {
18+
// Keep this minimal. Storybook + preset-scss already provide loaders.
19+
config.resolve ||= {};
20+
config.resolve.extensions = Array.from(
21+
new Set([
22+
...(config.resolve.extensions || []),
23+
'.ts',
24+
'.tsx',
25+
'.js',
26+
'.jsx',
27+
'.mjs',
28+
])
29+
);
30+
31+
return config;
1232
},
1333
};
34+
35+
export default config;

.storybook/preview.js

Lines changed: 41 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,43 @@
1-
export const parameters = {
2-
actions: { argTypesRegex: "^on[A-Z].*" },
3-
controls: {
4-
matchers: {
5-
color: /(background|color)$/i,
6-
date: /Date$/,
1+
// .storybook/preview.js
2+
3+
/** @type { import('@storybook/react-webpack5').Preview } */
4+
5+
// Default theme module for stories that support `cssModule` (e.g. AwesomeButton family)
6+
import themeEric from '../src/styles/themes/theme-eric';
7+
8+
const resolvedTheme = themeEric?.default || themeEric;
9+
10+
const preview = {
11+
parameters: {
12+
controls: {
13+
matchers: {
14+
color: /(background|color)$/i,
15+
date: /Date$/i,
16+
},
17+
},
18+
19+
layout: 'centered',
20+
21+
// Nice defaults for button components
22+
actions: {
23+
argTypesRegex: '^on[A-Z].*',
724
},
825
},
9-
}
26+
27+
decorators: [
28+
(Story, context) => {
29+
// Inject cssModule only when the story didn't set one explicitly.
30+
// This keeps stories lean while still allowing overrides per story.
31+
const args = context.args || {};
32+
33+
return Story({
34+
args: {
35+
...args,
36+
cssModule: args.cssModule ?? resolvedTheme,
37+
},
38+
});
39+
},
40+
],
41+
};
42+
43+
export default preview;

0 commit comments

Comments
 (0)