Skip to content

Commit fd0da2c

Browse files
committed
colapse menu button improved
1 parent 3b4b1b6 commit fd0da2c

3 files changed

Lines changed: 25 additions & 4 deletions

File tree

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,4 +109,6 @@ Upon hover apply background color e6dcff and selected or active to be background
109109
* Raptor mini: the menu dissapears when on mobile. That is great.
110110
I want the menu to have a tiny button on the bottom margin left with an arrow to the left or right for expanding the menu or for making it small. This is only for web. When we make it small it folds and only displays the icons of teh menu items, when it is expanded it should also add the labels to the menu items.
111111

112-
* Raptor mini: i want to imporve the left side menu on mobile. When the menu is visible it should be higher, the top part should be on top of the header, folding out and in with the rest of the menu. It should have an x close button and it should say menu. The locor of that top line of the header should be the color of the header 332746
112+
* Raptor mini: i want to imporve the left side menu on mobile. When the menu is visible it should be higher, the top part should be on top of the header, folding out and in with the rest of the menu. It should have an x close button and it should say menu. The locor of that top line of the header should be the color of the header 332746
113+
114+
* Raptor mini: the menu, on desktop, has a button to fold in or out. I want the same behavior to occur also when i simply click the folded in menu: it should expend. Not just when i click the dedicated button

src/mainPage/menu.css

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,9 +179,10 @@
179179
border: 1px solid var(--color-border);
180180
border-radius: 999px;
181181
color: var(--color-text);
182-
font-size: 0.75rem;
182+
font-size: 1.3rem;
183183
line-height: 1;
184184
cursor: pointer;
185+
box-shadow: 0 1px 4px rgba(124,77,255,0.12);
185186
}
186187

187188
@media (max-width: 768px) {

src/mainPage/menu.ts

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,26 @@ export const createLeftSideMenu = async (subject: NamedNode, outliner: OutlineMa
287287
menuOverlay.hidden = false
288288
}
289289

290+
const collapseBtn = document.getElementById('MenuCollapseBtn') as HTMLButtonElement | null
291+
292+
const expandDesktopMenu = () => {
293+
if (!navMenu || !collapseBtn) return
294+
if (!menuCollapsed) return
295+
menuCollapsed = false
296+
saveMenuCollapsedState(menuCollapsed)
297+
applyMenuCollapsedState(navMenu)
298+
}
299+
300+
if (navMenu) {
301+
navMenu.addEventListener('click', (event) => {
302+
const isMobile = outliner.context?.environment?.layout === 'mobile'
303+
const clickedCollapseButton = (event.target as HTMLElement).closest('#MenuCollapseBtn')
304+
if (!isMobile && menuCollapsed && !clickedCollapseButton) {
305+
expandDesktopMenu()
306+
}
307+
})
308+
}
309+
290310
if (menuToggle) {
291311
menuToggle.hidden = false
292312
menuToggle.addEventListener('click', () => {
@@ -297,8 +317,6 @@ export const createLeftSideMenu = async (subject: NamedNode, outliner: OutlineMa
297317
}
298318
})
299319
}
300-
301-
const collapseBtn = document.getElementById('MenuCollapseBtn') as HTMLButtonElement | null
302320
if (collapseBtn) {
303321
collapseBtn.addEventListener('click', () => {
304322
menuCollapsed = !menuCollapsed

0 commit comments

Comments
 (0)