Skip to content

Commit

Permalink
1/n
Browse files Browse the repository at this point in the history
  • Loading branch information
ShawkiS committed May 26, 2021
1 parent 62e47e9 commit 2166714
Show file tree
Hide file tree
Showing 28 changed files with 35,212 additions and 158 deletions.
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 = {
core: {
builder: "webpack5",
},
"stories": [
"../src/**/*.stories.mdx",
"../src/**/*.stories.@(js|jsx|ts|tsx)"
],
"addons": [
"@storybook/addon-links",
"@storybook/addon-essentials"
]
}
10 changes: 10 additions & 0 deletions .storybook/preview.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

export const parameters = {
actions: { argTypesRegex: "^on[A-Z].*" },
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/,
},
},
}
7 changes: 7 additions & 0 deletions craco.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = {
style: {
postcss: {
plugins: [require("tailwindcss"), require("autoprefixer")],
},
},
};
29,736 changes: 29,736 additions & 0 deletions package-lock.json

Large diffs are not rendered by default.

23 changes: 18 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@
"build:chrome": "cross-env NODE_ENV=production cross-env TARGET_BROWSER=chrome webpack",
"build:firefox": "cross-env NODE_ENV=production cross-env TARGET_BROWSER=firefox webpack",
"build:opera": "cross-env NODE_ENV=production cross-env TARGET_BROWSER=opera webpack",
"build": "yarn run build:chrome && yarn run build:firefox && yarn run build:opera",
"build": "yarn run build:chrome && yarn run build:firefox && yarn run build:opera && craco build",
"lint": "eslint . --ext .js,.jsx --max-warnings 0",
"lint:fix": "eslint . --ext .js,.jsx --fix",
"format": "prettier --loglevel silent --write \"**/*.(js|ts|jsx|tsx)\"",
"test-ext": "jest ./src/extension",
"test-app": "jest ./src/app",
"test": "jest"
"test": "jest",
"storybook": "start-storybook -p 6006",
"build-storybook": "build-storybook"
},
"husky": {
"hooks": {
Expand All @@ -41,23 +43,29 @@
"dependencies": {
"@ant-design/icons": "^4.6.2",
"@babel/runtime": "^7.13.10",
"@craco/craco": "^6.1.2",
"@headlessui/react": "^1.2.0",
"@heroicons/react": "^1.0.1",
"@node-lightning/invoice": "^0.22.0",
"advanced-css-reset": "^1.2.2",
"antd": "^4.15.0",
"assert": "^2.0.0",
"autoprefixer": "^10.2.5",
"axios": "^0.21.1",
"browser-polyfill": "^3.20.2",
"crypto-browserify": "^3.12.0",
"crypto-js": "^4.0.0",
"invoices": "^1.1.7",
"lsat-js": "^1.0.7",
"memoizee": "^0.4.15",
"postcss": "^8.3.0",
"query-string": "^7.0.0",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-router-dom": "^5.2.0",
"sha.js": "^2.4.11",
"stream": "^0.0.2",
"tailwindcss": "^2.1.2",
"webext-base-css": "^1.3.1",
"webext-options-sync": "^2.0.1",
"webextension-polyfill": "^0.7.0",
Expand All @@ -72,9 +80,14 @@
"@babel/plugin-transform-runtime": "^7.13.15",
"@babel/preset-env": "^7.13.15",
"@babel/preset-react": "^7.13.13",
"@storybook/addon-actions": "^6.2.9",
"@storybook/addon-essentials": "^6.2.9",
"@storybook/addon-links": "^6.2.9",
"@storybook/builder-webpack5": "^6.3.0-beta.0",
"@storybook/cli": "^6.2.9",
"@storybook/react": "^6.2.9",
"@typescript-eslint/eslint-plugin": "^4.21.0",
"@typescript-eslint/parser": "^4.21.0",
"autoprefixer": "^10.2.5",
"babel-eslint": "^10.0.0",
"babel-jest": "^26.6.3",
"babel-loader": "^8.2.2",
Expand All @@ -84,6 +97,7 @@
"copy-webpack-plugin": "^8.1.1",
"cross-env": "^7.0.3",
"css-loader": "^5.2.0",
"dotenv-webpack": "^7.0.2",
"eslint": "^7.23.0",
"eslint-config-prettier": "^8.1.0",
"eslint-config-react-app": "^6.0.0",
Expand All @@ -103,8 +117,7 @@
"mini-css-extract-plugin": "^1.4.1",
"node-sass": "^5.0.0",
"optimize-css-assets-webpack-plugin": "^5.0.4",
"postcss": "^8.2.9",
"postcss-loader": "^5.2.0",
"postcss-loader": "^5.3.0",
"prettier": "^2.2.1",
"process": "^0.11.10",
"react-test-renderer": "^17.0.2",
Expand Down
6 changes: 6 additions & 0 deletions postcss.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
}
2 changes: 1 addition & 1 deletion src/app/components/Welcome/index.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from "react";
import ReactDOM from "react-dom";

import '../../../index.css';
import Welcome from "./Welcome";

ReactDOM.render(<Welcome />, document.getElementById("welcome-root"));
4 changes: 4 additions & 0 deletions src/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/* ./src/index.css */
@tailwind base;
@tailwind components;
@tailwind utilities;
50 changes: 50 additions & 0 deletions src/stories/Button.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import React from 'react';
import PropTypes from 'prop-types';
import './button.css';

/**
* Primary UI component for user interaction
*/
export const Button = ({ primary, backgroundColor, size, label, ...props }) => {
const mode = primary ? 'storybook-button--primary' : 'storybook-button--secondary';
return (
<button
type="button"
className={['storybook-button', `storybook-button--${size}`, mode].join(' ')}
style={backgroundColor && { backgroundColor }}
{...props}
>
{label}
</button>
);
};

Button.propTypes = {
/**
* Is this the principal call to action on the page?
*/
primary: PropTypes.bool,
/**
* What background color to use
*/
backgroundColor: PropTypes.string,
/**
* How large should the button be?
*/
size: PropTypes.oneOf(['small', 'medium', 'large']),
/**
* Button contents
*/
label: PropTypes.string.isRequired,
/**
* Optional click handler
*/
onClick: PropTypes.func,
};

Button.defaultProps = {
backgroundColor: null,
primary: false,
size: 'medium',
onClick: undefined,
};
36 changes: 36 additions & 0 deletions src/stories/Button.stories.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import React from 'react';

import { Button } from './Button';

export default {
title: 'Example/Button',
component: Button,
argTypes: {
backgroundColor: { control: 'color' },
},
};

const Template = (args) => <Button {...args} />;

export const Primary = Template.bind({});
Primary.args = {
primary: true,
label: 'Button',
};

export const Secondary = Template.bind({});
Secondary.args = {
label: 'Button',
};

export const Large = Template.bind({});
Large.args = {
size: 'large',
label: 'Button',
};

export const Small = Template.bind({});
Small.args = {
size: 'small',
label: 'Button',
};
52 changes: 52 additions & 0 deletions src/stories/Header.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import React from 'react';
import PropTypes from 'prop-types';

import { Button } from './Button';
import './header.css';

export const Header = ({ user, onLogin, onLogout, onCreateAccount }) => (
<header>
<div className="wrapper">
<div>
<svg width="32" height="32" viewBox="0 0 32 32" xmlns="http://www.w3.org/2000/svg">
<g fill="none" fillRule="evenodd">
<path
d="M10 0h12a10 10 0 0110 10v12a10 10 0 01-10 10H10A10 10 0 010 22V10A10 10 0 0110 0z"
fill="#FFF"
/>
<path
d="M5.3 10.6l10.4 6v11.1l-10.4-6v-11zm11.4-6.2l9.7 5.5-9.7 5.6V4.4z"
fill="#555AB9"
/>
<path
d="M27.2 10.6v11.2l-10.5 6V16.5l10.5-6zM15.7 4.4v11L6 10l9.7-5.5z"
fill="#91BAF8"
/>
</g>
</svg>
<h1>Acme</h1>
</div>
<div>
{user ? (
<Button size="small" onClick={onLogout} label="Log out" />
) : (
<>
<Button size="small" onClick={onLogin} label="Log in" />
<Button primary size="small" onClick={onCreateAccount} label="Sign up" />
</>
)}
</div>
</div>
</header>
);

Header.propTypes = {
user: PropTypes.shape({}),
onLogin: PropTypes.func.isRequired,
onLogout: PropTypes.func.isRequired,
onCreateAccount: PropTypes.func.isRequired,
};

Header.defaultProps = {
user: null,
};
18 changes: 18 additions & 0 deletions src/stories/Header.stories.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import React from 'react';

import { Header } from './Header';

export default {
title: 'Example/Header',
component: Header,
};

const Template = (args) => <Header {...args} />;

export const LoggedIn = Template.bind({});
LoggedIn.args = {
user: {},
};

export const LoggedOut = Template.bind({});
LoggedOut.args = {};
Loading

0 comments on commit 2166714

Please sign in to comment.