Skip to content

Commit b4e9d6e

Browse files
committed
Add Download buttons and sandwich menu
1 parent 1c89ab1 commit b4e9d6e

1 file changed

Lines changed: 169 additions & 0 deletions

File tree

_includes/head-custom.html

Lines changed: 169 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,172 @@
1111
gtag('config', '{{ site.google_analytics }}');
1212
</script>
1313
{% endif %}
14+
15+
<!-- Floating hamburger menu for quick site navigation -->
16+
<style>
17+
.site-menu-toggle {
18+
position: fixed;
19+
top: 14px;
20+
right: 14px;
21+
z-index: 9999;
22+
width: 44px;
23+
height: 44px;
24+
border: 1px solid rgba(0, 0, 0, 0.18);
25+
border-radius: 10px;
26+
background: #ffffff;
27+
color: #1f2937;
28+
cursor: pointer;
29+
box-shadow: 0 6px 14px rgba(0, 0, 0, 0.16);
30+
display: flex;
31+
align-items: center;
32+
justify-content: center;
33+
font-size: 22px;
34+
line-height: 1;
35+
}
36+
37+
.site-menu-panel {
38+
position: fixed;
39+
top: 64px;
40+
right: 14px;
41+
z-index: 9998;
42+
min-width: 220px;
43+
border: 1px solid rgba(0, 0, 0, 0.14);
44+
border-radius: 10px;
45+
background: #ffffff;
46+
box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
47+
padding: 8px;
48+
}
49+
50+
.site-menu-panel[hidden] {
51+
display: none;
52+
}
53+
54+
.site-menu-list {
55+
list-style: none;
56+
margin: 0;
57+
padding: 0;
58+
}
59+
60+
.site-menu-list li {
61+
margin: 0;
62+
padding: 0;
63+
}
64+
65+
.site-menu-list a {
66+
display: block;
67+
padding: 10px 12px;
68+
border-radius: 8px;
69+
color: #111827;
70+
text-decoration: none;
71+
font-weight: 600;
72+
font-size: 14px;
73+
}
74+
75+
.site-menu-list a:hover,
76+
.site-menu-list a:focus {
77+
background: #f3f4f6;
78+
outline: none;
79+
}
80+
</style>
81+
82+
<script>
83+
document.addEventListener('DOMContentLoaded', function () {
84+
if (document.querySelector('[data-site-menu="toggle"]')) {
85+
return;
86+
}
87+
88+
var links = [
89+
{ label: 'Home', href: '{{ "/" | relative_url }}' },
90+
{ label: 'FAQ', href: '{{ "/faq/" | relative_url }}' },
91+
{ label: 'Scripts', href: '{{ "/scripts/" | relative_url }}' },
92+
{ label: 'Details', href: '{{ "/details/" | relative_url }}' },
93+
{ label: 'VS Code Info', href: '{{ "/docs/vscode-info/" | relative_url }}' }
94+
];
95+
96+
var toggle = document.createElement('button');
97+
toggle.type = 'button';
98+
toggle.className = 'site-menu-toggle';
99+
toggle.setAttribute('aria-label', 'Open navigation menu');
100+
toggle.setAttribute('aria-expanded', 'false');
101+
toggle.setAttribute('data-site-menu', 'toggle');
102+
toggle.textContent = '\u2630';
103+
104+
var panel = document.createElement('nav');
105+
panel.className = 'site-menu-panel';
106+
panel.setAttribute('aria-label', 'Site navigation');
107+
panel.setAttribute('data-site-menu', 'panel');
108+
panel.hidden = true;
109+
110+
var list = document.createElement('ul');
111+
list.className = 'site-menu-list';
112+
113+
links.forEach(function (item) {
114+
var listItem = document.createElement('li');
115+
var anchor = document.createElement('a');
116+
anchor.href = item.href;
117+
anchor.textContent = item.label;
118+
listItem.appendChild(anchor);
119+
list.appendChild(listItem);
120+
});
121+
122+
panel.appendChild(list);
123+
document.body.appendChild(toggle);
124+
document.body.appendChild(panel);
125+
126+
function closeMenu() {
127+
panel.hidden = true;
128+
toggle.setAttribute('aria-expanded', 'false');
129+
}
130+
131+
function openMenu() {
132+
panel.hidden = false;
133+
toggle.setAttribute('aria-expanded', 'true');
134+
}
135+
136+
toggle.addEventListener('click', function (event) {
137+
event.stopPropagation();
138+
if (panel.hidden) {
139+
openMenu();
140+
} else {
141+
closeMenu();
142+
}
143+
});
144+
145+
panel.addEventListener('click', function (event) {
146+
event.stopPropagation();
147+
});
148+
149+
document.addEventListener('click', function () {
150+
closeMenu();
151+
});
152+
153+
document.addEventListener('keydown', function (event) {
154+
if (event.key === 'Escape') {
155+
closeMenu();
156+
}
157+
});
158+
});
159+
</script>
160+
161+
<script>
162+
document.addEventListener('DOMContentLoaded', function () {
163+
var pageHeader = document.querySelector('.page-header');
164+
if (!pageHeader || pageHeader.querySelector('[data-site-download-zip="true"]')) {
165+
return;
166+
}
167+
168+
var zipButton = document.createElement('a');
169+
zipButton.className = 'btn';
170+
zipButton.href = 'https://github.com/yaravind/dev-tools/archive/refs/heads/main.zip';
171+
zipButton.textContent = 'Download .zip';
172+
zipButton.setAttribute('data-site-download-zip', 'true');
173+
174+
// Insert before Cayman's optional GitHub project button when present.
175+
var firstBtn = pageHeader.querySelector('.btn');
176+
if (firstBtn) {
177+
pageHeader.insertBefore(zipButton, firstBtn);
178+
} else {
179+
pageHeader.appendChild(zipButton);
180+
}
181+
});
182+
</script>

0 commit comments

Comments
 (0)