2023-07-27 07:31:52 +02:00
|
|
|
/*
|
|
|
|
* SPDX-FileCopyrightText: syuilo and other misskey contributors
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
*/
|
|
|
|
|
2021-12-25 17:42:50 +01: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 {
|
|
|
|
return el.parentElement ? getBgColor(el.parentElement) : 'transparent';
|
|
|
|
}
|
2022-06-10 07:36:55 +02:00
|
|
|
};
|
2023-07-08 00:08:16 +02:00
|
|
|
|
2021-12-25 17:42:50 +01:00
|
|
|
const parentBg = getBgColor(src.parentElement);
|
|
|
|
|
|
|
|
const myBg = window.getComputedStyle(src).backgroundColor;
|
|
|
|
|
|
|
|
if (parentBg === myBg) {
|
|
|
|
src.style.borderColor = 'var(--divider)';
|
|
|
|
} else {
|
|
|
|
src.style.borderColor = myBg;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
} as Directive;
|