-
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.
- Loading branch information
oliviercperrier
committed
Mar 3, 2025
1 parent
6f5aac9
commit dac99d4
Showing
31 changed files
with
4,317 additions
and
702 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,2 +1,4 @@ | ||
# node | ||
node_modules/ | ||
|
||
*storybook.log |
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,3 @@ | ||
@tailwind base; | ||
@tailwind components; | ||
@tailwind utilities; |
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,40 @@ | ||
import type { StorybookConfig } from "@storybook/react-vite"; | ||
import { mergeConfig } from "vite"; | ||
import tsConfigPaths from "vite-tsconfig-paths"; | ||
|
||
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: [ | ||
"../stories/**/*.mdx", | ||
"../stories/**/*.stories.@(js|jsx|mjs|ts|tsx)", | ||
], | ||
addons: [ | ||
getAbsolutePath("@storybook/addon-essentials"), | ||
getAbsolutePath("@storybook/addon-onboarding"), | ||
getAbsolutePath("@chromatic-com/storybook"), | ||
getAbsolutePath("@storybook/experimental-addon-test"), | ||
], | ||
framework: { | ||
name: getAbsolutePath("@storybook/react-vite"), | ||
options: {}, | ||
}, | ||
viteFinal: async (config) => { | ||
return mergeConfig(config, { | ||
plugins: [tsConfigPaths()], | ||
}); | ||
}, | ||
typescript: { | ||
reactDocgenTypescriptOptions: { | ||
tsconfigPath: "./tsconfig.json", | ||
}, | ||
}, | ||
}; | ||
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,17 @@ | ||
import type { Preview } from "@storybook/react"; | ||
import "./index.css"; | ||
import "@styles/colors.css"; | ||
import "@styles/main.css"; | ||
|
||
const preview: Preview = { | ||
parameters: { | ||
controls: { | ||
matchers: { | ||
color: /(background|color)$/i, | ||
date: /Date$/i, | ||
}, | ||
}, | ||
}, | ||
}; | ||
|
||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { beforeAll } from 'vitest'; | ||
import { setProjectAnnotations } from '@storybook/react'; | ||
import * as projectAnnotations from './preview'; | ||
|
||
// This is an important step to apply the right configuration when testing your stories. | ||
// More info at: https://storybook.js.org/docs/api/portable-stories/portable-stories-vitest#setprojectannotations | ||
const project = setProjectAnnotations([projectAnnotations]); | ||
|
||
beforeAll(project.beforeAll); |
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
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
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
97 changes: 97 additions & 0 deletions
97
frontend/components/stories/base/buttons/action-button.stories.tsx
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,97 @@ | ||
import type { Meta, StoryObj } from "@storybook/react"; | ||
import { fn } from "@storybook/test"; | ||
|
||
import ActionButton from "@/components/base/Buttons/ActionButton"; | ||
|
||
const meta = { | ||
title: "Base/Buttons/Action Button", | ||
component: ActionButton, | ||
tags: ["autodocs"], | ||
args: { onClick: fn(), size: "default", actions: [], onDefaultAction: fn() }, | ||
} satisfies Meta<typeof ActionButton>; | ||
|
||
export default meta; | ||
|
||
type Story = StoryObj<typeof meta>; | ||
|
||
export const Default: Story = { | ||
args: { | ||
children: "Button", | ||
variant: "default", | ||
}, | ||
}; | ||
|
||
export const Outline: Story = { | ||
args: { | ||
children: "Button", | ||
variant: "outline", | ||
}, | ||
}; | ||
|
||
export const Primary: Story = { | ||
args: { | ||
children: "Button", | ||
variant: "primary", | ||
}, | ||
}; | ||
|
||
export const Secondary: Story = { | ||
args: { | ||
children: "Button", | ||
variant: "secondary", | ||
}, | ||
}; | ||
|
||
export const Ghost: Story = { | ||
args: { | ||
children: "Button", | ||
variant: "ghost", | ||
}, | ||
}; | ||
|
||
export const Destructive: Story = { | ||
args: { | ||
children: "Button", | ||
variant: "destructive", | ||
}, | ||
}; | ||
|
||
export const Loading: Story = { | ||
args: { | ||
children: "Button", | ||
variant: "primary", | ||
}, | ||
}; | ||
|
||
export const Disabled: Story = { | ||
args: { | ||
children: "Button", | ||
variant: "primary", | ||
disabled: true, | ||
}, | ||
}; | ||
|
||
export const Sizes: Story = { | ||
args: { | ||
children: "Button", | ||
}, | ||
render: (args) => ( | ||
<div className="flex gap-2"> | ||
<ActionButton {...args} size="default" variant="primary"> | ||
Default | ||
</ActionButton> | ||
<ActionButton {...args} size="xs" variant="primary"> | ||
AButton xs | ||
</ActionButton> | ||
<ActionButton {...args} size="sm" variant="primary"> | ||
AButton sm | ||
</ActionButton> | ||
<ActionButton {...args} size="md" variant="primary"> | ||
AButton md | ||
</ActionButton> | ||
<ActionButton {...args} size="lg" variant="primary"> | ||
AButton lg | ||
</ActionButton> | ||
</div> | ||
), | ||
}; |
103 changes: 103 additions & 0 deletions
103
frontend/components/stories/base/buttons/button.stories.tsx
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,103 @@ | ||
import type { Meta, StoryObj } from "@storybook/react"; | ||
import { fn } from "@storybook/test"; | ||
|
||
import { Button } from "@/components/base/ui/button"; | ||
|
||
const meta = { | ||
title: "Base/Buttons/Button", | ||
component: Button, | ||
tags: ["autodocs"], | ||
args: { onClick: fn(), size: "default" }, | ||
} satisfies Meta<typeof Button>; | ||
|
||
export default meta; | ||
|
||
type Story = StoryObj<typeof meta>; | ||
|
||
export const Default: Story = { | ||
args: { | ||
children: "Button", | ||
variant: "default", | ||
}, | ||
}; | ||
|
||
export const Outline: Story = { | ||
args: { | ||
children: "Button", | ||
variant: "outline", | ||
}, | ||
}; | ||
|
||
export const Primary: Story = { | ||
args: { | ||
children: "Button", | ||
variant: "primary", | ||
}, | ||
}; | ||
|
||
export const Secondary: Story = { | ||
args: { | ||
children: "Button", | ||
variant: "secondary", | ||
}, | ||
}; | ||
|
||
export const Ghost: Story = { | ||
args: { | ||
children: "Button", | ||
variant: "ghost", | ||
}, | ||
}; | ||
|
||
export const Destructive: Story = { | ||
args: { | ||
children: "Button", | ||
variant: "destructive", | ||
}, | ||
}; | ||
|
||
export const Link: Story = { | ||
args: { | ||
children: "Button", | ||
variant: "link", | ||
}, | ||
}; | ||
|
||
export const Loading: Story = { | ||
args: { | ||
children: "Button", | ||
variant: "primary", | ||
loading: true, | ||
}, | ||
}; | ||
|
||
export const Disabled: Story = { | ||
args: { | ||
children: "Button", | ||
variant: "primary", | ||
disabled: true, | ||
}, | ||
}; | ||
|
||
export const Sizes: Story = { | ||
args: {}, | ||
render: () => ( | ||
<div className="flex gap-2"> | ||
<Button size="default" variant="primary"> | ||
Default | ||
</Button> | ||
<Button size="xs" variant="primary"> | ||
Button xs | ||
</Button> | ||
<Button size="sm" variant="primary"> | ||
Button sm | ||
</Button> | ||
<Button size="md" variant="primary"> | ||
Button md | ||
</Button> | ||
<Button size="lg" variant="primary"> | ||
Button lg | ||
</Button> | ||
</div> | ||
), | ||
}; |
Oops, something went wrong.