Skip to content

Commit

Permalink
feat: Basic storybook installation and Button story. (#264)
Browse files Browse the repository at this point in the history
* Fixed issues with depdendencies.

Signed-off-by: Tulun <[email protected]>

* added some commented config.

Signed-off-by: Tulun <[email protected]>

* yml file; added script + example

Signed-off-by: Tulun <[email protected]>

* fixed error

Signed-off-by: Tulun <[email protected]>

* EOL; add chromatic as dev dependency

Signed-off-by: Tulun <[email protected]>

* just add a newline

Signed-off-by: Tulun <[email protected]>

Signed-off-by: Tulun <[email protected]>
  • Loading branch information
Tulun authored Sep 12, 2022
1 parent 11568ff commit 13041e3
Show file tree
Hide file tree
Showing 17 changed files with 4,666 additions and 148 deletions.
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,6 @@ HARDHAT_INFURA_ID=

# Define a configurable message to display to users in environment.
REACT_APP_GENERAL_MAINTENANCE_MESSAGE="Message to display in top banner."

# Publish to Storybook manually by adding the frontend-v2 chromatic project id
CHROMATIC_PROJECT_TOKEN =
30 changes: 30 additions & 0 deletions .github/workflows/chromatic.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Workflow name
name: Chromatic

on:
# manual trigger
workflow_dispatch:
push:
branches:
- master
pull_request:
branches:
- master

# List of jobs
jobs:
chromatic-deployment:
# Operating System
runs-on: ubuntu-latest
# Job steps
steps:
- uses: actions/checkout@v1
- name: Install dependencies
run: yarn
# 👇 Adds Chromatic as a step in the workflow
- name: Publish to Chromatic
uses: chromaui/action@v1
# Chromatic GitHub Action options
with:
# 👇 Chromatic projectToken, refer to the manage page to obtain it.
projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,5 @@ yarn-error.log*
/cypress/videos
/cypress/downloads
/cypress/screenshots

build-storybook.log
13 changes: 13 additions & 0 deletions .storybook/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module.exports = {
stories: ["../src/**/*.stories.mdx", "../src/**/*.stories.@(js|jsx|ts|tsx)"],
addons: [
"@storybook/addon-links",
"@storybook/addon-essentials",
"@storybook/addon-interactions",
"@storybook/preset-create-react-app",
],
framework: "@storybook/react",
core: {
builder: "webpack4",
},
};
12 changes: 12 additions & 0 deletions .storybook/preview.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { Buffer } from "buffer";
window.Buffer = Buffer;

export const parameters = {
actions: { argTypesRegex: "^on[A-Z].*" },
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/,
},
},
};
38 changes: 34 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"axios": "^0.27.2",
"bnc-notify": "^1.9.1",
"bnc-onboard": "^1.39.0",
"buffer": "^6.0.3",
"downshift": "^6.1.7",
"ethers": "^5.6.1",
"framer-motion": "4.1.17",
Expand Down Expand Up @@ -70,7 +71,10 @@
"sitemap": "babel-node src/sitemap-generator.js",
"prepare": "husky install",
"cypress:open": "cypress open --e2e",
"cypress:run": "cypress run --e2e"
"cypress:run": "cypress run --e2e",
"storybook": "start-storybook -p 6006 -s public",
"build-storybook": "build-storybook -s public",
"chromatic": "chromatic"
},
"lint-staged": {
"*.{jsx,tsx,js,ts}": "yarn lint:fix"
Expand All @@ -90,6 +94,16 @@
"devDependencies": {
"@babel/plugin-transform-modules-commonjs": "^7.18.6",
"@ethersproject/experimental": "^5.6.3",
"@storybook/addon-actions": "^6.5.10",
"@storybook/addon-essentials": "^6.5.10",
"@storybook/addon-interactions": "^6.5.10",
"@storybook/addon-links": "^6.5.10",
"@storybook/builder-webpack4": "^6.5.10",
"@storybook/manager-webpack4": "^6.5.10",
"@storybook/node-logger": "^6.5.10",
"@storybook/preset-create-react-app": "^3.2.0",
"@storybook/react": "^6.5.10",
"@storybook/testing-library": "^0.0.13",
"@types/luxon": "^2.3.0",
"@types/react-slider": "^1.3.1",
"@vercel/node": "^2.5.13",
Expand All @@ -98,6 +112,7 @@
"babel-preset-es2015": "^6.24.1",
"babel-preset-react": "^6.24.1",
"babel-register": "^6.26.0",
"chromatic": "^6.9.0",
"cypress": "^10.4.0",
"eslint-plugin-prettier": "^4.2.1",
"husky": "^8.0.0",
Expand All @@ -116,7 +131,22 @@
}
},
"resolutions": {
"//": "See https://github.com/facebook/create-react-app/issues/11773",
"react-error-overlay": "6.0.9"
}
"//": "See https://github.com/facebook/create-react-app/issues/11773 ",
"react-error-overlay": "6.0.9",
"babel-loader": "8.1.0"
},
"eslintConfig": {
"overrides": [
{
"files": [
"**/*.stories.*"
],
"rules": {
"import/no-anonymous-default-export": "off"
}
}
]
},
"readme": "ERROR: No README data found!",
"_id": "[email protected]"
}
36 changes: 36 additions & 0 deletions src/stories/Button.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import React from "react";
import { ComponentStory, ComponentMeta } from "@storybook/react";

