Github integration (#6414)

Co-authored-by: Tom Moor <tom.moor@gmail.com>
This commit is contained in:
Apoorv Mishra
2024-03-23 19:39:28 +05:30
committed by GitHub
parent a648625700
commit 450d0d9355
47 changed files with 1710 additions and 93 deletions

View File

@@ -35,3 +35,17 @@ export const stringToColor = (input: string) => {
*/
export const toRGB = (color: string) =>
Object.values(parseToRgb(color)).join(", ");
/**
* Returns the text color that contrasts the given background color
*
* @param background - A color string
* @returns A color string
*/
export const getTextColor = (background: string) => {
const r = parseInt(background.substring(1, 3), 16);
const g = parseInt(background.substring(3, 5), 16);
const b = parseInt(background.substring(5, 7), 16);
const yiq = (r * 299 + g * 587 + b * 114) / 1000;
return yiq >= 128 ? "black" : "white";
};