一个方便的颜色主题组件
Demo
安装
yarn add color-theme
使用
/* 引入 Compoent 接口 */
import { Component as ColorTheme } from 'color-theme';
<ColorTheme
type="theme"
theme={themes}
active={type === 'theme'}
onhandleColorChange={this.handleColorChange}
onhandleBgChange={this.handleBgChange}
/>
/* 引入 reducer 接口 */
import { reducer as colorTheme } from 'color-theme';
API
| props | 描述 | 类型 | 默认值 |
|---|---|---|---|
| type | 主题类型,可选 theme | color | bg | string | - |
| theme | 颜色主题数组 | array | - |
| active | 是否激活,在需要不同类型的颜色主题组件时使用 | boolean | false |
| onhandleColorChange | 前景色改变的回调 | Function | - |
| onhandleBgChange | 背景色改变的回调 | Function | - |
注意:当
ColorThemetype 为color时,没有onhandleBgChangeprops,bg同理,当 type 为theme时,theme 是一个包含 color 和 background 的对象数组,当 type 为color时,theme 是一个包含 color 的对象数组。当 type 为bg时,theme 是一个color 数组
LICENSE
MIT@fengshangwuqi
