1.2.0 • Published 2 years ago

@gnosis.pm/safe-react-components v1.2.0

Weekly downloads
88
License
MIT
Repository
github
Last release
2 years ago

safe-react-components

Storybook npm

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

These components are being used to build the Gnosis Safe web and desktop app.

As Gnosis Safe 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 by Gnosis Safe. This makes your Safe Apps feel almost like a native feature of the Gnosis Safe.
  • 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

   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 and styled-components - 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 from styled-components.

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

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 components

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

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.

Local development

To develop on your local machine, install the dependencies (including the peer dependencies):

yarn

Launch the Storybook:

yarn storybook

Testing

Snapshot tests are generated automatically from the Storybook stories using the StoryShots addon.

To run the tests locally:

yarn test

Alternatively, run yarn test --watch to re-run the tests for each modification you do. Before you commit your changes, you need to update the snapshots and commit them as well. To do so, run yarn test -u. When the command finishes, the resulting snapshots will be the new baseline.

If you want to add a new Jest test, make sure to put a file with the .test.tsx extension into the same directory as the corresponding component.

Examples

At Gnosis we have developed some example Safe Apps. Here is the repository.

1.2.0

2 years ago

1.1.5

2 years ago

0.10.0

2 years ago

1.1.4

2 years ago

1.1.3

2 years ago

1.1.1

2 years ago

1.1.2

2 years ago

1.0.2

2 years ago

0.9.8

2 years ago

1.1.0

2 years ago

1.0.1

2 years ago

0.9.7

2 years ago

1.0.0

2 years ago

0.9.6

2 years ago

0.9.4

2 years ago

0.9.3

2 years ago

0.9.5

2 years ago

0.9.2

2 years ago

0.9.1

2 years ago

0.8.6

2 years ago

0.9.0

2 years ago

0.8.5

3 years ago

0.8.4

3 years ago

0.8.3

3 years ago

0.8.2

3 years ago

0.8.0

3 years ago

0.7.0

3 years ago

0.6.0

3 years ago

0.5.0

3 years ago

0.3.0

4 years ago

0.2.0

4 years ago

0.1.3

4 years ago

0.1.2

4 years ago

0.1.0

4 years ago

0.1.1

4 years ago