Skip to content
This repository has been archived by the owner on Aug 7, 2024. It is now read-only.

feat: setup storybook #1918

Merged
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
2 changes: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"extends": "next/core-web-vitals"
"extends": ["next/core-web-vitals", "plugin:storybook/recommended"]
}
16 changes: 16 additions & 0 deletions .storybook/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
module.exports = {
stories: [
"../stories/**/*.stories.mdx",
"../stories/**/*.stories.@(js|jsx|ts|tsx)",
],
addons: [
"@storybook/addon-links",
"@storybook/addon-essentials",
"@storybook/addon-interactions",
"storybook-addon-next",
],
framework: "@storybook/react",
core: {
builder: "@storybook/builder-webpack5",
},
};
10 changes: 10 additions & 0 deletions .storybook/preview.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import "../styles/globals.css";
export const parameters = {
actions: { argTypesRegex: "^on[A-Z].*" },
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/,
},
},
};
44,805 changes: 37,857 additions & 6,948 deletions package-lock.json

Large diffs are not rendered by default.

16 changes: 15 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
"cypress:run": "cypress run",
"test:e2e": "concurrently -k --success first \"npm run cypress:run\" \"npm run start\"",
"prepare": "husky install",
"format": "prettier --write ."
"format": "prettier --write .",
"storybook": "start-storybook -p 6006",
"build-storybook": "build-storybook"
},
"browserslist": {
"production": [
Expand All @@ -34,15 +36,27 @@
]
},
"devDependencies": {
"@babel/core": "^7.19.3",
"@storybook/addon-actions": "^6.5.12",
"@storybook/addon-essentials": "^6.5.12",
"@storybook/addon-interactions": "^6.5.12",
"@storybook/addon-links": "^6.5.12",
"@storybook/builder-webpack5": "^6.5.12",
"@storybook/manager-webpack5": "^6.5.12",
"@storybook/react": "^6.5.12",
"@storybook/testing-library": "^0.0.13",
"autoprefixer": "^10.4.7",
"babel-loader": "^8.2.5",
"concurrently": "^6.2.2",
"cypress": "^8.5.0",
"cypress-cucumber-preprocessor": "^4.3.0",
"eslint": "8.19.0",
"eslint-config-next": "12.2.0",
"eslint-plugin-storybook": "^0.6.4",
"husky": "^7.0.2",
"lint-staged": "^12.1.4",
"postcss": "^8.4.14",
"storybook-addon-next": "^1.6.9",
"tailwindcss": "^3.1.4"
},
"cypress-cucumber-preprocessor": {
Expand Down
17 changes: 17 additions & 0 deletions stories/components/user/UserLink.stories.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import UserLink from "../../../components/user/UserLink";

export default {
component: UserLink,
};

export const Basic = (args) => <UserLink {...args} />;

Basic.args = {
link: {
url: "https://www.youtube.com",
clicks: 2,
name: "My youtube channel",
},
username: "test",
displayStatsPublic: true,
};
30 changes: 30 additions & 0 deletions stories/pages/[username].stories.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import User from "../../pages/[username]";

export default {
component: User,
};

export const Basic = (args) => <User {...args} />;

Basic.args = {
data: {
name: "John",
bio: "I'm a developer",
avatar: require("./person-placeholder.png"),
views: 2,
displayStatsPublic: true,
username: "john",
links: [
{
url: "<https://www.youtube.com>",
clicks: 2,
name: "My Youtube",
},
{
url: "<https://www.instagram.com>",
clicks: 2,
name: "My Instagram",
},
],
},
};
Binary file added stories/pages/person-placeholder.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.