UnisKB/ui/src/components/layout-container/index.vue

88 lines
1.8 KiB
Vue
Raw Normal View History

2025-04-30 06:53:42 +00:00
<template>
<div class="layout-container flex h-full">
2025-07-04 09:42:12 +00:00
<div :class="`layout-container__left border-r ${isCollapse ? 'hidden' : ''}`">
<div class="layout-container__left_content">
<slot name="left"></slot>
</div>
2025-07-08 12:50:19 +00:00
<el-tooltip
:content="isCollapse ? $t('common.expand') : $t('common.collapse')"
placement="right"
>
<el-button
v-if="props.showCollapse"
class="collapse"
size="small"
circle
@click="isCollapse = !isCollapse"
:icon="isCollapse ? 'ArrowRightBold' : 'ArrowLeftBold'"
/>
2025-07-04 09:42:12 +00:00
</el-tooltip>
2025-04-30 06:53:42 +00:00
</div>
<div class="layout-container__right">
<slot></slot>
</div>
</div>
</template>
<script setup lang="ts">
2025-07-04 09:42:12 +00:00
import { computed, useSlots, ref } from 'vue'
2025-04-30 06:53:42 +00:00
defineOptions({ name: 'LayoutContainer' })
const slots = useSlots()
const props = defineProps({
header: String || null,
backTo: String,
2025-07-08 12:50:19 +00:00
showCollapse: Boolean,
2025-04-30 06:53:42 +00:00
})
2025-07-04 09:42:12 +00:00
const isCollapse = ref(false)
2025-04-30 06:53:42 +00:00
const showBack = computed(() => {
const { backTo } = props
return backTo
})
</script>
<style lang="scss" scoped>
.layout-container {
&__left {
2025-07-04 09:42:12 +00:00
position: relative;
2025-04-30 06:53:42 +00:00
box-sizing: border-box;
transition: width 0.28s;
width: var(--sidebar-width);
min-width: var(--sidebar-width);
2025-07-04 09:42:12 +00:00
box-sizing: border-box;
.collapse {
position: absolute;
top: 36px;
right: -15px;
2025-07-08 12:50:19 +00:00
box-shadow: 0px 5px 10px 0px rgba(31, 35, 41, 0.1);
2025-07-04 09:42:12 +00:00
z-index: 1;
}
.layout-container__left_content {
width: 100%;
2025-07-07 06:23:36 +00:00
// height: 100%;
2025-07-04 09:42:12 +00:00
}
&.hidden {
width: 0;
min-width: 0;
.layout-container__left_content {
visibility: hidden;
}
.collapse {
right: -18px;
}
}
2025-04-30 06:53:42 +00:00
}
2025-07-04 09:42:12 +00:00
2025-04-30 06:53:42 +00:00
&__right {
2025-07-04 09:42:12 +00:00
flex: 1;
overflow: hidden;
2025-04-30 06:53:42 +00:00
}
}
</style>