Sidebar becomes a mobile drawer below 768px
The sidebar was flex:0 0 15rem inside .app__body unconditionally, so on a narrow viewport it and the main content just fought over space. Below 768px it now leaves the flex flow entirely (position: fixed, translated off-canvas by default) and slides in as a drawer instead, leaving .app__main the full width. - App.vue: a ☰ button in the header (hidden above the breakpoint) opens it; a backdrop tap, the drawer's own close button, or any navigation (route.fullPath watcher) closes it. State lives in App.vue since the toggle button is in the header, not the sidebar. - AppSidebar.vue: a close button (✕), only visible in the drawer, emitting 'close'. - Desktop (>=768px) layout and behaviour is untouched -- the drawer CSS and the toggle button both live behind the same media query. Drag-and-drop is untouched, as asked -- this only affects layout, and the sidebar's inbox draggable works the same as before either way. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -62,10 +62,36 @@ body {
|
||||
border-bottom: 1px solid var(--border);
|
||||
}
|
||||
|
||||
.app__bar-left {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.75rem;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.app__brand {
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
/* Opens the sidebar drawer on mobile (see the sidebar's own mobile rules
|
||||
below) -- hidden here, shown only under that same breakpoint. */
|
||||
.app__menu-toggle {
|
||||
display: none;
|
||||
flex: none;
|
||||
border: 1px solid var(--border);
|
||||
background: var(--bg);
|
||||
color: var(--text);
|
||||
border-radius: 8px;
|
||||
padding: 0.35rem 0.55rem;
|
||||
font-size: 1rem;
|
||||
line-height: 1;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.app__menu-toggle:hover {
|
||||
border-color: var(--muted);
|
||||
}
|
||||
|
||||
.app__account {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
@@ -118,6 +144,70 @@ body {
|
||||
background: var(--surface);
|
||||
}
|
||||
|
||||
/* Only shown once .sidebar becomes a drawer, under the mobile breakpoint
|
||||
below -- hidden here. */
|
||||
.sidebar__close {
|
||||
display: none;
|
||||
position: absolute;
|
||||
top: 0.75rem;
|
||||
right: 0.75rem;
|
||||
border: none;
|
||||
background: none;
|
||||
color: var(--muted);
|
||||
cursor: pointer;
|
||||
font-size: 1rem;
|
||||
padding: 0.3rem 0.5rem;
|
||||
border-radius: 6px;
|
||||
}
|
||||
|
||||
.sidebar__close:hover {
|
||||
background: var(--bg);
|
||||
color: var(--text);
|
||||
}
|
||||
|
||||
/* --- mobile: sidebar becomes an off-canvas drawer ---------------------- */
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.app__menu-toggle {
|
||||
display: inline-flex;
|
||||
}
|
||||
|
||||
.app__body {
|
||||
padding: 1rem;
|
||||
}
|
||||
|
||||
.sidebar {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
z-index: 200;
|
||||
width: 85vw;
|
||||
max-width: 20rem;
|
||||
height: 100vh;
|
||||
border: none;
|
||||
border-radius: 0;
|
||||
border-right: 1px solid var(--border);
|
||||
padding-top: 2.75rem;
|
||||
transform: translateX(-100%);
|
||||
transition: transform 0.2s ease;
|
||||
}
|
||||
|
||||
.sidebar--open {
|
||||
transform: translateX(0);
|
||||
}
|
||||
|
||||
.sidebar__close {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.app__drawer-backdrop {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
z-index: 150;
|
||||
background: rgba(0, 0, 0, 0.45);
|
||||
}
|
||||
}
|
||||
|
||||
.sidebar__nav {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
Reference in New Issue
Block a user