monkeeShark/packages/frontend/src/components/global/MkSpacer.vue

58 lines
1.1 KiB
Vue
Raw Normal View History

<!--
SPDX-FileCopyrightText: syuilo and other misskey contributors
SPDX-License-Identifier: AGPL-3.0-only
-->
2021-10-14 11:55:59 +00:00
<template>
<div :class="[$style.root, { [$style.rootMin]: forceSpacerMin }]">
<div :class="$style.content">
2021-10-14 11:55:59 +00:00
<slot></slot>
</div>
</div>
</template>
2022-06-22 07:29:31 +00:00
<script lang="ts" setup>
import { inject } from 'vue';
2023-09-19 07:37:43 +00:00
import { deviceKind } from '@/scripts/device-kind.js';
2021-10-14 11:55:59 +00:00
2022-06-22 07:29:31 +00:00
const props = withDefaults(defineProps<{
contentMax?: number | null;
marginMin?: number;
marginMax?: number;
}>(), {
contentMax: null,
marginMin: 12,
marginMax: 24,
});
2021-10-14 11:55:59 +00:00
const forceSpacerMin = inject('forceSpacerMin', false) || deviceKind === 'smartphone';
2021-10-14 11:55:59 +00:00
</script>
<style lang="scss" module>
.root {
box-sizing: border-box;
width: 100%;
}
.rootMin {
padding: v-bind('props.marginMin + "px"') !important;
}
2021-10-14 11:55:59 +00:00
.content {
margin: 0 auto;
max-width: v-bind('props.contentMax + "px"');
container-type: inline-size;
2021-10-14 11:55:59 +00:00
}
2023-01-07 02:49:04 +00:00
@container (max-width: 450px) {
.root {
padding: v-bind('props.marginMin + "px"');
}
}
2023-01-07 02:49:04 +00:00
@container (min-width: 451px) {
.root {
padding: v-bind('props.marginMax + "px"');
}
}
2021-10-14 11:55:59 +00:00
</style>