diff --git a/packages/frontend/src/components/MkInstanceTicker.impl.ts b/packages/frontend/src/components/MkInstanceTicker.impl.ts deleted file mode 100644 index f59a2b6103..0000000000 --- a/packages/frontend/src/components/MkInstanceTicker.impl.ts +++ /dev/null @@ -1,36 +0,0 @@ -/* - * SPDX-FileCopyrightText: syuilo and misskey-project - * SPDX-License-Identifier: AGPL-3.0-only - */ - -import tinycolor from 'tinycolor2'; - -type ITickerColors = { - readonly bg: string; - readonly fg: string; -}; - -const TICKER_YUV_THRESHOLD = 191 as const; -const TICKER_FG_COLOR_LIGHT = '#ffffff' as const; -const TICKER_FG_COLOR_DARK = '#2f2f2fcc' as const; - -const tickerColorsCache = new Map(); - -export const getTickerColors = (bgHex: string): ITickerColors => { - const cachedTickerColors = tickerColorsCache.get(bgHex); - if (cachedTickerColors != null) return cachedTickerColors; - - const tinycolorInstance = tinycolor(bgHex); - const { r, g, b } = tinycolorInstance.toRgb(); - const yuv = 0.299 * r + 0.587 * g + 0.114 * b; - const fgHex = yuv > TICKER_YUV_THRESHOLD ? TICKER_FG_COLOR_DARK : TICKER_FG_COLOR_LIGHT; - - const tickerColors = { - fg: fgHex, - bg: bgHex, - } as const satisfies ITickerColors; - - tickerColorsCache.set(tinycolorInstance.toHex(), tickerColors); - - return tickerColors; -}; diff --git a/packages/frontend/src/components/MkInstanceTicker.vue b/packages/frontend/src/components/MkInstanceTicker.vue index 751ffe5e2d..62ff806096 100644 --- a/packages/frontend/src/components/MkInstanceTicker.vue +++ b/packages/frontend/src/components/MkInstanceTicker.vue @@ -12,11 +12,11 @@ SPDX-License-Identifier: AGPL-3.0-only