2023-07-27 07:31:52 +02:00
|
|
|
/*
|
2024-02-13 16:59:27 +01:00
|
|
|
* SPDX-FileCopyrightText: syuilo and misskey-project
|
2023-07-27 07:31:52 +02:00
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
*/
|
|
|
|
|
|
2024-10-22 15:55:33 +02:00
|
|
|
import type { ObjectDirective } from 'vue';
|
2021-12-25 17:42:50 +01:00
|
|
|
|
2024-11-01 13:07:35 +01:00
|
|
|
type VAdaptiveBorder = ObjectDirective<HTMLElement, null | undefined>;
|
|
|
|
|
|
|
|
|
|
export const vAdaptiveBorder = {
|
|
|
|
|
async mounted(src) {
|
|
|
|
|
const [
|
|
|
|
|
{ getBgColor },
|
|
|
|
|
] = await Promise.all([
|
|
|
|
|
import('@/scripts/get-bg-color.js'),
|
|
|
|
|
]);
|
|
|
|
|
|
2024-10-19 11:02:09 +02:00
|
|
|
const parentBg = getBgColor(src.parentElement) ?? 'transparent';
|
2021-12-25 17:42:50 +01:00
|
|
|
|
|
|
|
|
const myBg = window.getComputedStyle(src).backgroundColor;
|
|
|
|
|
|
|
|
|
|
if (parentBg === myBg) {
|
2024-10-09 11:08:14 +02:00
|
|
|
src.style.borderColor = 'var(--MI_THEME-divider)';
|
2021-12-25 17:42:50 +01:00
|
|
|
} else {
|
|
|
|
|
src.style.borderColor = myBg;
|
|
|
|
|
}
|
|
|
|
|
},
|
2024-11-01 13:07:35 +01:00
|
|
|
} satisfies VAdaptiveBorder as VAdaptiveBorder;
|