-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from alterviewxyz/feat/add-storybook
Feat/add storybook
- Loading branch information
Showing
37 changed files
with
2,486 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
name: CI | ||
name: Build & Test | ||
|
||
on: | ||
push: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
name: Storybook | ||
|
||
on: | ||
push: | ||
branches: ["main"] | ||
pull_request: | ||
types: [opened, synchronize] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
# Checkout the repository | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Cache turbo build setup | ||
uses: actions/cache@v4 | ||
with: | ||
path: .turbo | ||
key: ${{ runner.os }}-turbo-${{ github.sha }} | ||
restore-keys: | | ||
${{ runner.os }}-turbo- | ||
# Setup pnpm | ||
- uses: pnpm/action-setup@v3 | ||
with: | ||
version: 8 | ||
|
||
# Install dependencies | ||
- name: Install Dependencies | ||
run: pnpm install | ||
|
||
# Build Storybook | ||
- name: Build Storybook | ||
run: pnpm run build-storybook | ||
|
||
# Deploy to GitHub Pages (only on push to main) | ||
- name: Deploy to GitHub Pages | ||
if: github.ref == 'refs/heads/main' && github.event_name == 'push' | ||
uses: peaceiris/actions-gh-pages@v3 | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
publish_dir: ./dist-storybook | ||
# Optionally specify the branch | ||
# publish_branch: gh-pages |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,3 +54,6 @@ dist-ssr | |
*.njsproj | ||
*.sln | ||
*.sw? | ||
|
||
*storybook.log | ||
/dist-storybook |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
/** @type {import("eslint").Linter.Config} */ | ||
module.exports = { | ||
root: true, | ||
extends: ["@rentment/eslint-config/web.config.mjs"], | ||
extends: [ | ||
"@rentment/eslint-config/web.config.mjs", | ||
"plugin:storybook/recommended", | ||
], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import type { StorybookConfig } from "@storybook/react-vite"; | ||
|
||
import { join, dirname } from "path"; | ||
|
||
/** | ||
* 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): any { | ||
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-onboarding"), | ||
getAbsolutePath("@storybook/addon-essentials"), | ||
getAbsolutePath("@chromatic-com/storybook"), | ||
getAbsolutePath("@storybook/addon-interactions"), | ||
], | ||
framework: { | ||
name: getAbsolutePath("@storybook/react-vite"), | ||
options: {}, | ||
}, | ||
}; | ||
export default config; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import React from "react"; | ||
import type { Preview } from "@storybook/react"; | ||
import "../src/App.css"; | ||
|
||
const preview: Preview = { | ||
parameters: { | ||
controls: { | ||
matchers: { | ||
color: /(background|color)$/i, | ||
date: /Date$/i, | ||
}, | ||
}, | ||
}, | ||
}; | ||
|
||
// Optional: Add global decorators | ||
export const decorators = [ | ||
(Story) => ( | ||
<div style={{ margin: "3em" }}> | ||
<Story /> | ||
</div> | ||
), | ||
]; | ||
|
||
export default preview; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
// Button.stories.tsx | ||
import type { Meta, StoryObj } from "@storybook/react"; | ||
|
||
import { Button } from "./Button"; | ||
|
||
// Meta configuration for the Button component | ||
const meta: Meta<typeof Button> = { | ||
title: "Components/Button", | ||
component: Button, | ||
parameters: { | ||
layout: "centered", | ||
}, | ||
tags: ["autodocs"], | ||
argTypes: { | ||
color: { | ||
control: { | ||
type: "select", | ||
options: ["primary", "secondary", "black", "white"], | ||
}, | ||
}, | ||
variant: { | ||
control: { | ||
type: "select", | ||
options: ["solid", "outline", "text"], | ||
}, | ||
}, | ||
disabled: { control: "boolean" }, | ||
onClick: { action: "clicked" }, | ||
}, | ||
args: { | ||
onClick: () => {}, | ||
label: "متن دکمه", | ||
color: "primary", | ||
variant: "solid", | ||
disabled: false, | ||
}, | ||
} satisfies Meta<typeof Button>; | ||
|
||
export default meta; | ||
type Story = StoryObj<typeof meta>; | ||
export const Primary: Story = { | ||
args: { | ||
color: "primary", | ||
}, | ||
argTypes: { | ||
variant: { | ||
control: { | ||
type: "select", | ||
options: ["solid", "outline", "text"], | ||
}, | ||
}, | ||
disabled: { control: "boolean" }, | ||
}, | ||
}; | ||
|
||
export const Secondary: Story = { | ||
args: { | ||
color: "secondary", | ||
}, | ||
argTypes: { | ||
variant: { | ||
control: { | ||
type: "select", | ||
options: ["solid", "outline", "text"], | ||
}, | ||
}, | ||
disabled: { control: "boolean" }, | ||
}, | ||
}; | ||
|
||
export const Black: Story = { | ||
args: { | ||
color: "black", | ||
}, | ||
argTypes: { | ||
variant: { | ||
control: { | ||
type: "select", | ||
options: ["solid", "outline", "text"], | ||
}, | ||
}, | ||
disabled: { control: "boolean" }, | ||
}, | ||
}; | ||
|
||
export const White: Story = { | ||
args: { | ||
color: "white", | ||
}, | ||
argTypes: { | ||
variant: { | ||
control: { | ||
type: "select", | ||
options: ["solid", "outline", "text"], | ||
}, | ||
}, | ||
disabled: { control: "boolean" }, | ||
}, | ||
}; |
Oops, something went wrong.