Skip to content

Commit

Permalink
Setup Storybook 📖! (#24)
Browse files Browse the repository at this point in the history
* [WIP] attempt to setup dev server

* [WIP] setup storybook! 🚀🎉 (build is broken though)

* removed ts-loader and completely rely on babel 🗿

* added .nvmrc + fix babel config + storybook config

* remove dev server and instead use storybook

* revert back generatePreview to fix import flow

* change package.json:type to module (not sure if this is a good plan though)

* fix for rollup dependency in CI

* 1.2.0

* 1.3.0
  • Loading branch information
melledijkstra authored Nov 16, 2023
1 parent c1a3f9a commit 190dd86
Show file tree
Hide file tree
Showing 14 changed files with 15,137 additions and 4,684 deletions.
4 changes: 4 additions & 0 deletions .babel.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"sourceType": "unambiguous",
"presets": ["@babel/preset-env", "@babel/preset-typescript"]
}
3 changes: 3 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,8 @@ jobs:
run: npm ci
- name: Run build
run: npm run build
- name: Install testing dependency
# fix for CI, there should be a better way to fix this
run: npm install "@rollup/rollup-linux-x64-gnu"
- name: Run unit tests
run: npm run test
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,13 @@ src/server/config.json

# unit test coverage
coverage/

# certs
*.pem
certs/

# env secrets
.env

# storybook
storybook-static/
25 changes: 25 additions & 0 deletions .storybook/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { StorybookConfig } from '@storybook/react-webpack5';
import { join, dirname } from 'path';

/**
* This function is used to resolve the absolute path of a package.
* It is needed in projects that use Yarn PnP or are set up within a monorepo.
*/
function getAbsolutePath(value: string) {
return dirname(require.resolve(join(value, 'package.json')));
}

const config: StorybookConfig = {
stories: ['../src/client/**/*.stories.@(js|jsx|mjs|ts|tsx)'],
addons: [
getAbsolutePath('@storybook/addon-links'),
getAbsolutePath('@storybook/addon-essentials'),
getAbsolutePath('@storybook/addon-onboarding'),
getAbsolutePath('@storybook/addon-interactions'),
],
framework: '@storybook/react-webpack5',
docs: {
autodocs: 'tag',
},
};
export default config;
14 changes: 14 additions & 0 deletions .storybook/preview.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/** @type { import('@storybook/react').Preview } */
const preview = {
parameters: {
actions: { argTypesRegex: '^on[A-Z].*' },
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/i,
},
},
},
};

export default preview;
Loading

0 comments on commit 190dd86

Please sign in to comment.