Extract theme to theme.ts

This commit is contained in:
ryo-ma 2020-09-06 11:37:24 +09:00
parent 587689f000
commit 89d8c54d07
6 changed files with 83 additions and 79 deletions

View file

@ -1,7 +1,8 @@
import { ServerRequest } from "./deps.ts";
import { GithubAPIClient } from "./src/github_api_client.ts";
import { Card } from "./src/card.ts";
import { parseParams, COLORS, CONSTANTS } from "./src/utils.ts";
import { parseParams, CONSTANTS } from "./src/utils.ts";
import { COLORS } from "./src/theme.ts";
import "https://deno.land/x/dotenv@v0.5.0/load.ts";
const client = new GithubAPIClient();

View file

@ -11,7 +11,8 @@ import {
AncientAccountTrophy,
} from "./trophies.ts";
import { UserInfo } from "./github_api_client.ts";
import { CONSTANTS, RANK_ORDER, RANK, Theme } from "./utils.ts";
import { RANK_ORDER, RANK } from "./utils.ts";
import { Theme } from "./theme.ts";
export class Card {
private width = 0;

View file

@ -1,4 +1,5 @@
import { RANK, Theme } from "./utils.ts";
import { RANK } from "./utils.ts";
import { Theme } from "./theme.ts";
const leafIcon = (laurel: string): string => {
return `<svg xmlns="http://www.w3.org/2000/svg" version="1.0" width="90pt" height="90pt" viewBox="0 0 100 100" preserveAspectRatio="xMidYMid meet">

75
src/theme.ts Normal file
View file

@ -0,0 +1,75 @@
export const COLORS = {
default: {
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: "#FAD200",
S_RANK_SHADOW: "#C8A090",
S_RANK_TEXT: "#886000",
A_RANK_BASE: "#B0B0B0",
A_RANK_SHADOW: "#9090C0",
A_RAKN_TEXT: "#505050",
B_RANK_BASE: "#A18D66",
B_RANK_SHADOW: "#816D96",
B_RANK_TEXT: "#412D06",
DEFAULT_RANK_BASE: "#777",
DEFAULT_RANK_SHADOW: "#333",
DEFAULT_RANK_TEXT: "#333",
},
gruvbox: {
PRIMARY: "#282828",
SECONDARY: "#ebdbb2",
ICON_CIRCLE: "#ebdbb2",
TEXT: "#98971a",
LAUREL: "#689d6a",
SECRET_RANK_1: "#fb4934",
SECRET_RANK_2: "#d3869b",
SECRET_RANK_3: "#458588",
SECRET_RANK_TEXT: "#b16286",
NEXT_RANK_BAR: "#fabd26",
S_RANK_BASE: "#fabd2f",
S_RANK_SHADOW: "#fabd2f",
S_RANK_TEXT: "#322301",
A_RANK_BASE: "#83a598",
A_RANK_SHADOW: "#83a598",
A_RAKN_TEXT: "#151e1a",
B_RANK_BASE: "#d65d0e",
B_RANK_SHADOW: "#d65d0e",
B_RANK_TEXT: "#301503",
DEFAULT_RANK_BASE: "#928374",
DEFAULT_RANK_SHADOW: "#928374",
DEFAULT_RANK_TEXT: "#282828",
},
};
export interface Theme {
PRIMARY: string;
SECONDARY: string;
ICON_CIRCLE: string;
TEXT: string;
LAUREL: string;
SECRET_RANK_1: string;
SECRET_RANK_2: string;
SECRET_RANK_3: string;
SECRET_RANK_TEXT: string;
NEXT_RANK_BAR: string;
S_RANK_BASE: string;
S_RANK_SHADOW: string;
S_RANK_TEXT: string;
A_RANK_BASE: string;
A_RANK_SHADOW: string;
A_RAKN_TEXT: string;
B_RANK_BASE: string;
B_RANK_SHADOW: string;
B_RANK_TEXT: string;
DEFAULT_RANK_BASE: string;
DEFAULT_RANK_SHADOW: string;
DEFAULT_RANK_TEXT: string;
}

View file

@ -1,5 +1,6 @@
import { getTrophyIcon, getNextRankBar } from "./icons.ts";
import { CONSTANTS, RANK, abridgeScore, RANK_ORDER, Theme } from "./utils.ts";
import { CONSTANTS, RANK, abridgeScore, RANK_ORDER } from "./utils.ts";
import { Theme } from "./theme.ts";
class RankCondition {
constructor(

View file

@ -68,80 +68,5 @@ export enum RANK {
UNKNOWN = "?",
}
export const COLORS = {
default: {
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: "#FAD200",
S_RANK_SHADOW: "#C8A090",
S_RANK_TEXT: "#886000",
A_RANK_BASE: "#B0B0B0",
A_RANK_SHADOW: "#9090C0",
A_RAKN_TEXT: "#505050",
B_RANK_BASE: "#A18D66",
B_RANK_SHADOW: "#816D96",
B_RANK_TEXT: "#412D06",
DEFAULT_RANK_BASE: "#777",
DEFAULT_RANK_SHADOW: "#333",
DEFAULT_RANK_TEXT: "#333",
},
gruvbox: {
PRIMARY: "#282828",
SECONDARY: "#ebdbb2",
ICON_CIRCLE: "#ebdbb2",
TEXT: "#98971a",
LAUREL: "#689d6a",
SECRET_RANK_1: "#fb4934",
SECRET_RANK_2: "#d3869b",
SECRET_RANK_3: "#458588",
SECRET_RANK_TEXT: "#b16286",
NEXT_RANK_BAR: "#fabd26",
S_RANK_BASE: "#fabd2f",
S_RANK_SHADOW: "#fabd2f",
S_RANK_TEXT: "#322301",
A_RANK_BASE: "#83a598",
A_RANK_SHADOW: "#83a598",
A_RAKN_TEXT: "#151e1a",
B_RANK_BASE: "#d65d0e",
B_RANK_SHADOW: "#d65d0e",
B_RANK_TEXT: "#301503",
DEFAULT_RANK_BASE: "#928374",
DEFAULT_RANK_SHADOW: "#928374",
DEFAULT_RANK_TEXT: "#282828",
},
};
export interface Theme {
PRIMARY: string;
SECONDARY: string;
ICON_CIRCLE: string;
TEXT: string;
LAUREL: string;
SECRET_RANK_1: string;
SECRET_RANK_2: string;
SECRET_RANK_3: string;
SECRET_RANK_TEXT: string;
NEXT_RANK_BAR: string;
S_RANK_BASE: string;
S_RANK_SHADOW: string;
S_RANK_TEXT: string;
A_RANK_BASE: string;
A_RANK_SHADOW: string;
A_RAKN_TEXT: string;
B_RANK_BASE: string;
B_RANK_SHADOW: string;
B_RANK_TEXT: string;
DEFAULT_RANK_BASE: string;
DEFAULT_RANK_SHADOW: string;
DEFAULT_RANK_TEXT: string;
}
export const RANK_ORDER = Object.values(RANK);