Skip to content

Commit 3b4b1b6

Browse files
committed
mobile header improved style
1 parent 513decd commit 3b4b1b6

3 files changed

Lines changed: 111 additions & 9 deletions

File tree

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,5 +106,7 @@ onclick: () => openDashboardPane(outliner, element.tabName || element.paneName)
106106
* Auto: don't add each menu item in a button looking border. Simply list them.
107107
Upon hover apply background color e6dcff and selected or active to be background color: cbb9ff
108108

109-
* Raptor mini: the menu dissapears not when on mobile. That is great.
110-
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.
109+
* Raptor mini: the menu dissapears when on mobile. That is great.
110+
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.
111+
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

src/mainPage/menu.css

Lines changed: 66 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
display: flex;
33
flex-direction: column;
44
gap: 0.5rem;
5+
padding-top: 0.75rem;
56
}
67

78
.menu-item {
@@ -45,7 +46,7 @@
4546
.menu-toggle {
4647
position: fixed;
4748
top: 0.5rem;
48-
left: 2.75rem;
49+
left: 1rem;
4950
z-index: 300;
5051
display: inline-flex;
5152
align-items: center;
@@ -68,23 +69,81 @@
6869

6970
.app-nav {
7071
position: relative;
72+
display: flex;
73+
flex-direction: column;
74+
background: var(--color-background);
7175
}
7276

73-
.app-nav.mobile-hidden {
74-
transform: translateX(-100%);
75-
transition: transform 0.25s ease-in-out;
77+
.app-nav.mobile-hidden,
78+
.app-nav.mobile-visible {
7679
position: fixed;
7780
left: 0;
78-
top: 4.5rem;
81+
top: 0;
7982
bottom: 0;
80-
z-index: 110;
8183
width: min(80vw, 320px);
84+
height: 100vh;
85+
min-height: 100vh;
86+
transform: translateX(-100%);
87+
transition: transform 0.25s ease-in-out;
88+
z-index: 999;
89+
display: flex;
90+
flex-direction: column;
91+
background: var(--color-background);
92+
border-right: none;
93+
box-shadow: none;
94+
overflow: hidden;
95+
padding-top: 3.75rem;
8296
}
8397

8498
.app-nav.mobile-visible {
8599
transform: translateX(0);
86-
display: block;
87100
visibility: visible;
101+
background: var(--color-background);
102+
}
103+
104+
.menu-header {
105+
display: none;
106+
position: absolute;
107+
top: 0;
108+
left: 0;
109+
right: 0;
110+
align-items: center;
111+
justify-content: flex-start;
112+
background-color: #42345a !important;
113+
color: #ffffff;
114+
font-weight: 600;
115+
min-height: 3.75rem;
116+
height: 3.75rem;
117+
box-sizing: border-box;
118+
width: 100%;
119+
z-index: 1000;
120+
border-right: none;
121+
box-shadow: none;
122+
}
123+
124+
.app-nav.mobile-hidden .menu-header,
125+
.app-nav.mobile-visible .menu-header {
126+
display: flex;
127+
}
128+
129+
.menu-header-title {
130+
font-size: 1.25rem;
131+
color: #ffffff;
132+
}
133+
134+
.menu-close {
135+
border: none;
136+
background: transparent;
137+
color: #ffffff;
138+
font-size: 1.25rem;
139+
cursor: pointer;
140+
padding-left: 1.25rem;
141+
line-height: 1;
142+
}
143+
144+
.menu-close:hover,
145+
.menu-close:focus {
146+
opacity: 0.85;
88147
}
89148

90149
.app-nav.collapsed {

src/mainPage/menu.ts

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,24 @@ const ensureMenuSkeleton = () => {
6767
navMenu.className = 'app-nav'
6868
navMenu.setAttribute('aria-label', 'App navigation')
6969

70+
const headerEl = document.createElement('div')
71+
headerEl.className = 'menu-header'
72+
73+
const closeBtn = document.createElement('button')
74+
closeBtn.id = 'MenuCloseBtn'
75+
closeBtn.className = 'menu-close'
76+
closeBtn.type = 'button'
77+
closeBtn.setAttribute('aria-label', 'Close menu')
78+
closeBtn.textContent = '✕'
79+
headerEl.appendChild(closeBtn)
80+
81+
const title = document.createElement('span')
82+
title.className = 'menu-header-title'
83+
title.textContent = 'Menu'
84+
headerEl.appendChild(title)
85+
86+
navMenu.appendChild(headerEl)
87+
7088
const authStateEl = document.createElement('div')
7189
authStateEl.id = 'AuthState'
7290
authStateEl.className = 'menu-auth-state'
@@ -78,6 +96,24 @@ const ensureMenuSkeleton = () => {
7896
navMenu.appendChild(contentEl)
7997

8098
root.insertBefore(navMenu, root.firstChild)
99+
} else if (!navMenu.querySelector('.menu-header')) {
100+
const headerEl = document.createElement('div')
101+
headerEl.className = 'menu-header'
102+
103+
const closeBtn = document.createElement('button')
104+
closeBtn.id = 'MenuCloseBtn'
105+
closeBtn.className = 'menu-close'
106+
closeBtn.type = 'button'
107+
closeBtn.setAttribute('aria-label', 'Close menu')
108+
closeBtn.textContent = '✕'
109+
headerEl.appendChild(closeBtn)
110+
111+
const title = document.createElement('span')
112+
title.className = 'menu-header-title'
113+
title.textContent = 'Menu'
114+
headerEl.appendChild(title)
115+
116+
navMenu.insertBefore(headerEl, navMenu.firstChild)
81117
}
82118

83119
let toggle = document.getElementById('MenuToggleBtn') as HTMLButtonElement | null
@@ -275,6 +311,11 @@ export const createLeftSideMenu = async (subject: NamedNode, outliner: OutlineMa
275311
menuOverlay.addEventListener('click', closeMobileMenu)
276312
}
277313

314+
const closeBtn = document.getElementById('MenuCloseBtn') as HTMLButtonElement | null
315+
if (closeBtn) {
316+
closeBtn.addEventListener('click', closeMobileMenu)
317+
}
318+
278319
if (navMenuContent) {
279320
await renderMenuItems(subject, outliner, navMenuContent)
280321

0 commit comments

Comments
 (0)