generated from Seekra/repository-template
feat(sidebar): add sidebar expand button to left sidebar layout
Added a sidebar expand button to the left sidebar layout that is shown on small screens when the sidebar is not expanded.
This commit is contained in:
@@ -16,6 +16,7 @@ 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 SidebarExpandButton from '@/features/sidebar/components/SidebarExpandButton.vue';
|
||||||
import { ref } from 'vue';
|
import { ref } from 'vue';
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
@@ -35,7 +36,10 @@ const toggleExpanded = function toggleExpanded () {
|
|||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="layout-container" :class="{ expanded }">
|
<div class="layout-container" :class="{ expanded }">
|
||||||
<Sidebar @toggle-expanded="toggleExpanded" :expanded="expanded">
|
<div class="sidebar-expand-button-container">
|
||||||
|
<SidebarExpandButton class="sidebar-expand-button" @click="toggleExpanded" />
|
||||||
|
</div>
|
||||||
|
<Sidebar @toggle-expanded="toggleExpanded" :expanded="expanded" class="sidebar">
|
||||||
<slot name="sidebar" />
|
<slot name="sidebar" />
|
||||||
</Sidebar>
|
</Sidebar>
|
||||||
<main class="main-content">
|
<main class="main-content">
|
||||||
@@ -48,6 +52,10 @@ const toggleExpanded = function toggleExpanded () {
|
|||||||
.layout-container {
|
.layout-container {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: 72px 1fr;
|
grid-template-columns: 72px 1fr;
|
||||||
|
grid-template-rows: auto 1fr;
|
||||||
|
grid-template-areas:
|
||||||
|
"sidebar-expand sidebar-expand"
|
||||||
|
"sidebar main-content";
|
||||||
border-top: 1px solid var(--border);
|
border-top: 1px solid var(--border);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -55,6 +63,15 @@ const toggleExpanded = function toggleExpanded () {
|
|||||||
grid-template-columns: min(24%, 280px) 1fr;
|
grid-template-columns: min(24%, 280px) 1fr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.sidebar-expand-button-container {
|
||||||
|
grid-area: sidebar-expand;
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sidebar {
|
||||||
|
grid-area: sidebar;
|
||||||
|
}
|
||||||
|
|
||||||
@media (max-width: 48rem) {
|
@media (max-width: 48rem) {
|
||||||
.layout-container {
|
.layout-container {
|
||||||
grid-template-columns: 0 1fr;
|
grid-template-columns: 0 1fr;
|
||||||
@@ -63,9 +80,20 @@ const toggleExpanded = function toggleExpanded () {
|
|||||||
.layout-container.expanded {
|
.layout-container.expanded {
|
||||||
grid-template-columns: 1fr 0;
|
grid-template-columns: 1fr 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.layout-container:not(.expanded) .sidebar-expand-button-container {
|
||||||
|
justify-content: end;
|
||||||
|
display: block;
|
||||||
|
padding: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.layout-container:not(.expanded) .main-content {
|
||||||
|
padding-top: 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.main-content {
|
.main-content {
|
||||||
|
grid-area: main-content;
|
||||||
padding: 20px;
|
padding: 20px;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
Reference in New Issue
Block a user