import { ButtonV2 } from "components/Buttons/ButtonV2";

// More on default export: https://storybook.js.org/docs/react/writing-stories/introduction#default-export
export default {
title: "ButtonV2",
component: ButtonV2,
// More on argTypes: https://storybook.js.org/docs/react/api/argtypes
argTypes: {},
} as ComponentMeta<typeof ButtonV2>;

// More on component templates: https://storybook.js.org/docs/react/writing-stories/introduction#using-args
const Template: ComponentStory<typeof ButtonV2> = (args) => (
<ButtonV2 {...args}>{args.children}</ButtonV2>
);

export const Primary = Template.bind({});
// More on args: https://storybook.js.org/docs/react/writing-stories/args
Primary.args = {
size: "md",
children: "Submit",
};

export const Large = Template.bind({});
Large.args = {
size: "lg",
children: "Submit",
};

export const Small = Template.bind({});
Small.args = {
size: "sm",
children: "Submit",
};
211 changes: 211 additions & 0 deletions src/stories/Introduction.stories.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,211 @@
import { Meta } from '@storybook/addon-docs';
import Code from './assets/code-brackets.svg';
import Colors from './assets/colors.svg';
import Comments from './assets/comments.svg';
import Direction from './assets/direction.svg';
import Flow from './assets/flow.svg';
import Plugin from './assets/plugin.svg';
import Repo from './assets/repo.svg';
import StackAlt from './assets/stackalt.svg';

<Meta title="Example/Introduction" />

<style>
{`
.subheading {
--mediumdark: '#999999';
font-weight: 900;
font-size: 13px;
color: #999;
letter-spacing: 6px;
line-height: 24px;
text-transform: uppercase;
margin-bottom: 12px;
margin-top: 40px;
}
.link-list {
display: grid;
grid-template-columns: 1fr;
grid-template-rows: 1fr 1fr;
row-gap: 10px;
}
@media (min-width: 620px) {
.link-list {
row-gap: 20px;
column-gap: 20px;
grid-template-columns: 1fr 1fr;
}
}
@media all and (-ms-high-contrast:none) {
.link-list {
display: -ms-grid;
-ms-grid-columns: 1fr 1fr;
-ms-grid-rows: 1fr 1fr;
}
}
.link-item {
display: block;
padding: 20px 30px 20px 15px;
border: 1px solid #00000010;
border-radius: 5px;
transition: background 150ms ease-out, border 150ms ease-out, transform 150ms ease-out;
color: #333333;
display: flex;
align-items: flex-start;
}
.link-item:hover {
border-color: #1EA7FD50;
transform: translate3d(0, -3px, 0);
box-shadow: rgba(0, 0, 0, 0.08) 0 3px 10px 0;
}
.link-item:active {
border-color: #1EA7FD;
transform: translate3d(0, 0, 0);
}
.link-item strong {
font-weight: 700;
display: block;
margin-bottom: 2px;
}
.link-item img {
height: 40px;
width: 40px;
margin-right: 15px;
flex: none;
}
.link-item span {
font-size: 14px;
line-height: 20px;
}
.tip {
display: inline-block;
border-radius: 1em;
font-size: 11px;
line-height: 12px;
font-weight: 700;
background: #E7FDD8;
color: #66BF3C;
padding: 4px 12px;
margin-right: 10px;
vertical-align: top;
}
.tip-wrapper {
font-size: 13px;
line-height: 20px;
margin-top: 40px;
margin-bottom: 40px;
}
.tip-wrapper code {
font-size: 12px;
display: inline-block;
}
`}
</style>

