mirror of
https://github.com/paricafe/misskey.git
synced 2024-11-25 18:56:43 -06:00
24 lines
681 B
TypeScript
24 lines
681 B
TypeScript
import { Directive } from 'vue';
|
|
|
|
export default {
|
|
mounted(src, binding, vn) {
|
|
const getBgColor = (el: HTMLElement) => {
|
|
const style = window.getComputedStyle(el);
|
|
if (style.backgroundColor && !['rgba(0, 0, 0, 0)', 'rgba(0,0,0,0)', 'transparent'].includes(style.backgroundColor)) {
|
|
return style.backgroundColor;
|
|
} else {
|
|
return getBgColor(el.parentElement);
|
|
}
|
|
}
|
|
|
|
const parentBg = getBgColor(src.parentElement);
|
|
|
|
const myBg = getComputedStyle(document.documentElement).getPropertyValue('--panel');
|
|
|
|
if (parentBg === myBg) {
|
|
src.style.backgroundColor = 'var(--bg)';
|
|
} else {
|
|
src.style.backgroundColor = 'var(--panel)';
|
|
}
|
|
},
|
|
} as Directive;
|