Skip to content

Commit

Permalink
feat: storybook7 mdx2+csf3
Browse files Browse the repository at this point in the history
  • Loading branch information
liyouzhi committed Jul 12, 2023
1 parent 31bc5af commit a6fbc94
Show file tree
Hide file tree
Showing 328 changed files with 33,071 additions and 18,315 deletions.
34 changes: 2 additions & 32 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "./tools/eslintrc/index.js",
"extends": "@1stg/eslint-config/loose",
"parserOptions": {
"requireConfigFile": false
},
Expand Down Expand Up @@ -50,36 +50,6 @@
"@angular-eslint/no-input-rename": "off",
"@angular-eslint/no-output-rename": "off",
"@angular-eslint/no-host-metadata-property": "off",
"@typescript-eslint/no-unsafe-argument": "off",
"@angular-eslint/template/eqeqeq": 0,
"@angular-eslint/template/no-negated-async": 0,
"@typescript-eslint/member-ordering": 0,
"@typescript-eslint/naming-convention": 0,
"@typescript-eslint/no-explicit-any": 0,
"@typescript-eslint/no-floating-promises": 0,
"@typescript-eslint/no-magic-numbers": 0,
"@typescript-eslint/no-type-alias": 0,
"@typescript-eslint/no-unnecessary-condition": 0,
"@typescript-eslint/no-unsafe-assignment": 0,
"@typescript-eslint/no-unsafe-member-access": 0,
"@typescript-eslint/no-unsafe-return": 0,
"@typescript-eslint/prefer-ts-expect-error": 0,
"@typescript-eslint/restrict-plus-operands": 0,
"@typescript-eslint/sort-type-union-intersection-members": 0,
"@typescript-eslint/unbound-method": 0,
"@typescript-eslint/no-inferrable-types": 0,
"regexp/optimal-quantifier-concatenation": 1,
"arrow-body-style": 0,
"accessor-pairs": 0,
"no-magic-numbers": 0,
"no-negated-condition": 0,
"promise/always-return": 0,
"promise/catch-or-return": 0,
"unicorn/explicit-length-check": 0,
"unicorn/no-array-for-each": 0,
"unicorn/no-fn-reference-in-iterator": 0,
"unicorn/prefer-number-properties": 0,
"unicorn/prefer-prototype-methods": 0,
"unicorn/prefer-spread": 0
"@typescript-eslint/no-unsafe-argument": "off"
}
}
44 changes: 15 additions & 29 deletions .storybook/main.ts
Original file line number Diff line number Diff line change
@@ -1,43 +1,29 @@
import type { StorybookConfig } from "@storybook/angular";
import type { StorybookConfig } from '@storybook/angular';
import remarkGfm from 'remark-gfm';

const config: StorybookConfig = {
core: {},
stories: [
'../stories/**/index.@(js|ts)',
'../stories/**/*.stories.@(js|ts|mdx)',
],
stories: ['../stories/**/*.mdx', '../stories/**/*.stories.@(js|jsx|ts|tsx)'],
addons: [
'@storybook/addon-docs',
'@storybook/addon-knobs',
'@storybook/addon-actions',
'@storybook/addon-storysource',
'storybook-dark-mode',
],
webpackFinal(config) {
config.module.rules.push({
test: /\.stories\.tsx?$/,
use: [
{
loader: require.resolve('@storybook/source-loader'),
options: {
parser: 'typescript',
'@storybook/addon-links',
'@storybook/addon-essentials',
'@storybook/addon-interactions',
{
name: '@storybook/addon-docs',
options: {
mdxPluginOptions: {
mdxCompileOptions: {
remarkPlugins: [remarkGfm],
},
},
],
enforce: 'pre',
});
return config;
},
},
},
],
framework: {
name: '@storybook/angular',
options: {},
},
docs: {
autodocs: true,
},
features: {
legacyMdx1: true, // Enables MDX v1 support
storyStoreV7: false, // Opt out of on-demand story loading
},
};
export default config;
20 changes: 20 additions & 0 deletions .storybook/preview.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import { setCompodocJson } from '@storybook/addon-docs/angular';
import { addons } from '@storybook/addons';
import type { Preview } from '@storybook/angular';

import docJson from '../documentation.json';

setCompodocJson(docJson);

const channel = addons.getChannel();

Expand All @@ -7,3 +13,17 @@ channel.addListener('DARK_MODE', isDark => {
.querySelector('html')
.setAttribute('aui-theme-mode', isDark ? 'dark' : 'light');
});

const preview: Preview = {
parameters: {
actions: { argTypesRegex: '^on[A-Z].*' },
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/,
},
},
},
};

export default preview;
9 changes: 8 additions & 1 deletion .storybook/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
{
"extends": "../tsconfig",
"include": ["./*.ts", "../stories"]
"compilerOptions": {
"types": ["node"],
"allowSyntheticDefaultImports": true,
"resolveJsonModule": true
},
"exclude": ["../stories/test.ts", "../stories/**/*.spec.ts"],
"include": ["../stories/**/*", "./preview.ts"],
"files": ["./typings.d.ts"]
}
4 changes: 4 additions & 0 deletions .storybook/typings.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
declare module '*.md' {
const content: string;
export default content;
}
14 changes: 6 additions & 8 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,22 +62,20 @@
"options": {
"configDir": ".storybook",
"browserTarget": "storybook:build",
"compodoc": false,
"compodoc": true,
"compodocArgs": ["-e", "json", "-d", "."],
"port": 6006
},
"compodoc": true,
"compodocArgs": ["-e", "json", "-d", "."]
}
},
"build-storybook": {
"builder": "@storybook/angular:build-storybook",
"options": {
"configDir": ".storybook",
"browserTarget": "storybook:build",
"compodoc": false,
"compodoc": true,
"compodocArgs": ["-e", "json", "-d", "."],
"outputDir": "dist"
},
"compodoc": true,
"compodocArgs": ["-e", "json", "-d", "."]
}
}
}
}
Expand Down
Loading

0 comments on commit a6fbc94

Please sign in to comment.