Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/letshare/storybook-addon-customize-antd-theme

a Storybook addon help you visually customize an ant design theme
https://github.com/letshare/storybook-addon-customize-antd-theme

Last synced: about 2 months ago
JSON representation

a Storybook addon help you visually customize an ant design theme

Awesome Lists containing this project

README

        

[![npm version](https://badge.fury.io/js/storybook-addon-customize-antd-theme.svg)](https://badge.fury.io/js/storybook-addon-customize-antd-theme)
[![GitHub license](https://img.shields.io/github/license/letshare/storybook-addon-customize-antd-theme.svg)](https://github.com/letshare/storybook-addon-customize-antd-theme/blob/master/LICENSE)
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)](https://github.com/prettier/prettier)


## storybook-addon-customize-antd-theme

一个[Storybook](https://github.com/storybooks/storybook)插件, 它可以辅助你可视化定制 ant design 主题。

- [Docs & Demo](https://letshare.github.io/storybook-addon-customize-antd-theme)

[English](./README.md) | 简体中文

## 要求

- Storybook@>=6.0.0

## 使用

### 1. 安装

```sh
npm install -D storybook-addon-customize-antd-theme
# yarn add -D storybook-addon-customize-antd-theme
```

### 2. 在 `main.js` 注册本插件

另外建议导入本插件的一个 antd story`storybook-addon-customize-antd-theme/dist/esm/stories/index.js`

```js
module.exports = {
stories: ['storybook-addon-customize-antd-theme/dist/esm/stories/index.js'],
addons: ['storybook-addon-customize-antd-theme'],
};
```

### 3. 设置 story 的默认状态

你可以在 preview.js 初始化导入一个 ant design 主题,在`parameters`上设置属性`customizeAntdTheme`:

```js
// .storybook/preview.js

export const parameters = {
customizeAntdTheme: {
modifyVars: {
'primary-color': '#ff1771',
'border-radius-base': '20px',
},
},
};
```

`modifyVars` 也可以是 less string,可以通过 webpack 插件`raw-loader`导入一个 antd design 主题 less 文件,例如:

```js
// .storybook/preview.js
import themeLess from '!!raw-loader!../src/theme/theme.less';
export const parameters = {
customizeAntdTheme: {
modifyVars: themeLess,
},
};
```