@gnosis.pm/safe-react-components

中文文档
1.2.0发布于 2022/08/13MITTypeScriptCommonJS近 30 天下载 4471

Gnosis UI components

此软件包已被标记为弃用

Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

原始使用文档
文档目录7 节
  1. How to install
  2. Integration
  3. Using the components
  4. Storybook
  5. Local development
  6. Testing
  7. Examples

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.

版本与发布记录

@gnosis.pm/safe-react-components 共发布 35 个版本,首次发布于 2020/04/30;过去 12 个月发布了 0 个版本。

版本发布日期距今
1.2.0latest2022/08/134 年前
0.10.02022/08/124 年前
1.1.52022/07/124 年前
1.1.42022/04/274 年前
1.1.32022/04/204 年前
1.1.22022/03/164 年前

关于 @gnosis.pm/safe-react-components 的常见问题

@gnosis.pm/safe-react-components 是什么?

Gnosis UI components注意:该包已被作者标记为弃用——Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

如何安装 @gnosis.pm/safe-react-components?

在项目目录运行 npm install @gnosis.pm/safe-react-components,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@material-ui/core(4.X.X)、@mui/x-data-grid(^4.X.X)、react(16.x.x || 17.x.x)、react-dom(16.x.x || 17.x.x)、styled-components(5.x.x)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@gnosis.pm/safe-react-components 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@gnosis.pm/safe-react-components 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@gnosis.pm/safe-react-components 可以商用吗?

@gnosis.pm/safe-react-components 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@gnosis.pm/safe-react-components 的下载量有多少?

根据 npm 官方下载统计,@gnosis.pm/safe-react-components 在 2026/10/17 – 2026/11/15 这 30 天内被下载 4,471 次,日均约 149 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@gnosis.pm/safe-react-components 还在维护吗?

最新版本 1.2.0 发布于 2022/08/13(4 年前);至今共发布 35 个版本,其中过去 12 个月发布了 0 个;首次发布于 2020/04/30。作者已将其标记为弃用,新项目建议寻找替代方案。