summaryrefslogtreecommitdiff
path: root/packages/frontend/src/components/MkAsUi.vue
diff options
context:
space:
mode:
Diffstat (limited to 'packages/frontend/src/components/MkAsUi.vue')
-rw-r--r--packages/frontend/src/components/MkAsUi.vue27
1 files changed, 25 insertions, 2 deletions
diff --git a/packages/frontend/src/components/MkAsUi.vue b/packages/frontend/src/components/MkAsUi.vue
index 7e150f7dd5..e2af4f034e 100644
--- a/packages/frontend/src/components/MkAsUi.vue
+++ b/packages/frontend/src/components/MkAsUi.vue
@@ -54,7 +54,7 @@ SPDX-License-Identifier: AGPL-3.0-only
<MkAsUi v-if="!g(child).hidden" :component="g(child)" :components="props.components" :size="size"/>
</template>
</MkFolder>
- <div v-else-if="c.type === 'container'" :class="[$style.container, { [$style.fontSerif]: c.font === 'serif', [$style.fontMonospace]: c.font === 'monospace' }]" :style="{ textAlign: c.align, backgroundColor: c.bgColor, color: c.fgColor, borderWidth: c.borderWidth ? `${c.borderWidth}px` : 0, borderColor: c.borderColor ?? 'var(--divider)', padding: c.padding ? `${c.padding}px` : 0, borderRadius: c.rounded ? '8px' : 0 }">
+ <div v-else-if="c.type === 'container'" :class="[$style.container, { [$style.fontSerif]: c.font === 'serif', [$style.fontMonospace]: c.font === 'monospace' }]" :style="containerStyle">
<template v-for="child in c.children" :key="child">
<MkAsUi v-if="!g(child).hidden" :component="g(child)" :components="props.components" :size="size" :align="c.align"/>
</template>
@@ -63,7 +63,7 @@ SPDX-License-Identifier: AGPL-3.0-only
</template>
<script lang="ts" setup>
-import { Ref, ref } from 'vue';
+import { Ref, ref, computed } from 'vue';
import * as os from '@/os.js';
import MkButton from '@/components/MkButton.vue';
import MkInput from '@/components/MkInput.vue';
@@ -97,6 +97,29 @@ function g(id) {
} as AsUiRoot;
}
+const containerStyle = computed(() => {
+ if (c.type !== 'container') return undefined;
+
+ // width, color, styleのうち一つでも指定があれば、枠線がちゃんと表示されるようにwidthとstyleのデフォルト値を設定
+ // radiusは単に角を丸める用途もあるため除外
+ const isBordered = c.borderWidth ?? c.borderColor ?? c.borderStyle;
+
+ const border = isBordered ? {
+ borderWidth: c.borderWidth ?? '1px',
+ borderColor: c.borderColor ?? 'var(--divider)',
+ borderStyle: c.borderStyle ?? 'solid',
+ } : undefined;
+
+ return {
+ textAlign: c.align,
+ backgroundColor: c.bgColor,
+ color: c.fgColor,
+ padding: c.padding ? `${c.padding}px` : 0,
+ borderRadius: (c.borderRadius ?? (c.rounded ? 8 : 0)) + 'px',
+ ...border,
+ };
+});
+
const valueForSwitch = ref('default' in c && typeof c.default === 'boolean' ? c.default : false);
function onSwitchUpdate(v) {