Feat(sidebar): allow left sidebar layout content to toggle the sidebar #159

Open
jakob.scheid wants to merge 3 commits from feature/left-sidebar-layout-content-sidebar-toggling into main
2 changed files with 11 additions and 6 deletions
+6 -1
View File
@@ -61,6 +61,10 @@ onMounted(async () => {
});
settingsLoaded.value = true;
});
const toggleSidebarIfSmallScreen = function toggleSidebarIfSmallScreen (toggleSidebarFunction) {
if (matchMedia('(max-width: 48rem)').matches) toggleSidebarFunction();
};
</script>
<template>
@@ -71,13 +75,14 @@ onMounted(async () => {
</h1>
</header>
<LeftSidebarLayout class="layout">
<template #sidebar>
<template #sidebar="{ toggleSidebar }">
<ul class="sidebar-sections-list">
<li v-for="section in settings">
<RouterLink
:to="`/settings/${section.name}`"
class="button button-link link sidebar-section"
:class="{ active: activeSection === section.name }"
@click="toggleSidebarIfSmallScreen(toggleSidebar)"
>
{{ t(section.i18n) }}
</RouterLink>
+5 -5
View File
@@ -29,7 +29,7 @@ const props = defineProps({
const expanded = ref(props.expanded);
const toggleExpanded = function toggleExpanded () {
const toggleSidebar = function toggleSidebar () {
expanded.value = !expanded.value;
};
</script>
@@ -37,13 +37,13 @@ const toggleExpanded = function toggleExpanded () {
<template>
<div class="layout-container" :class="{ expanded }">
<div class="sidebar-expand-button-container">
<SidebarExpandButton class="sidebar-expand-button" @click="toggleExpanded" />
<SidebarExpandButton class="sidebar-expand-button" @click="toggleSidebar" />
</div>
<Sidebar @toggle-expanded="toggleExpanded" :expanded="expanded" class="sidebar">
<slot name="sidebar" />
<Sidebar @toggle-expanded="toggleSidebar" :expanded="expanded" class="sidebar">
<slot name="sidebar" :toggleSidebar="toggleSidebar" />
</Sidebar>
<main class="main-content">
<slot />
<slot :toggleSidebar="toggleSidebar" />
</main>
</div>
</template>