2021-11-28 05:07:37 -06:00
|
|
|
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 {
|
2021-12-25 10:42:50 -06:00
|
|
|
return el.parentElement ? getBgColor(el.parentElement) : 'transparent';
|
2021-11-28 05:07:37 -06:00
|
|
|
}
|
2022-06-10 00:36:55 -05:00
|
|
|
};
|
2021-11-28 05:07:37 -06:00
|
|
|
|
|
|
|
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;
|