mirror of
https://github.com/misskey-dev/misskey.git
synced 2026-05-13 21:05:54 +02:00
* wip * add test * use themeManager.currentCompiledTheme for obtaining theme variables / reduce getComputedStyle usage * fix * fix: better error handling on theme installation * Update Changelog * chore: remove frontend-shared builds as it is currently working as a stub package * fix: broken lockfile * fix * fix lint * fix
37 lines
845 B
TypeScript
37 lines
845 B
TypeScript
/*
|
|
* SPDX-FileCopyrightText: syuilo and misskey-project
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
*/
|
|
|
|
import type { Directive } from 'vue';
|
|
import { getBgColor } from '@/utility/get-bg-color.js';
|
|
import { themeManager } from '@/theme.js';
|
|
|
|
const handlerMap = new WeakMap<HTMLElement, () => void>();
|
|
|
|
export const adaptiveBorderDirective = {
|
|
mounted(src) {
|
|
function calc() {
|
|
const parentBg = getBgColor(src.parentElement) ?? 'transparent';
|
|
|
|
const myBg = window.getComputedStyle(src).backgroundColor;
|
|
|
|
if (parentBg === myBg) {
|
|
src.style.borderColor = 'var(--MI_THEME-divider)';
|
|
} else {
|
|
src.style.borderColor = myBg;
|
|
}
|
|
}
|
|
|
|
handlerMap.set(src, calc);
|
|
|
|
calc();
|
|
|
|
themeManager.on('themeChanged', calc);
|
|
},
|
|
|
|
unmounted(src) {
|
|
themeManager.off('themeChanged', handlerMap.get(src));
|
|
},
|
|
} as Directive<HTMLElement>;
|