mirror of
https://github.com/hex248/sprint.git
synced 2026-02-07 18:23:03 +00:00
moved isLight to utils
This commit is contained in:
@@ -1,17 +1,5 @@
|
|||||||
import { DEFAULT_STATUS_COLOUR } from "@issue/shared";
|
import { DEFAULT_STATUS_COLOUR } from "@issue/shared";
|
||||||
import { cn } from "@/lib/utils";
|
import { cn, DARK_TEXT_COLOUR, isLight } from "@/lib/utils";
|
||||||
|
|
||||||
const DARK_TEXT_COLOUR = "#0a0a0a";
|
|
||||||
const THRESHOLD = 0.6;
|
|
||||||
|
|
||||||
const isLight = (hex: string): boolean => {
|
|
||||||
const num = Number.parseInt(hex.replace("#", ""), 16);
|
|
||||||
const r = (num >> 16) & 255;
|
|
||||||
const g = (num >> 8) & 255;
|
|
||||||
const b = num & 255;
|
|
||||||
const luminance = (0.299 * r + 0.587 * g + 0.114 * b) / 255;
|
|
||||||
return luminance > THRESHOLD;
|
|
||||||
};
|
|
||||||
|
|
||||||
export default function StatusTag({
|
export default function StatusTag({
|
||||||
status,
|
status,
|
||||||
|
|||||||
@@ -50,3 +50,15 @@ export function formatTime(ms: number): string {
|
|||||||
.toString()
|
.toString()
|
||||||
.padStart(2, "0")}`;
|
.padStart(2, "0")}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const DARK_TEXT_COLOUR = "#0a0a0a";
|
||||||
|
const THRESHOLD = 0.6;
|
||||||
|
|
||||||
|
export const isLight = (hex: string): boolean => {
|
||||||
|
const num = Number.parseInt(hex.replace("#", ""), 16);
|
||||||
|
const r = (num >> 16) & 255;
|
||||||
|
const g = (num >> 8) & 255;
|
||||||
|
const b = num & 255;
|
||||||
|
const luminance = (0.299 * r + 0.587 * g + 0.114 * b) / 255;
|
||||||
|
return luminance > THRESHOLD;
|
||||||
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user