feat(sidebar): implement sidebar visibility toggling

This commit is contained in:
2026-07-31 20:59:19 +02:00
committed by Gitea
parent 5b1f2b57a7
commit e43784bff0
2 changed files with 47 additions and 5 deletions
+15 -2
View File
@@ -16,14 +16,27 @@ limitations under the License.
<script setup>
import SidebarExpandButton from './SidebarExpandButton.vue';
const props = defineProps({
'expanded': {
default: false,
required: false,
type: Boolean
}
});
const emit = defineEmits(['toggleExpanded']);
const toggleSidebar = function toggleSidebar () {
emit('toggleExpanded');
};
</script>
<template>
<nav class="sidebar">
<div class="sidebar-controls">
<SidebarExpandButton />
<SidebarExpandButton @click="toggleSidebar" />
</div>
<div class="sidebar-content">
<div class="sidebar-content" v-if="props.expanded">
<slot />
</div>
</nav>
+32 -3
View File
@@ -16,11 +16,26 @@ limitations under the License.
<script setup>
import Sidebar from '@/features/sidebar/components/Sidebar.vue';
import { ref } from 'vue';
const props = defineProps({
'expanded': {
default: false,
required: false,
type: Boolean
}
});
const expanded = ref(props.expanded);
const toggleExpanded = function toggleExpanded () {
expanded.value = !expanded.value;
};
</script>
<template>
<div class="layout-container">
<Sidebar>
<div class="layout-container" :class="{ expanded }">
<Sidebar @toggle-expanded="toggleExpanded" :expanded="expanded">
<slot name="sidebar" />
</Sidebar>
<main class="main-content">
@@ -32,10 +47,24 @@ import Sidebar from '@/features/sidebar/components/Sidebar.vue';
<style scoped>
.layout-container {
display: grid;
grid-template-columns: min(24%, 280px) 1fr;
grid-template-columns: 72px 1fr;
border-top: 1px solid var(--border);
}
.layout-container.expanded {
grid-template-columns: min(24%, 280px) 1fr;
}
@media (max-width: 48rem) {
.layout-container {
grid-template-columns: 0 1fr;
}
.layout-container.expanded {
grid-template-columns: 1fr 0;
}
}
.main-content {
padding: 20px;
}