summaryrefslogtreecommitdiff
path: root/packages/frontend/src/scripts
diff options
context:
space:
mode:
authorかっこかり <67428053+kakkokari-gtyih@users.noreply.github.com>2024-10-19 18:02:09 +0900
committerGitHub <noreply@github.com>2024-10-19 18:02:09 +0900
commit2250e521e4bcfa1b162cd46091da1bead5abcac0 (patch)
tree908aac984abb83e32dee350e5b06b74a9f8fbb0f /packages/frontend/src/scripts
parentenhance(frontend): Bull Dashboard に relationship queue を追加 (#14777) (diff)
downloadsharkey-2250e521e4bcfa1b162cd46091da1bead5abcac0.tar.gz
sharkey-2250e521e4bcfa1b162cd46091da1bead5abcac0.tar.bz2
sharkey-2250e521e4bcfa1b162cd46091da1bead5abcac0.zip
refactor(frontend): getBgColorを共通化 (#14782)
* refactor: getBgColor関数の切り出し + fix types (taiyme#291) * move thing * revert unnecesary changes --------- Co-authored-by: taiy <53635909+taiyme@users.noreply.github.com>
Diffstat (limited to 'packages/frontend/src/scripts')
-rw-r--r--packages/frontend/src/scripts/get-bg-color.ts18
1 files changed, 18 insertions, 0 deletions
diff --git a/packages/frontend/src/scripts/get-bg-color.ts b/packages/frontend/src/scripts/get-bg-color.ts
new file mode 100644
index 0000000000..ccf60b454f
--- /dev/null
+++ b/packages/frontend/src/scripts/get-bg-color.ts
@@ -0,0 +1,18 @@
+/*
+ * SPDX-FileCopyrightText: syuilo and misskey-project
+ * SPDX-License-Identifier: AGPL-3.0-only
+ */
+
+import tinycolor from 'tinycolor2';
+
+export const getBgColor = (elem?: Element | null | undefined): string | null => {
+ if (elem == null) return null;
+
+ const { backgroundColor: bg } = window.getComputedStyle(elem);
+
+ if (bg && tinycolor(bg).getAlpha() !== 0) {
+ return bg;
+ }
+
+ return getBgColor(elem.parentElement);
+};