Skip to content

Commit 9e847e2

Browse files
author
takuma-hmng8
committed
Storybook導入
1 parent 942ca8d commit 9e847e2

Some content is hidden

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

86 files changed

+16068
-4330
lines changed

Diff for: .eslintrc.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
{
2-
"extends": "next/core-web-vitals"
2+
"extends": [
3+
"next/core-web-vitals",
4+
"plugin:storybook/recommended"
5+
]
36
}

Diff for: .gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,6 @@ yarn-error.log*
3333
# typescript
3434
*.tsbuildinfo
3535
next-env.d.ts
36+
37+
# Storybook
38+
storybook-static/

Diff for: app/_shaderFx/index.tsx renamed to .storybook/Setup.tsx

+5-13
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,11 @@
11
"use client";
2-
3-
const isDev = process.env.NODE_ENV === "development";
4-
import { Suspense, useState } from "react";
2+
import * as React from "react";
3+
import { useState } from "react";
54
import { Canvas } from "@react-three/fiber";
65
import { Perf } from "r3f-perf";
76
import { PerformanceMonitor } from "@react-three/drei";
8-
import { Demo } from "./Demo";
9-
import { CreateKit } from "./CreateKit";
10-
11-
// Create scene is rendered if develop environment and isCreate is true
12-
const isCreate = true;
137

14-
export const ShaderFx = () => {
8+
export const Setup = ({ children }: { children: React.ReactNode }) => {
159
const [dpr, setDpr] = useState(1.5);
1610
return (
1711
<Canvas dpr={dpr}>
@@ -21,10 +15,8 @@ export const ShaderFx = () => {
2115
console.log(`dpr:${dpr}`);
2216
setDpr(Math.round((0.5 + 1.5 * factor) * 10) / 10);
2317
}}>
24-
<Suspense fallback={null}>
25-
{isDev && isCreate ? <CreateKit /> : <Demo />}
26-
</Suspense>
27-
<Perf position={"bottom-right"} minimal={false} />
18+
{children}
19+
<Perf position={"bottom-left"} minimal={false} />
2820
</PerformanceMonitor>
2921
</Canvas>
3022
);

Diff for: app/_shaderFx/CreateKit/fxMaterial.tsx renamed to .storybook/fxMaterial.tsx

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
import * as THREE from "three";
2-
import vertexShader from "./shader/main.vert";
3-
import fragmentShader from "./shader/main.frag";
42
import { shaderMaterial } from "@react-three/drei";
53

64
declare global {
@@ -19,6 +17,6 @@ export const FxMaterial = shaderMaterial(
1917
{
2018
u_fx: null,
2119
},
22-
vertexShader,
23-
fragmentShader
20+
"varying vec2 vUv;void main() {vUv = uv;gl_Position = vec4(position, 1.0);}",
21+
"precision mediump float;varying vec2 vUv;uniform sampler2D u_fx;void main() {vec2 uv = vUv; gl_FragColor = texture2D(u_fx, uv);}"
2422
);

Diff for: .storybook/main.ts

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import type { StorybookConfig } from "@storybook/nextjs";
2+
3+
const config: StorybookConfig = {
4+
staticDirs: ["./public"],
5+
stories: [
6+
"./stories/**/*.mdx",
7+
"./stories/**/*.stories.@(js|jsx|mjs|ts|tsx)",
8+
],
9+
addons: [
10+
"@storybook/addon-links",
11+
"@storybook/addon-essentials",
12+
"@storybook/addon-onboarding",
13+
"@storybook/addon-interactions",
14+
],
15+
framework: {
16+
name: "@storybook/nextjs",
17+
options: {},
18+
},
19+
docs: {
20+
autodocs: "tag",
21+
},
22+
};
23+
export default config;

Diff for: .storybook/manager.ts

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { addons } from "@storybook/manager-api";
2+
import { create } from "@storybook/theming/create";
3+
4+
addons.setConfig({
5+
theme: create({
6+
base: "dark",
7+
brandImage: "/logo.svg",
8+
brandUrl: "https://github.com/takuma-hmng8/use-shader-fx",
9+
brandTitle: "use-shader-fx",
10+
brandTarget: "_blank",
11+
}),
12+
panelPosition: "right",
13+
showPanel: true,
14+
});

Diff for: .storybook/preview.tsx

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import React from "react";
2+
import type { Preview } from "@storybook/react";
3+
4+
const preview: Preview = {
5+
parameters: {
6+
layout: "fullscreen",
7+
},
8+
decorators: [
9+
(Story) => (
10+
<React.Suspense fallback={null}>
11+
<Story />
12+
</React.Suspense>
13+
),
14+
],
15+
};
16+
export default preview;

Diff for: .storybook/public/favicon.ico

86.1 KB
Binary file not shown.

Diff for: .storybook/public/logo.svg

+17
Loading

Diff for: .storybook/public/thumbnail.jpg

103 KB
Loading

0 commit comments

Comments
 (0)