Skip to content

Commit

Permalink
chore: setup storybook
Browse files Browse the repository at this point in the history
  • Loading branch information
Markus-Ende committed Apr 15, 2024
1 parent ce595ce commit a400b06
Show file tree
Hide file tree
Showing 9 changed files with 107 additions and 3 deletions.
2 changes: 1 addition & 1 deletion libs/sketch/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"extends": ["../../.eslintrc.json"],
"ignorePatterns": ["!**/*"],
"ignorePatterns": ["!**/*", "storybook-static"],
"overrides": [
{
"files": ["*.ts"],
Expand Down
16 changes: 16 additions & 0 deletions libs/sketch/.storybook/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import type { StorybookConfig } from '@storybook/angular';

const config: StorybookConfig = {
stories: ['../**/*.stories.@(js|jsx|ts|tsx|mdx)'],
addons: ['@storybook/addon-essentials'],
framework: {
name: '@storybook/angular',
options: {},
},
};

export default config;

// To customize your webpack configuration you can use the webpackFinal field.
// Check https://storybook.js.org/docs/react/builders/webpack#extending-storybooks-webpack-config
// and https://nx.dev/recipes/storybook/custom-builder-configs
Empty file.
16 changes: 16 additions & 0 deletions libs/sketch/.storybook/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"emitDecoratorMetadata": true
},
"exclude": ["../**/*.spec.ts"],
"include": [
"../src/**/*.stories.ts",
"../src/**/*.stories.js",
"../src/**/*.stories.jsx",
"../src/**/*.stories.tsx",
"../src/**/*.stories.mdx",
"*.js",
"*.ts"
]
}
42 changes: 42 additions & 0 deletions libs/sketch/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,48 @@
},
"lint": {
"executor": "@nx/eslint:lint"
},
"storybook": {
"executor": "@storybook/angular:start-storybook",
"options": {
"port": 4400,
"configDir": "libs/sketch/.storybook",
"browserTarget": "sketch:build-storybook",
"compodoc": false
},
"configurations": {
"ci": {
"quiet": true
}
}
},
"build-storybook": {
"executor": "@storybook/angular:build-storybook",
"outputs": ["{options.outputDir}"],
"options": {
"outputDir": "dist/storybook/sketch",
"configDir": "libs/sketch/.storybook",
"browserTarget": "sketch:build-storybook",
"compodoc": false
},
"configurations": {
"ci": {
"quiet": true
}
}
},
"static-storybook": {
"executor": "@nx/web:file-server",
"options": {
"buildTarget": "sketch:build-storybook",
"staticFilePath": "dist/storybook/sketch",
"spa": true
},
"configurations": {
"ci": {
"buildTarget": "sketch:build-storybook:ci"
}
}
}
}
}
13 changes: 13 additions & 0 deletions libs/sketch/src/lib/sketch/sketch.component.stories.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import type { Meta, StoryObj } from '@storybook/angular';
import { SketchComponent } from './sketch.component';

const meta: Meta<SketchComponent> = {
component: SketchComponent,
title: 'SketchComponent',
};
export default meta;
type Story = StoryObj<SketchComponent>;

export const Primary: Story = {
args: {},
};
3 changes: 3 additions & 0 deletions libs/sketch/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
},
{
"path": "./tsconfig.spec.json"
},
{
"path": "./.storybook/tsconfig.json"
}
],
"extends": "../../tsconfig.base.json",
Expand Down
4 changes: 3 additions & 1 deletion libs/sketch/tsconfig.lib.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
"src/**/*.spec.ts",
"src/test-setup.ts",
"jest.config.ts",
"src/**/*.test.ts"
"src/**/*.test.ts",
"**/*.stories.ts",
"**/*.stories.js"
],
"include": ["src/**/*.ts"]
}
14 changes: 13 additions & 1 deletion nx.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@
"!{projectRoot}/tsconfig.spec.json",
"!{projectRoot}/jest.config.[jt]s",
"!{projectRoot}/src/test-setup.[jt]s",
"!{projectRoot}/test-setup.[jt]s"
"!{projectRoot}/test-setup.[jt]s",
"!{projectRoot}/**/*.stories.@(js|jsx|ts|tsx|mdx)",
"!{projectRoot}/.storybook/**/*",
"!{projectRoot}/tsconfig.storybook.json"
],
"sharedGlobals": []
},
Expand Down Expand Up @@ -46,6 +49,15 @@
"cache": true,
"dependsOn": ["^build"],
"inputs": ["production", "^production"]
},
"build-storybook": {
"cache": true,
"inputs": [
"default",
"^production",
"{projectRoot}/.storybook/**/*",
"{projectRoot}/tsconfig.storybook.json"
]
}
},
"plugins": [
Expand Down

0 comments on commit a400b06

Please sign in to comment.