1.0.4 • Published 5 years ago
color-switch v1.0.4
color-switch
用于切换站内主题色
Demo
Example
Scope
DOMElement
- color
- border-color
- background-color
StyleSheet
- color
- border-color
- background-color
SVG
- fill
Installation
$ npm install color-switch --save
Usage
import colorSwitch from 'color-switch'
const fromColorList = [
['000', 'rgb(255, 255, 255)'], // [hex (black), rgb (white)] to #50A5FC (blue)
['#007eff'] // [hex (blue)] to rgb(255, 86, 12) (red)
]
const toColorList = ['#50A5FC', 'rgb(255, 86, 12)'] // [hex (blue), rgb (red)]
colorSwitch(fromColorList, toColorList)
Attention
只需在进入页面时调用该方法,调用后会监听 DOM Tree 及 StyleTag 的变化,动态修改内部相关的色值
如果是 SSR,建议在 Client 端调用(因为 Server 端不支持...略略略)