Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add storybook [MDS-1442] #224

Merged
merged 14 commits into from
Dec 20, 2024
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
5 changes: 5 additions & 0 deletions .changeset/nice-falcons-invite.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"docs": minor
---

feat: add storybook [MDS-1442]
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ cache

# next.js
/docs/.next
/docs/public/stories/
/.next/
/out/

Expand Down
1 change: 1 addition & 0 deletions cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
".git",
"node_modules",
"docs/generated/changelog.ts",
"docs/public/stories/**",
".config/aws-task-definition.json",
".config/Dockerfile",
".gitignore",
Expand Down
6 changes: 5 additions & 1 deletion docs/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
{
"plugins": ["prettier"],
"extends": ["next/core-web-vitals", "prettier"]
"extends": [
"next/core-web-vitals",
"prettier",
"plugin:storybook/recommended"
]
}
20 changes: 20 additions & 0 deletions docs/.storybook/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import type { StorybookConfig } from "@storybook/nextjs";

const config: StorybookConfig = {
stories: [
"../app/stories/**/*.mdx",
"../app/stories/**/*.stories.@(js|jsx|mjs|ts|tsx)",
],
addons: [
"@storybook/addon-onboarding",
"@storybook/addon-essentials",
"@chromatic-com/storybook",
"@storybook/addon-interactions",
],
framework: {
name: "@storybook/nextjs",
options: {},
},
staticDirs: ["../public"],
};
export default config;
7 changes: 7 additions & 0 deletions docs/.storybook/preview-body.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<html>
<body
class="light-theme theme-moon-light flex items-center justify-center h-screen"
>
<div id="storybook-root"></div>
</body>
</html>
15 changes: 15 additions & 0 deletions docs/.storybook/preview.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import type { Preview } from "@storybook/react";
import "../app/globals.css";

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

export default preview;
1 change: 1 addition & 0 deletions docs/app/globals.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
@tailwind base;
@tailwind components;
@tailwind utilities;
robb91-dev marked this conversation as resolved.
Show resolved Hide resolved
robb91-dev marked this conversation as resolved.
Show resolved Hide resolved
@import "./themes.css";

/* @font-face {
font-family: 'DM Sans';
Expand Down
1 change: 0 additions & 1 deletion docs/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { SearchProvider } from "@/components/search/SearchProvider";
import { useSearchActions } from "@/components/search/useSearchActions";
import { cookies } from "next/headers";
import "./globals.css";
import "./themes.css";
import { mergeClassnames } from "@heathmont/moon-base-tw";
import GoogleAnalytics from "@/components/GoogleAnalytics";

Expand Down
15 changes: 15 additions & 0 deletions docs/app/stories/Avatar.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { Avatar as AvatarComponent } from "@heathmont/moon-core-tw";
import type { Meta, StoryObj } from "@storybook/react";

const meta: Meta<typeof AvatarComponent> = {
component: AvatarComponent,
};

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

export const Avatar: Story = {
args: {
size: "sm",
},
};
20 changes: 20 additions & 0 deletions docs/app/stories/Button.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { Button as ButtonComponent } from "@heathmont/moon-core-tw";
import type { Meta, StoryObj } from "@storybook/react";

const meta: Meta<typeof ButtonComponent> = {
component: ButtonComponent,
};

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

export const Button: Story = {
args: {
children: <span>Click me</span>,
variant: "primary",
size: "xl",
disabled: false,
fullWidth: false,
animation: "pulse",
},
};
21 changes: 21 additions & 0 deletions docs/app/stories/Chip.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { Chip as ChipComponent } from "@heathmont/moon-core-tw";

import type { Meta, StoryObj } from "@storybook/react";

const meta: Meta<typeof ChipComponent> = {
component: ChipComponent,
};

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

const args = {
isActive: true,
size: "md",
isStroke: true,
children: <span>To the moon</span>,
};

export const Chip: Story = {
args,
};
16 changes: 16 additions & 0 deletions docs/app/stories/Textarea.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { Textarea as TextareaComponent } from "@heathmont/moon-core-tw";

import type { Meta, StoryObj } from "@storybook/react";

const meta: Meta<typeof TextareaComponent> = {
component: TextareaComponent,
};

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

export const Textarea: Story = {
args: {
error: false,
},
};
5 changes: 5 additions & 0 deletions docs/app/stories/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { redirect } from "next/navigation";

export default function StoriesPage() {
redirect("/stories/index.html");
}
6 changes: 6 additions & 0 deletions docs/app/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -909,6 +909,12 @@ export type Examples = {
}
}
},
"stories": {
"Avatar.stories": "string",
"Button.stories": "string",
"Chip.stories": "string",
"Textarea.stories": "string"
},
"themes": {
"ColorSet": "string",
"MainColors": "string",
Expand Down
18 changes: 15 additions & 3 deletions docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,17 @@
"build:changelog": "node scripts/buildChangelog.mjs",
"build:installation": "node scripts/buildInstallation.mjs",
"build:contribution": "node scripts/buildContribution.mjs",
"build": "pnpm run build:types && pnpm run build:components && pnpm run build:dict && pnpm build:descriptions && pnpm build:changelog && pnpm build:installation && pnpm build:contribution && pnpm run lint:components && pnpm run lint:descriptions && pnpm run lint:changelog && next build",
"build": "pnpm run build:types && pnpm run build:components && pnpm run build:dict && pnpm build:descriptions && pnpm build:changelog && pnpm build:installation && pnpm build:contribution && pnpm build:storybook && pnpm run lint:components && pnpm run lint:descriptions && pnpm run lint:changelog && next build",
"lint": "next lint",
"lint:components": "prettier --write ./components.constants.mjs",
"lint:descriptions": "prettier --write ./generated/componentDescriptions.ts",
"lint:changelog": "prettier --write ./generated/changelog.ts",
"start": "next start -p 80",
"test": "playwright test",
"test:pa11y": "node scripts/cli/index.mjs pa11y",
"clean:next": "rimraf .next"
"clean:next": "rimraf .next",
"storybook": "storybook dev -p 6006",
"build:storybook": "storybook build -o .storybook/temp-dist && rm -rf public/stories && mv .storybook/temp-dist public/stories"
},
"dependencies": {
"@heathmont/moon-base-tw": "workspace:^10.18.1",
Expand All @@ -33,15 +35,23 @@
"commander": "^11.1.0",
"next": "14.0.3",
"next-mdx-remote": "^4.4.1",
"react-syntax-highlighter": "^15.5.0",
"react": "^18",
"react-dom": "^18",
"react-hook-form": "^7.49.0",
"react-syntax-highlighter": "^15.5.0",
"sharp": "^0.33.1",
"zod": "^3.22.4"
},
"devDependencies": {
"@chromatic-com/storybook": "^3.2.2",
"@playwright/test": "^1.40.0",
"@storybook/addon-essentials": "^8.4.7",
"@storybook/addon-interactions": "^8.4.7",
"@storybook/addon-onboarding": "^8.4.7",
"@storybook/blocks": "^8.4.7",
"@storybook/nextjs": "^8.4.7",
"@storybook/react": "^8.4.7",
"@storybook/test": "^8.4.7",
"@types/node": "^20",
"@types/react": "^18",
"@types/react-dom": "^18",
Expand All @@ -53,8 +63,10 @@
"eslint-config-next": "14.0.3",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.1.2",
"eslint-plugin-storybook": "^0.11.1",
"pa11y": "^6.2.3",
"postcss": "^8",
"storybook": "^8.4.7",
"tailwindcss": "^3.4.3",
"typescript": "^5"
}
Expand Down
Loading
Loading