Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@ node_modules
# Build Output
dist
*.tsbuildinfo

*storybook.log
storybook-static
385 changes: 384 additions & 1 deletion bun.lock

Large diffs are not rendered by default.

8 changes: 7 additions & 1 deletion docs/developer_readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,10 @@ Userのデータは`User`クラスを使用して扱います。Userのデータ
"source.organizeImports.biome": "always"
}
}
```
```

## Storybookの使用
```bash
bun run storybook
```
- localhost:6006にStorybookが立ち上がるので、そこでUIを確認してください。
24 changes: 24 additions & 0 deletions packages/web/.storybook/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { dirname, join } from "node:path";
import type { StorybookConfig } from "@storybook/react-vite";

/**
* 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): string {
return dirname(require.resolve(join(value, "package.json")));
}
const config: StorybookConfig = {
stories: ["../src/**/*.mdx", "../src/**/*.stories.@(js|jsx|mjs|ts|tsx)"],
addons: [
getAbsolutePath("@storybook/addon-links"),
getAbsolutePath("@storybook/addon-essentials"),
getAbsolutePath("@storybook/addon-onboarding"),
getAbsolutePath("@storybook/addon-interactions"),
],
framework: {
name: getAbsolutePath("@storybook/react-vite"),
options: {},
},
};
export default config;
14 changes: 14 additions & 0 deletions packages/web/.storybook/preview.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import type { Preview } from "@storybook/react-vite";

const preview: Preview = {
parameters: {
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/i,
},
},
},
};

export default preview;
13 changes: 12 additions & 1 deletion packages/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
"dev": "vite",
"build": "tsc && vite build",
"preview": "vite preview",
"check": "tsc --noEmit"
"check": "tsc --noEmit",
"storybook": "storybook dev -p 6006",
"build-storybook": "storybook build"
},
"dependencies": {
"@elysiajs/eden": "^1.3.2",
Expand All @@ -22,12 +24,21 @@
"react-router-dom": "^7.1.1"
},
"devDependencies": {
"@storybook/addon-essentials": "^8.6.14",
"@storybook/addon-interactions": "^8.6.14",
"@storybook/addon-links": "^8.6.14",
"@storybook/addon-onboarding": "^8.6.14",
"@storybook/blocks": "^8.6.14",
"@storybook/react": "^8.6.14",
"@storybook/react-vite": "^8.6.14",
"@storybook/test": "^8.6.14",
"@tailwindcss/postcss": "^4.1.11",
"@types/react": "^19.0.5",
"@types/react-dom": "^19.0.5",
"@vitejs/plugin-react": "^4.3.4",
"daisyui": "^5.0.46",
"postcss": "^8.5.6",
"storybook": "^8.0.9",
"tailwindcss": "^4.1.11",
"typescript": "^5.8.3",
"vite": "^6.0.7"
Expand Down
54 changes: 54 additions & 0 deletions packages/web/src/stories/Button.stories.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import type { Meta, StoryObj } from "@storybook/react";

import { fn } from "@storybook/test";

import { Button } from "./Button.tsx";

// More on how to set up stories at: https://storybook.js.org/docs/writing-stories#default-export
const meta = {
title: "Example/Button",
component: Button,
parameters: {
// Optional parameter to center the component in the Canvas. More info: https://storybook.js.org/docs/configure/story-layout
layout: "centered",
},
// This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs
tags: ["autodocs"],
// More on argTypes: https://storybook.js.org/docs/api/argtypes
argTypes: {
backgroundColor: { control: "color" },
},
// Use `fn` to spy on the onClick arg, which will appear in the actions panel once invoked: https://storybook.js.org/docs/essentials/actions#action-args
args: { onClick: fn() },
} satisfies Meta<typeof Button>;

export default meta;
type Story = StoryObj<typeof meta>;

// More on writing stories with args: https://storybook.js.org/docs/writing-stories/args
export const Primary: Story = {
args: {
primary: true,
label: "Button",
},
};

export const Secondary: Story = {
args: {
label: "Button",
},
};

export const Large: Story = {
args: {
size: "large",
label: "Button",
},
};

export const Small: Story = {
args: {
size: "small",
label: "Button",
},
};
39 changes: 39 additions & 0 deletions packages/web/src/stories/Button.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import "./button.css";

export interface ButtonProps {
/** Is this the principal call to action on the page? */
primary?: boolean;
/** What background color to use */
backgroundColor?: string;
/** How large should the button be? */
size?: "small" | "medium" | "large";
/** Button contents */
label: string;
/** Optional click handler */
onClick?: () => void;
}

/** Primary UI component for user interaction */
export const Button = ({
primary = false,
size = "medium",
backgroundColor,
label,
...props
}: ButtonProps) => {
const mode = primary
? "storybook-button--primary"
: "storybook-button--secondary";
return (
<button
type="button"
className={["storybook-button", `storybook-button--${size}`, mode].join(
" ",
)}
style={{ backgroundColor }}
{...props}
>
{label}
</button>
);
};
Loading