feat: added inbuilt themes (#105)

* feat: added inbuilt themes

* docs: added theming docs

* docs: update docs
This commit is contained in:
Anurag Hazra
2020-07-19 20:34:41 +05:30
committed by GitHub
parent b4a9bd4468
commit 2c26329e13
10 changed files with 320 additions and 29 deletions

View File

@@ -3,6 +3,7 @@ const {
encodeHTML,
renderError,
FlexLayout,
getCardColors,
} = require("../src/utils");
describe("Test utils.js", () => {
@@ -49,4 +50,48 @@ describe("Test utils.js", () => {
`<g transform=\"translate(0, 0)\"><text>1</text></g><g transform=\"translate(0, 60)\"><text>2</text></g>`
);
});
it("getCardColors: should return expected values", () => {
let colors = getCardColors({
title_color: "f00",
text_color: "0f0",
icon_color: "00f",
bg_color: "fff",
theme: "dark",
});
expect(colors).toStrictEqual({
titleColor: "#f00",
textColor: "#0f0",
iconColor: "#00f",
bgColor: "#fff",
});
});
it("getCardColors: should fallback to default colors if color is invalid", () => {
let colors = getCardColors({
title_color: "invalidcolor",
text_color: "0f0",
icon_color: "00f",
bg_color: "fff",
theme: "dark",
});
expect(colors).toStrictEqual({
titleColor: "#2f80ed",
textColor: "#0f0",
iconColor: "#00f",
bgColor: "#fff",
});
});
it("getCardColors: should fallback to specified theme colors if is not defined", () => {
let colors = getCardColors({
theme: "dark",
});
expect(colors).toStrictEqual({
titleColor: "#fff",
textColor: "#9f9f9f",
iconColor: "#79ff97",
bgColor: "#151515",
});
});
});