一个方便的颜色主题组件

644 阅读1分钟

一个方便的颜色主题组件

Build Status npm download license

Demo

安装

yarn add color-theme

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 -

:warning: 注意:当 ColorTheme type 为 color 时,没有 onhandleBgChange props,bg 同理,当 type 为 theme 时,theme 是一个 包含 color 和 background 的对象数组,当 type 为 color 时,theme 是一个 包含 color 的对象数组。当 type 为 bg 时,theme 是一个 color 数组

LICENSE

MIT@fengshangwuqi