summaryrefslogtreecommitdiff
path: root/packages/frontend/src/components/global/MkSpacer.vue
blob: db01c10eb074e4f5069a5fb58b2509e5ba665dbb (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
<!--
SPDX-FileCopyrightText: syuilo and misskey-project
SPDX-License-Identifier: AGPL-3.0-only
-->

<template>
<div :class="[$style.root, { [$style.rootMin]: forceSpacerMin }]">
	<div :class="$style.content">
		<slot></slot>
	</div>
</div>
</template>

<script lang="ts" setup>
import { inject } from 'vue';
import { deviceKind } from '@/scripts/device-kind.js';

const props = withDefaults(defineProps<{
	contentMax?: number | null;
	marginMin?: number;
	marginMax?: number;
}>(), {
	contentMax: null,
	marginMin: 12,
	marginMax: 24,
});

const forceSpacerMin = inject('forceSpacerMin', false) || deviceKind === 'smartphone';
</script>

<style lang="scss" module>
.root {
	box-sizing: border-box;
	width: 100%;
}
.rootMin {
	padding: v-bind('props.marginMin + "px"') !important;
}

.content {
	margin: 0 auto;
	max-width: v-bind('props.contentMax + "px"');
	container-type: inline-size;
}

@container (max-width: 450px) {
	.root {
		padding: v-bind('props.marginMin + "px"');
	}
}

@container (min-width: 451px) {
	.root {
		padding: v-bind('props.marginMax + "px"');
	}
}
</style>