From 44e2f502651b354d99b73f12707d4f4ac23516d6 Mon Sep 17 00:00:00 2001 From: Ewen Le Bihan Date: Mon, 11 May 2020 22:40:30 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=8C=20=3Dindex:=20Add=20`lightColor`?= =?UTF-8?q?=20and=20`darkColor`=20getters?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- store/index.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/store/index.js b/store/index.js index 095f45c..ff9761a 100644 --- a/store/index.js +++ b/store/index.js @@ -86,6 +86,16 @@ export const getters = { * on backgroundColor: either 'black' or 'white'. */ tinycolor(backgroundColor).isLight() ? 'black' : 'white', + lightColor: () => baseColor => { + /* see https://codepen.io/ewen-lbh/pen/dyYKWVL */ + const { h, s } = tinycolor(baseColor).toHsl() + return tinycolor({ h, s: 2 * s, l: 0.9 }).toHslString() + }, + darkColor: () => baseColor => { + /* see https://codepen.io/ewen-lbh/pen/dyYKWVL */ + const { h, s } = tinycolor(baseColor).toHsl() + return tinycolor({ h, s: 0.25 * s, l: 0.4 }).toHslString() + }, formatTime: (state, getters) => time => { if (time === null) return null return format(time, 'HH:mm')