summaryrefslogtreecommitdiff
path: root/packages/frontend/src/components/MkPreviewWithControls.vue
blob: ad5fd2a01d1629a33a1adb45fea0f63c50f5bc9d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<!--
SPDX-FileCopyrightText: syuilo and misskey-project
SPDX-License-Identifier: AGPL-3.0-only
-->

<template>
<div :class="$style.root">
	<div :class="$style.container">
		<div :class="[$style.preview, prefer.s.animation ? $style.animatedBg : null]">
			<div :class="$style.previewContent">
				<slot name="preview"></slot>
			</div>
			<div v-if="previewLoading" :class="$style.previewLoading">
				<MkLoading/>
			</div>
		</div>
		<div :class="$style.controls">
			<slot name="controls"></slot>
		</div>
	</div>
</div>
</template>

<script lang="ts" setup>
import { prefer } from '@/preferences.js';

const props = withDefaults(defineProps<{
	previewLoading?: boolean;
}>(), {
	previewLoading: false,
});

defineSlots<{
	preview: () => any;
	controls: () => any;
}>();
</script>

<style lang="scss" module>
.root {
	container-type: inline-size;
	height: 100%;
}

.container {
	height: 100%;
	display: grid;
	grid-template-columns: 1fr 400px;
}

.preview {
	position: relative;
	background-color: var(--MI_THEME-bg);
	background-image: linear-gradient(135deg, transparent 30%, var(--MI_THEME-panel) 30%, var(--MI_THEME-panel) 50%, transparent 50%, transparent 80%, var(--MI_THEME-panel) 80%, var(--MI_THEME-panel) 100%);
	background-size: 20px 20px;
}

.previewContent {
	position: relative;
	width: 100%;
	height: 100%;
	overflow: clip;
}

.previewLoading {
	position: absolute;
	inset: 0;
	background-color: color(from var(--MI_THEME-panel) srgb r g b / 0.7);
	display: flex;
	justify-content: center;
	align-items: center;
}

.animatedBg {
	animation: bg 1.2s linear infinite;
}

@keyframes bg {
	0% { background-position: 0 0; }
	100% { background-position: -20px -20px; }
}

.controls {
	overflow-y: scroll;
}

@container (max-width: 800px) {
	.container {
		grid-template-columns: 1fr;
		grid-template-rows: 1fr 1fr;
	}
}
</style>