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

Commit

Permalink
Merge pull request #35 from gnosis/development
Browse files Browse the repository at this point in the history
Release 0.2.0
  • Loading branch information
nicosampler authored Jul 15, 2020
2 parents 719934f + a547677 commit c29f000
Show file tree
Hide file tree
Showing 42 changed files with 2,518 additions and 1,552 deletions.
16 changes: 10 additions & 6 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
{
"extends": ["react-app", "prettier", "prettier/react", "plugin:import/errors"],
"plugins": ["prettier", "import"],
"parserOptions": {
"ecmaVersion": 9
}
}
"parser": "@typescript-eslint/parser",
"extends": [
"react-app",
"prettier",
"prettier/react",
"plugin:import/errors",
"plugin:@typescript-eslint/recommended"
],
"plugins": ["prettier", "import"]
}
2 changes: 1 addition & 1 deletion .storybook/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ module.exports = ({ config }) => {
});

config.module.rules.push({
test: /\.(svg)$/,
test: /\.(svg|png|jpg)$/i,
use: [
{
loader: 'url-loader',
Expand Down
6 changes: 5 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
if: (branch = master) OR (branch = development) OR (tag IS present)
if: (branch = master) OR (branch = development) OR (type = pull_request) OR (tag IS present)
language: node_js
node_js: '12'
before_install:
Expand Down Expand Up @@ -26,6 +26,10 @@ script: |
else
echo "No tagged commit, won't build NPM lib"
fi
after_success:
# Pull Request - Deploy it to a review environment
# Travis doesn't do deploy step with pull requests builds
- ./travis/deploy_pull_request.sh
deploy:
# DEVELOPMENT env deployment
- provider: s3
Expand Down
107 changes: 106 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,108 @@
# safe-react-components

[Live example](https://components.gnosis-safe.io/)
![Badge](https://raw.githubusercontent.com/storybooks/brand/master/badge/badge-storybook.svg)
![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/gnosis/safe-react-components?sort=semver)
![GitHub](https://img.shields.io/github/license/gnosis/safe-react-components)

This repository contains a set of React components written in typescript.

These components are being used to build the [Safe Multisig](https://github.com/gnosis/safe-react) web and desktop app.

As Safe Multisig allows to integrate third party applications ("Safe Apps"), these components can also be used to build Safe Apps with the following benefits:

- **Native feel:** Build your Safe Apps with a similar style as the one used Safe-multisig. This makes your Safe Apps feel almost like a native feature of the Safe Multisig.
- **Responsive:** Most of the components will are optimized to render properly in different resolutions.
- **Blockchain-focused:** Some components solve common blockchain-related problems like inputs for ETH addresses and bigNumbers, identicon images, and more.
- **Save time:** No need to build all components from scratch.

## How to install

```bash
yarn add @gnosis.pm/safe-react-components

npm install @gnosis.pm/safe-react-components
```

## Integration

This library makes use of [material-ui - 4.X.X](https://material-ui.com/) and [styled-componentes - 5.X.X]() as `peer dependencies`, this means you must install it in your Safe App. Make sure to provide the same version as the one being used by the current version of this library.


Once everything is installed, you have to instantiate a [ThemeProvider](https://styled-components.com/docs/api#themeprovider) from [styled-components](http://styled-components.com/).

This example uses the theme exported by safe-react-components. Here, you can extend this theme to customize it to your needs.

```js
import { ThemeProvider } from 'styled-components';
import { theme } from '@gnosis.pm/safe-react-components';

import App from './App';

export default () => (
<ThemeProvider theme={theme}>
<App />
</ThemeProvider>
);
```

### Using the same fonts as Safe-multisig

If you want your app to have the same fonts as the one used by Safe Multisig you need to do the following.

```js
import { createGlobalStyle } from 'styled-components';
import avertaFont from '@gnosis.pm/safe-react-components/dist/fonts/averta-normal.woff2';
import avertaBoldFont from '@gnosis.pm/safe-react-components/dist/fonts/averta-bold.woff2';

const GlobalStyle = createGlobalStyle`
@font-face {
font-family: 'Averta';
font-display: swap;
src: local('Averta'), local('Averta Bold'),
url(${avertaFont}) format('woff2'),
url(${avertaBoldFont}) format('woff');
}
`;

export default GlobalStyle;
```

And then include it in the root of your Safe App.

```js
import React from "react";
import ReactDOM from "react-dom";
import GlobalStyles from './global';

import App from './App';

ReactDOM.render(
<>
<GlobalStyles />
<App>
</>,
document.getElementById('root')
);
```

## Using the components

You can import every component exported from @gnosis.pm/safe-react-components in the same way.

```js
import { Text } from '@gnosis.pm/safe-react-components';

const App = () => {
return <Text size="lg">some text</Text>;
};

export default App;
```

## Storybook

You can find documentation and examples of all our components in this [storybook](https://components.gnosis-safe.io/).

## Examples

At Gnosis we have developed some example Safe Apps. Here is the [repository](https://github.com/gnosis/safe-react-apps).
54 changes: 28 additions & 26 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@gnosis.pm/safe-react-components",
"version": "0.1.3",
"version": "0.2.0",
"description": "Gnosis UI components",
"main": "dist/index.min.js",
"typings": "dist/index.d.ts",
Expand All @@ -22,59 +22,61 @@
"license": "MIT",
"dependencies": {
"classnames": "^2.2.6",
"polished": "3.6.3",
"polished": "3.6.5",
"react-docgen-typescript-loader": "^3.7.2",
"react-media": "^1.10.0",
"url-loader": "^4.1.0"
},
"devDependencies": {
"@babel/core": "7.9.6",
"@material-ui/core": "4.8.0",
"@storybook/addon-actions": "5.3.18",
"@storybook/addon-docs": "5.3.18",
"@storybook/addon-links": "5.3.18",
"@storybook/addons": "5.3.18",
"@material-ui/core": "4.10.2",
"@storybook/addon-actions": "5.3.19",
"@storybook/addon-docs": "5.3.19",
"@storybook/addon-links": "5.3.19",
"@storybook/addons": "5.3.19",
"@storybook/preset-create-react-app": "2.1.2",
"@storybook/react": "5.3.18",
"@testing-library/jest-dom": "5.7.0",
"@testing-library/react": "10.0.4",
"@storybook/react": "5.3.19",
"@testing-library/jest-dom": "5.11.0",
"@testing-library/react": "10.4.3",
"@testing-library/user-event": "10.3.1",
"@types/big.js": "^4.0.5",
"@types/classnames": "^2.2.10",
"@types/jest": "25.2.2",
"@types/jest": "26.0.3",
"@types/material-ui": "^0.21.7",
"@types/node": "14.0.1",
"@types/react": "16.9.35",
"@types/node": "14.0.14",
"@types/react": "16.9.41",
"@types/react-dom": "16.9.8",
"@types/styled-components": "5.1.0",
"@types/yup": "0.28.3",
"@types/yup": "0.29.3",
"@typescript-eslint/eslint-plugin": "^3.5.0",
"@typescript-eslint/parser": "^3.5.0",
"awesome-typescript-loader": "^5.2.1",
"babel-eslint": "^10.0.3",
"babel-loader": "8.1.0",
"copy-webpack-plugin": "^5.1.1",
"eslint": "7.0.0",
"eslint": "7.3.1",
"eslint-config-prettier": "6.11.0",
"eslint-config-react-app": "5.2.1",
"eslint-plugin-flowtype": "5.1.0",
"eslint-plugin-import": "2.20.2",
"eslint-plugin-import": "2.22.0",
"eslint-plugin-jsx-a11y": "^6.2.3",
"eslint-plugin-prettier": "3.1.3",
"eslint-plugin-react": "7.20.0",
"eslint-plugin-react-hooks": "4.0.2",
"eslint-plugin-prettier": "3.1.4",
"eslint-plugin-react": "7.20.2",
"eslint-plugin-react-hooks": "4.0.4",
"ethereum-blockies-base64": "^1.0.2",
"prettier": "2.0.5",
"react": "16.13.1",
"react-dom": "16.13.1",
"rimraf": "^3.0.2",
"styled-components": "5.1.0",
"typescript": "3.9.2",
"styled-components": "5.1.1",
"typescript": "3.9.5",
"webpack": "4.43.0",
"webpack-cli": "^3.3.10",
"webpack-node-externals": "^1.7.2"
},
"peerDependencies": {
"react": "^16.x.x",
"react-dom": "^16.x.x",
"styled-components": "^4.x.x"
"@material-ui/core": "4.X.X",
"react": "16.x.x",
"react-dom": "16.x.x",
"styled-components": "5.x.x"
},
"eslintConfig": {
"extends": "react-app"
Expand Down
20 changes: 17 additions & 3 deletions src/dataDisplay/Icon/icon.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,22 +32,31 @@ export const icons = () => {
font-size: 14px;
`;

const IconDisplay = styled.div`
display: flex;
align-items: center;
flex-direction: column;
justify-content: space-evenly;
`;

return (
<Wrapper>
{[
'add',
'allowances',
'addressBook',
'addressBookAdd',
'apps',
'alert',
'allowances',
'apps',
'arrowDown',
'assets',
'awaitingConfirmations',
'camera',
'chain',
'check',
'circleCheck',
'circleCross',
'circleDropdown',
'code',
'collectibles',
'copy',
Expand All @@ -64,7 +73,9 @@ export const icons = () => {
'filledCross',
'fingerPrint',
'getInTouch',
'home',
'info',
'knowledge',
'licenses',
'loadSafe',
'locked',
Expand All @@ -83,12 +94,15 @@ export const icons = () => {
'requiredConfirmations',
'restricted',
'resync',
'rocket',
'scan',
'search',
'sendAgain',
'sent',
'serverError',
'settings',
'settingsChange',
'settingsTool',
'share',
'termsOfUse',
'transactionsInactive',
Expand All @@ -97,7 +111,7 @@ export const icons = () => {
'wallet'
].map((type: any, index) => (
<IconBox key={index}>
<Icon size={'md'} type={type} />
<Icon size="md" type={type} />
{type}
</IconBox>
))}
Expand Down
6 changes: 5 additions & 1 deletion src/dataDisplay/Icon/images/alert.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ export default {
<path d="M0 0H24V24H0z" />
<path
className="icon-color"
d="M6.066 19.998c.292-2.109 1.506-3.209 2.686-4.276 1.101-.997 2.24-2.028 2.251-3.73-.01-1.688-1.15-2.719-2.25-3.716-.105-.092-.208-.187-.31-.282h7.115c-.102.095-.205.19-.308.282-1.1.997-2.24 2.028-2.25 3.73.01 1.688 1.148 2.719 2.25 3.716 1.18 1.067 2.394 2.167 2.686 4.276H6.066zM17.936 4c-.112.812-.364 1.474-.696 2.042-.078-.02-.153-.048-.237-.048H6.731C6.414 5.436 6.175 4.789 6.066 4h11.87zm-1.344 10.238c-1.014-.918-1.588-1.474-1.593-2.232.005-.772.58-1.329 1.593-2.247 1.44-1.303 3.411-3.087 3.411-6.759 0-.553-.448-1-1-1H5c-.553 0-1 .447-1 1 0 3.672 1.97 5.456 3.41 6.759 1.013.918 1.588 1.475 1.593 2.233-.005.772-.58 1.328-1.593 2.246C5.97 15.542 4 17.326 4 20.998c0 .553.447 1 1 1h14.003c.552 0 1-.447 1-1 0-3.672-1.972-5.457-3.41-6.76z"
d="M11.999 8.002c.552 0 1 .447 1 1v4c0 .552-.448 1-1 1-.553 0-1-.448-1-1v-4c0-.553.447-1 1-1M11.999 15.752c.69 0 1.25.56 1.25 1.25s-.56 1.25-1.25 1.25-1.25-.56-1.25-1.25.56-1.25 1.25-1.25"
/>
<path
className="icon-color"
d="M12 2c-.502 0-1.004.25-1.283.752L1.187 19.83C.644 20.804 1.352 22 2.47 22H21.53c1.119 0 1.826-1.196 1.283-2.17l-9.53-17.078C13.004 2.25 12.503 2 12 2m0 2.554l8.624 15.454H3.377L12 4.554"
/>
</g>
</svg>
Expand Down
46 changes: 46 additions & 0 deletions src/dataDisplay/Icon/images/chain.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import React from 'react';

export default {
sm: (
<svg
xmlns="http://www.w3.org/2000/svg"
width="16"
height="16"
viewBox="0 0 16 16">
<g fill="none" fillRule="evenodd">
<path d="M0 0H16V16H0z" />
<path
className="icon-color"
fillRule="nonzero"
d="M8.026 2.196c1.596-1.595 4.182-1.595 5.777 0 1.543 1.543 1.594 4.012.155 5.615l-.155.163-2.013 2.013c-1.512 1.512-3.933 1.599-5.548.21-.418-.36-.466-.99-.106-1.41.36-.418.991-.466 1.41-.106.777.668 1.922.666 2.697.013l.133-.122L12.39 6.56c.815-.813.815-2.134 0-2.948-.814-.815-2.134-.815-2.949 0-.39.39-1.023.39-1.414 0-.39-.39-.39-1.024 0-1.415z"
/>
<path
className="icon-color"
fillRule="nonzero"
d="M4.21 6.014c1.494-1.495 3.879-1.599 5.496-.256.425.353.483.983.13 1.408-.325.392-.887.472-1.306.205l-.102-.074c-.778-.646-1.908-.635-2.673.01l-.132.122L3.611 9.44c-.814.814-.814 2.134 0 2.949.814.814 2.135.814 2.95 0 .39-.391 1.023-.391 1.413 0 .39.39.39 1.023 0 1.414-1.595 1.595-4.183 1.595-5.777 0C.655 12.26.603 9.794 2.043 8.189l.154-.163L4.21 6.014z"
/>
</g>
</svg>
),
md: (
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24">
<g fill="none" fillRule="evenodd">
<path d="M0 0H24V24H0z" />
<path
className="icon-color"
fillRule="nonzero"
d="M11.795 4.229l.599-.58c2.198-2.198 5.761-2.198 7.959 0 2.139 2.139 2.197 5.57.173 7.779l-.173.18-3.019 3.02c-2.197 2.196-5.76 2.196-7.959 0-.212-.212-.406-.44-.579-.68-.323-.447-.223-1.072.225-1.396.447-.323 1.072-.223 1.396.225.11.153.235.3.372.436 1.366 1.366 3.552 1.414 4.976.147l.155-.146 3.018-3.02c1.418-1.417 1.418-3.714 0-5.131-1.366-1.366-3.55-1.415-4.985-.136l-.157.147-.61.591c-.396.384-1.03.374-1.414-.022-.354-.367-.373-.934-.062-1.322l.085-.092z"
/>
<path
className="icon-color"
fillRule="nonzero"
d="M6.667 9.376c2.198-2.198 5.762-2.198 7.96 0 .156.155.3.318.436.488.342.433.269 1.062-.164 1.405-.433.343-1.062.27-1.405-.164-.087-.11-.18-.215-.28-.315-1.367-1.366-3.553-1.415-4.978-.146l-.155.146-3.018 3.018c-1.417 1.417-1.417 3.714 0 5.132 1.366 1.367 3.55 1.415 4.972.15l.155-.146.753-.763c.388-.393 1.02-.397 1.414-.009.363.358.394.925.092 1.32l-.083.094-.757.768c-2.199 2.198-5.762 2.198-7.96 0-2.139-2.14-2.197-5.57-.174-7.78l.173-.18 3.02-3.018z"
/>
</g>
</svg>
)
};
Loading

0 comments on commit c29f000

Please sign in to comment.