From e5817cdce3cc07a5aac2fd06f8201bd44954707b Mon Sep 17 00:00:00 2001 From: ryo-ma Date: Sun, 6 Sep 2020 21:09:28 +0900 Subject: [PATCH] Add flat theme --- README.md | 1 + index.ts | 12 ++++-------- src/theme.ts | 28 ++++++++++++++++++++++++++-- 3 files changed, 31 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 9fedcbd..f6c9621 100644 --- a/README.md +++ b/README.md @@ -143,6 +143,7 @@ Available themes. | theme | | ---- | +| flat | | gruvbox | ``` diff --git a/index.ts b/index.ts index 52f0a4d..a7c6dc5 100644 --- a/index.ts +++ b/index.ts @@ -2,7 +2,7 @@ import { ServerRequest } from "./deps.ts"; import { GithubAPIClient } from "./src/github_api_client.ts"; import { Card } from "./src/card.ts"; import { parseParams, CONSTANTS } from "./src/utils.ts"; -import { COLORS } from "./src/theme.ts"; +import { COLORS, Theme } from "./src/theme.ts"; import "https://deno.land/x/dotenv@v0.5.0/load.ts"; const client = new GithubAPIClient(); @@ -13,13 +13,9 @@ export default async (req: ServerRequest) => { const row = params.getNumberValue("row", CONSTANTS.DEFAULT_MAX_ROW); const column = params.getNumberValue("column", CONSTANTS.DEFAULT_MAX_COLUMN); const themeParam: string = params.getStringValue("theme", "default"); - let theme; - switch (themeParam) { - case "gruvbox": - theme = COLORS.gruvbox; - break; - default: - theme = COLORS.default; + let theme: Theme = COLORS.default; + if (Object.keys(COLORS).includes(themeParam)) { + theme = COLORS[themeParam] } const paddingWidth = params.getNumberValue( "padding-w", diff --git a/src/theme.ts b/src/theme.ts index f92c0cb..e18c83b 100644 --- a/src/theme.ts +++ b/src/theme.ts @@ -1,4 +1,4 @@ -export const COLORS = { +export const COLORS: {[name: string]: Theme} = { default: { PRIMARY: "#FFF", SECONDARY: "#000", @@ -23,6 +23,30 @@ export const COLORS = { DEFAULT_RANK_SHADOW: "#333", DEFAULT_RANK_TEXT: "#333", }, + flat: { + PRIMARY: "#FFF", + SECONDARY: "#000", + ICON_CIRCLE: "#FFF", + TEXT: "#666", + LAUREL: "#009366", + SECRET_RANK_1: "red", + SECRET_RANK_2: "fuchsia", + SECRET_RANK_3: "blue", + SECRET_RANK_TEXT: "fuchsia", + NEXT_RANK_BAR: "#0366d6", + S_RANK_BASE: "#eac200", + S_RANK_SHADOW: "#eac200", + S_RANK_TEXT: "#886000", + A_RANK_BASE: "#B0B0B0", + A_RANK_SHADOW: "#B0B0B0", + A_RAKN_TEXT: "#505050", + B_RANK_BASE: "#A18D66", + B_RANK_SHADOW: "#A18D66", + B_RANK_TEXT: "#412D06", + DEFAULT_RANK_BASE: "#777", + DEFAULT_RANK_SHADOW: "#777", + DEFAULT_RANK_TEXT: "#333", + }, gruvbox: { PRIMARY: "#282828", SECONDARY: "#ebdbb2", @@ -72,4 +96,4 @@ export interface Theme { DEFAULT_RANK_BASE: string; DEFAULT_RANK_SHADOW: string; DEFAULT_RANK_TEXT: string; -} \ No newline at end of file +}