From f88f0a157f0a3f8f27e14975e9fc4372a6c1ccb5 Mon Sep 17 00:00:00 2001 From: kakkokari-gtyih <67428053+kakkokari-gtyih@users.noreply.github.com> Date: Fri, 9 May 2025 21:08:30 +0900 Subject: [PATCH] =?UTF-8?q?=E8=89=B2=E3=81=AE=E8=A8=88=E7=AE=97=E3=82=92?= =?UTF-8?q?=E3=82=B3=E3=83=B3=E3=83=9D=E3=83=BC=E3=83=8D=E3=83=B3=E3=83=88?= =?UTF-8?q?=E5=86=85=E3=81=AB=E7=A7=BB=E5=8B=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/MkInstanceTicker.impl.ts | 36 ------------------- .../src/components/MkInstanceTicker.vue | 23 +++++++++++- 2 files changed, 22 insertions(+), 37 deletions(-) delete mode 100644 packages/frontend/src/components/MkInstanceTicker.impl.ts 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