@coorpacademy/components

中文文档
11.43.2发布于 2026/11/07TypeScriptESM + CJS近 30 天下载 1.7万

This library provide sharable components for web applications, either :

原始使用文档
文档目录13 节
  1. Goal
  2. Development
  3. Seeing the components on Storybook
  4. Analyse your component
  5. Adding a component
  6. Adding a locale
  7. Using a Lottie Animation
  8. Locally use in an external project
  9. Use in mobile app
  10. Visual Testing with Chromatic
  11. Setup
  12. Troubleshooting
  13. Generating a Bundle Analyzer Report

@Coorpacademy/Components

This library provide sharable components for web applications, either :

  • as CommonJS components
  • as a minified library

Components diagram

Goal

  • edit a component once, share it across all our platforms
  • provide a documentation referencing every component with its
    • available states (disabled, selected)
    • skinable properties
  • provide the smallest lib

Development

Seeing the components on Storybook

yarn
npm run start
# OR
npm run start:ie # for Internet Explorer

Then open http://localhost:3004.

Analyse your component

The props is the contract your app should fill in order to use the component. If the props are not properly set, it is not the role of you component to change them in order to render somehow. The propTypes are the representation of this contract.

Keep this workflow in mind:

props -> propTypes -> fixtures -> component

Then your app will just have to read propTypes to know which props to provide to render a view.

Adding a component

  • choose your atomic folder depending your component: template, organism, molecule, atom
  • add a folder having your component name: for example, for button you should have this tree:
atom
  └── button
        ├── index.js
        ├── style.css
        └── test
            └── fixtures
               └── default.js
               └── disabled.js
               └── hovered.js
  • index.js contains the React code + jsx, and exports your component
  • style.css contains the css module style for your component
  • test/fixtures/*.js are files representing all the possible states for your component, thus export props accordingly

note that whenever you add new component or new fixtures you have to generate the storybook index:

npm run generate

which is also launched automatically whenever you run npm start

Adding a locale

  • You need to add your locale in en/global.json file
  • Be sure to have translate: Provider.childContextTypes.translate in the contextTypes object of your component

example:

  ....

  const YourComponent = (props, context) => {
    const {translate} = context;

    return <p>{translate('your new locale')}</p>
  }

  YourComponent.contextTypes = {
    translate: Provider.childContextTypes.translate
};

  ...

Using a Lottie Animation

To use a lottie animation, you need to use the LottieWrapper Atom.

Among the Lottie Atom's props, there are two important props: animationSrc & ie11ImageBackup, that need an additional step, the ie11ImageBackup is needed as it's name implies because ie11 doesn't support Lottie (more specifically Web Components due to the Shadow DOM).

First, you must upload to AWS S3 any new animation, in one of the static buckets (depending on the desired env), ex: https://static-staging.coorpacademy.com/animations/review/.

This animation must be paired with a backup image (svg) that'll be used for the ie11 scenario.

Then, use the urls as props for animationSrc & ie11ImageBackup, ex:

const props = {
    'aria-label': 'aria lottie',
    'data-name': 'default-lottie',
    className: undefined,
    animationSrc: 'https://static-staging.coorpacademy.com/animations/review/rank.json',
    loop: true,
    height: 200,
    width: 200,
    ie11ImageBackup:
      'https://static-staging.coorpacademy.com/animations/review/rank_icon_congrats.svg',
    // autoplay: true // autoplay is true by default
}

If you need to control the animation (play/pause/stop), then you must set autoplay to false & add your desired state, among the available states: play, pause, stop, loading

const props = {
    'aria-label': 'aria lottie',
    'data-name': 'default-lottie',
    className: undefined,
    animationSrc: 'https://static-staging.coorpacademy.com/animations/review/rank.json',
    loop: true,
    height: 200,
    width: 200,
    ie11ImageBackup:
      'https://static-staging.coorpacademy.com/animations/review/rank_icon_congrats.svg',
    autoplay: false,
    animationControl: 'loading' // play can be passed directly without using loading first
}

Additional information

The props include classNames && size control to handle additional styling.

Locally use in an external project

Link your dependencies:

[@coorpacademy-components] > npm link
[your-app] > npm link @coorpacademy/components

Build modifications:

[@coorpacademy-components] > npm run build:es

Use in mobile app

Run npm run build:watch For more info see the mobile documentation

You may need to install these optional libs depending on which native components you use:

  • colorjs.io
  • react-native-modal
  • react-native-render-html
  • react-native-linear-gradient
  • @coorpacademy/react-native-slider
  • @react-native-community/blur

Visual Testing with Chromatic

We use Chromatic for visual regression testing. This helps catch UI changes and ensure consistency across components.

Setup

  1. Copy the example environment file:

    cp .env.example .env
    
  2. Add your Chromatic project token to the .env file:

    CHROMATIC_PROJECT_TOKEN=your_token_here
    
  3. Run Chromatic:

    npm run chromatic
    

This will build your Storybook and upload it to Chromatic for visual testing.

Troubleshooting

Error when trying to launch the storybook:

Try to delete your node_modules, go to the project's root and launch: yarn

Generating a Bundle Analyzer Report

To check the content of the bundle and optimize it if needed, we set up webpack-bundle-analyzer, which generates a bundle analysis report. This visualizes the size of webpack output files with an interactive zoomable treemap. To generate it, just run npm run build:stats.

Webpack Bundle Analyzer Report

版本与发布记录

@coorpacademy/components 共发布 2,466 个版本,首次发布于 2016/01/28;过去 12 个月发布了 51 个版本。

版本发布日期距今
11.43.2latest2026/11/074 天前
11.43.12026/11/064 天前
11.43.02026/11/055 天前
11.42.122026/11/056 天前
11.42.112026/11/037 天前
11.42.102026/11/037 天前

其他发布通道:next → 10.30.7,canary → 11.40.22-slider.1。

关于 @coorpacademy/components 的常见问题

@coorpacademy/components 是什么?

This library provide sharable components for web applications, either :

如何安装 @coorpacademy/components?

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

@coorpacademy/components 支持 TypeScript 吗?

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

@coorpacademy/components 支持 ESM 还是 CommonJS?

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

@coorpacademy/components 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=22。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@coorpacademy/components 可以商用吗?

@coorpacademy/components 使用 未声明 许可。package.json 没有声明许可证。没有许可证的代码默认保留全部权利,商用前请联系作者或查看仓库中的 LICENSE 文件。以上为概括,不构成法律意见,请以许可原文为准。

@coorpacademy/components 的下载量有多少?

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

@coorpacademy/components 还在维护吗?

最新版本 11.43.2 发布于 2026/11/07(4 天前);至今共发布 2466 个版本,其中过去 12 个月发布了 51 个;首次发布于 2016/01/28。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。