generated from Seekra/repository-template
Feat(sidebar): implement sidebar toggling #157
@@ -16,14 +16,27 @@ limitations under the License.
|
|||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import SidebarExpandButton from './SidebarExpandButton.vue';
|
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>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<nav class="sidebar">
|
<nav class="sidebar">
|
||||||
<div class="sidebar-controls">
|
<div class="sidebar-controls">
|
||||||
<SidebarExpandButton />
|
<SidebarExpandButton @click="toggleSidebar" />
|
||||||
</div>
|
</div>
|
||||||
<div class="sidebar-content">
|
<div class="sidebar-content" v-if="props.expanded">
|
||||||
<slot />
|
<slot />
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
|
|||||||
@@ -16,11 +16,26 @@ limitations under the License.
|
|||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import Sidebar from '@/features/sidebar/components/Sidebar.vue';
|
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>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="layout-container">
|
<div class="layout-container" :class="{ expanded }">
|
||||||
<Sidebar>
|
<Sidebar @toggle-expanded="toggleExpanded" :expanded="expanded">
|
||||||
<slot name="sidebar" />
|
<slot name="sidebar" />
|
||||||
</Sidebar>
|
</Sidebar>
|
||||||
<main class="main-content">
|
<main class="main-content">
|
||||||
@@ -32,10 +47,24 @@ import Sidebar from '@/features/sidebar/components/Sidebar.vue';
|
|||||||
<style scoped>
|
<style scoped>
|
||||||
.layout-container {
|
.layout-container {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: min(24%, 280px) 1fr;
|
grid-template-columns: 72px 1fr;
|
||||||
border-top: 1px solid var(--border);
|
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 {
|
.main-content {
|
||||||
padding: 20px;
|
padding: 20px;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user