Skip to content

Commit

Permalink
add storybook example
Browse files Browse the repository at this point in the history
  • Loading branch information
Excleson committed Oct 12, 2023
1 parent 9487b92 commit b10ffe4
Show file tree
Hide file tree
Showing 6 changed files with 17,027 additions and 4,035 deletions.
3 changes: 2 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"next/core-web-vitals"
"next/core-web-vitals",
"plugin:storybook/recommended"
],
"rules": {
"react/prop-types": 0,
Expand Down
23 changes: 23 additions & 0 deletions .storybook/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import type { StorybookConfig } from "@storybook/nextjs";

const config: StorybookConfig = {
// Stories and Components location
stories: [
"../components/**/*.mdx",
"../components/**/*.stories.@(js|jsx|mjs|ts|tsx)"
],
addons: [
"@storybook/addon-links",
"@storybook/addon-essentials",
"@storybook/addon-onboarding",
"@storybook/addon-interactions",
],
framework: {
name: "@storybook/nextjs",
options: {},
},
docs: {
autodocs: "tag",
},
};
export default config;
17 changes: 17 additions & 0 deletions .storybook/preview.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import type { Preview } from "@storybook/react";
// Add any used css here
import "../styles/globals.css"

const preview: Preview = {
parameters: {
actions: { argTypesRegex: "^on[A-Z].*" },
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/,
},
},
},
};

export default preview;
51 changes: 51 additions & 0 deletions components/Buttons.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import {AButton} from './Buttons';

// More on how to set up stories at: https://storybook.js.org/docs/react/writing-stories/introduction#default-export
export default {
// Name of the component for the stories
component: AButton,

// Stories Title
title: 'AButton',

// This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/react/writing-docs/autodocs
tags: ['autodocs'],

// Add documentation for each args. More on argTypes: https://storybook.js.org/docs/react/api/argtypes
argTypes: {
text:{
description:"Button Text"
},
type:{
control:"select",
options:["button","submit","reset"],
description:"Button Type"
},
disabled:{
control:"boolean",
description:"Button disabled or not"
},
}
};

// More on writing stories with args: https://storybook.js.org/docs/react/writing-stories/args
export const Default = {
// Args for the component
args:{
text: "Default",
type: "button"
}
};
export const Submit = {
args:{
text: "Submit",
type: "submit"
}
};
export const Reset = {
args:{
text: "Reset",
type: "reset"
}
};

Loading

0 comments on commit b10ffe4

Please sign in to comment.