# Welcome to Storybook

Storybook helps you build UI components in isolation from your app's business logic, data, and context.
That makes it easy to develop hard-to-reach states. Save these UI states as **stories** to revisit during development, testing, or QA.

Browse example stories now by navigating to them in the sidebar.
View their code in the `stories` directory to learn how they work.
We recommend building UIs with a [**component-driven**](https://componentdriven.org) process starting with atomic components and ending with pages.

<div className="subheading">Configure</div>

<div className="link-list">
<a
className="link-item"
href="https://storybook.js.org/docs/react/addons/addon-types"
target="_blank"
>
<img src={Plugin} alt="plugin" />
<span>
<strong>Presets for popular tools</strong>
Easy setup for TypeScript, SCSS and more.
</span>
</a>
<a
className="link-item"
href="https://storybook.js.org/docs/react/configure/webpack"
target="_blank"
>
<img src={StackAlt} alt="Build" />
<span>
<strong>Build configuration</strong>
How to customize webpack and Babel
</span>
</a>
<a
className="link-item"
href="https://storybook.js.org/docs/react/configure/styling-and-css"
target="_blank"
>
<img src={Colors} alt="colors" />
<span>
<strong>Styling</strong>
How to load and configure CSS libraries
</span>
</a>
<a
className="link-item"
href="https://storybook.js.org/docs/react/get-started/setup#configure-storybook-for-your-stack"
target="_blank"
>
<img src={Flow} alt="flow" />
<span>
<strong>Data</strong>
Providers and mocking for data libraries
</span>
</a>
</div>

<div className="subheading">Learn</div>

<div className="link-list">
<a className="link-item" href="https://storybook.js.org/docs" target="_blank">
<img src={Repo} alt="repo" />
<span>
<strong>Storybook documentation</strong>
Configure, customize, and extend
</span>
</a>
<a className="link-item" href="https://storybook.js.org/tutorials/" target="_blank">
<img src={Direction} alt="direction" />
<span>
<strong>In-depth guides</strong>
Best practices from leading teams
</span>
</a>
<a className="link-item" href="https://github.com/storybookjs/storybook" target="_blank">
<img src={Code} alt="code" />
<span>
<strong>GitHub project</strong>
View the source and add issues
</span>
</a>
<a className="link-item" href="https://discord.gg/storybook" target="_blank">
<img src={Comments} alt="comments" />
<span>
<strong>Discord chat</strong>
Chat with maintainers and the community
</span>
</a>
</div>

<div className="tip-wrapper">
<span className="tip">Tip</span>Edit the Markdown in{' '}
<code>stories/Introduction.stories.mdx</code>
</div>
1 change: 1 addition & 0 deletions src/stories/assets/code-brackets.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

2 comments on commit 13041e3

@vercel
Copy link

@vercel vercel bot commented on 13041e3 Sep 12, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

goerli-frontend-v2 – ./

goerli-frontend-v2-git-master-uma.vercel.app
goerli-frontend-v2-uma.vercel.app
goerli-frontend-v2.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 13041e3 Sep 12, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.