@anarock/pebble

中文文档
0.46.1发布于 2019/05/23MITTypeScriptESM + CJS近 30 天下载 2237

A set of lightweight and accessible React component written in typescript and emotion.

原始使用文档
文档目录7 节
  1. Installation
  2. Getting started
  3. Polyfill
  4. UMD Usage
  5. Using icons in React Native
  6. Acknowledgements
  7. License

pebble

A set of lightweight and accessible React component written in typescript and emotion.

Installation

yarn add @anarock/pebble

Getting started

First of all you will need to install the fonts and icons used by the Design System. Make sure the below code is executed at the very beginning.

The easier way is to use the cdn:

<link
  rel="stylesheet"
  href="https://unpkg.com/@anarock/pebble@[version]/dist/pebble.css"
/>

:boom: Warning: Pebble adds box-sizing: border-box by default to every element by using inherit. If you have some elements whose children which need default box-sizing you can reset it's box-sizing to content-box

Polyfill

Pebble intends to have a very small footprint while maintaining performance. This, however, comes at a cost of supporting only modern browsers. If you need to support legacy browsers, you would need to add polyfills.

<script src="https://polyfill.io/v3/polyfill.min.js?features=Array.prototype.find,Array.prototype.findIndex,IntersectionObserver,Intl.~locale.en,Object.entries,default"></script>

UMD Usage

<script src="https://polyfill.io/v3/polyfill.min.js?features=Array.prototype.find,Array.prototype.findIndex,IntersectionObserver,Intl.~locale.en,Object.entries,default"></script>
<script src="https://unpkg.com/react@latest/umd/react.production.min.js"></script>
<script src="https://unpkg.com/react-dom@latest/umd/react-dom.production.min.js"></script>
<script src="https://unpkg.com/@anarock/pebble@latest/dist/pebble.umd.js"></script>
<script>
  // Components are available in window.pebble
  var Button = pebble.Button;
  var h = React.createElement;
  ReactDOM.render(
    h(
      Button,
      {
        onClick: function() {
          alert("You clicked the button");
        }
      },
      "Click Me!"
    ),
    document.getElementById("root")
  );
</script>

Using icons in React Native

Add the following in your package.json;

"rnpm": {
    "assets": {
        "./node_modules/@anarock/pebble/native/icons"
    }
}

Then run react-native link. and then it can be used by importing the Icon component.

import { Icon } from "@anarock/pebble/native";

// Usage
<Icon name="iconName" size={20} color="#000000" />;

Acknowledgements

We use Chromaticqa for visual regression testing and it is awesome.

License

MIT

版本与发布记录

@anarock/pebble 共发布 102 个版本,首次发布于 2018/07/10;过去 12 个月发布了 0 个版本。

版本发布日期距今
0.46.1latest2019/05/237 年前
0.46.02019/05/207 年前
0.45.02019/05/177 年前
0.44.32019/05/067 年前
0.44.12019/04/167 年前
0.44.02019/04/157 年前

关于 @anarock/pebble 的常见问题

@anarock/pebble 是什么?

A set of lightweight and accessible React component written in typescript and emotion.

如何安装 @anarock/pebble?

在项目目录运行 npm install @anarock/pebble,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(^16.8.4)、react-dom(^16.8.4)、@babel/runtime(^7.3.4)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@anarock/pebble 支持 TypeScript 吗?

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

@anarock/pebble 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@anarock/pebble 可以商用吗?

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

@anarock/pebble 的下载量有多少?

根据 npm 官方下载统计,@anarock/pebble 在 2026/10/06 – 2026/11/04 这 30 天内被下载 2,237 次,日均约 75 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@anarock/pebble 还在维护吗?

最新版本 0.46.1 发布于 2019/05/23(7 年前);至今共发布 102 个版本,其中过去 12 个月发布了 0 个;首次发布于 2018/07/10。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。