/
index.js
36 lines (30 loc) · 922 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import { ColorThemePlugin, ColorThemeMixin, ColorThemeActionsMixin } from 'vuestic-ui/src/services/ColorThemePlugin'
import { getHoverColor, getGradientBackground, hex2rgb, hex2hsl } from 'vuestic-ui/src/services/color-functions'
const colorShiftHsl = (main, offset = { h: 0, s: 0, l: 0 }) => {
offset = {
h: offset.h || 0,
s: offset.s || 0,
l: offset.l || 0,
}
const color = hex2hsl(main)
const normalizeParam = (value, params = { start: 0, end: 100 }) =>
value < params.start
? params.start
: value > params.end
? params.end
: value
color.h = normalizeParam(color.h + offset.h, { end: 360 })
color.s = normalizeParam(color.s + offset.s)
color.l = normalizeParam(color.l + offset.l)
return color
}
export {
ColorThemePlugin,
ColorThemeMixin,
ColorThemeActionsMixin,
getHoverColor,
getGradientBackground,
hex2rgb,
hex2hsl,
colorShiftHsl,
}