liuyuqi-dellpc 1 year ago
parent
commit
6618cecd92
7 changed files with 77 additions and 0 deletions
  1. 4 0
      .husky/commit-msg
  2. 4 0
      .husky/pre-commit
  3. 4 0
      .husky/pre-push
  4. 17 0
      .storybook/main.js
  5. 48 0
      .storybook/preview.js
  6. 0 0
      src/styles/Home.module.css
  7. 0 0
      src/styles/globals.css

+ 4 - 0
.husky/commit-msg

@@ -0,0 +1,4 @@
+#!/usr/bin/env sh
+. "$(dirname -- "$0")/_/husky.sh"
+
+npx --no -- commitlint --edit ""

+ 4 - 0
.husky/pre-commit

@@ -0,0 +1,4 @@
+#!/usr/bin/env sh
+. "$(dirname -- "$0")/_/husky.sh"
+
+yarn lint

+ 4 - 0
.husky/pre-push

@@ -0,0 +1,4 @@
+#!/usr/bin/env sh
+. "$(dirname -- "$0")/_/husky.sh"
+
+yarn build

+ 17 - 0
.storybook/main.js

@@ -0,0 +1,17 @@
+module.exports = {
+  "stories": [
+    "../src/**/*.stories.mdx",
+    "../src/**/*.stories.@(js|jsx|ts|tsx)"
+  ],
+  	/** 暴露 public 目录给到 stotrybook,作为静态资源目录 */
+  "staticDirs": ['../public'],
+  "addons": [
+    "@storybook/addon-links",
+    "@storybook/addon-essentials",
+    "@storybook/addon-interactions"
+  ],
+  "framework": "@storybook/react",
+  "core": {
+    "builder": "@storybook/builder-webpack5"
+  }
+}

+ 48 - 0
.storybook/preview.js

@@ -0,0 +1,48 @@
+// @ts-check
+import '../src/pages/globals.css';
+import * as NextImage from 'next/image';
+
+const BREAKPOINTS_INT = {
+  xs: 375,
+  sm: 600,
+  md: 900,
+  lg: 1200,
+  xl: 1536,
+};
+
+const customViewports = Object.fromEntries(
+  Object.entries(BREAKPOINTS_INT).map(([key, val], idx) => {
+    console.log(val);
+    return [
+      key,
+      {
+        name: key,
+        styles: {
+          width: `${val}px`,
+          height: `${(idx + 5) * 10}vh`,
+        },
+      },
+    ];
+  })
+);
+
+// Allow Storybook to handle Next's <Image> component
+const OriginalNextImage = NextImage.default;
+
+Object.defineProperty(NextImage, 'default', {
+  configurable: true,
+  value: (props) => <OriginalNextImage {...props} unoptimized />,
+});
+
+
+
+export const parameters = {
+  actions: { argTypesRegex: '^on[A-Z].*' },
+  controls: {
+    matchers: {
+      color: /(background|color)$/i,
+      date: /Date$/,
+    },
+  },
+  viewport: { viewports: customViewports },
+}

+ 0 - 0
styles/Home.module.css → src/styles/Home.module.css


+ 0 - 0
styles/globals.css → src/styles/globals.css