mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-10 12:25:02 +00:00
Add case icons. Clean up !cases. Allow customizing case colors and icons.
This commit is contained in:
parent
ad24d166ce
commit
131a79ffd4
24 changed files with 138 additions and 22 deletions
17
backend/src/utils/tColor.ts
Normal file
17
backend/src/utils/tColor.ts
Normal file
|
@ -0,0 +1,17 @@
|
|||
import * as t from "io-ts";
|
||||
import { either } from "fp-ts/lib/Either";
|
||||
import { convertDelayStringToMS } from "../utils";
|
||||
import { parseColor } from "./parseColor";
|
||||
import { rgbToInt } from "./rgbToInt";
|
||||
import { intToRgb } from "./intToRgb";
|
||||
|
||||
export const tColor = new t.Type<number, string>(
|
||||
"tColor",
|
||||
(s): s is number => typeof s === "number",
|
||||
(from, to) =>
|
||||
either.chain(t.string.validate(from, to), input => {
|
||||
const parsedColor = parseColor(input);
|
||||
return parsedColor == null ? t.failure(from, to, "Invalid color") : t.success(rgbToInt(parsedColor));
|
||||
}),
|
||||
s => intToRgb(s).join(","),
|
||||
);
|
Loading…
Add table
Add a link
Reference in a new issue