Skip to content

Commit 8d997ad

Browse files
Responsive navbar (fixes #3)
1 parent a257d89 commit 8d997ad

File tree

4 files changed

+92
-42
lines changed

4 files changed

+92
-42
lines changed

web/resources/article.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{{ article.html_content }}
22

3-
<div style="text-align: left; font-size: 0.8em; color: #b5b5b5; position: absolute; bottom: 0; padding-bottom: 20px; width: 100%;">
3+
<div style="text-align: left; font-size: 0.8em; color: #b5b5b5; position: absolute; bottom: 0; padding-bottom: 20px; max-width: 100%;">
44
<div>Article: <strong>{{ article.title }}</strong></div>
55
<div style="margin-top: 0.5em;">Written by <i class="fab fa-github"></i> <a href="https://github.com/{{ article.author }}" rel="noopener" target="_blank">{{ article.author }}</a> on {{ article.date }}</div>
66
</div>

web/resources/assets/style.css

Lines changed: 71 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -110,13 +110,37 @@ hr {
110110
width: 6px;
111111
}
112112

113+
114+
.function-type-title {
115+
float: right;
116+
font-size: 1.8em;
117+
padding-left: 1em;
118+
padding-top: 11px;
119+
position: relative;
120+
z-index: 1;
121+
}
122+
123+
124+
footer {
125+
border-top: 1px solid #394a60;
126+
color: #9F9FA2;
127+
padding: 1em 0;
128+
text-align: center;
129+
}
130+
footer p {
131+
margin-top: 1em;
132+
margin-bottom: 1em;
133+
}
134+
135+
136+
113137
header {
114138
background: #151b23 url(/assets/color-strip.png) no-repeat left bottom / 100% 3px;
115139
overflow: hidden;
116140
}
117141

118142
#logo {
119-
max-width: 100%;
143+
max-width: 80vw;
120144
max-height: 100%;
121145
}
122146
#logo:hover {
@@ -140,28 +164,6 @@ header {
140164
border-radius: 0.25em;
141165
}
142166

143-
.function-type-title {
144-
float: right;
145-
font-size: 1.8em;
146-
padding-left: 1em;
147-
padding-top: 11px;
148-
position: relative;
149-
z-index: 1;
150-
}
151-
152-
153-
footer {
154-
border-top: 1px solid #394a60;
155-
color: #9F9FA2;
156-
padding: 1em 0;
157-
text-align: center;
158-
}
159-
footer p {
160-
margin-top: 1em;
161-
margin-bottom: 1em;
162-
}
163-
164-
165167

166168
/* Grid container */
167169
.grid-container {
@@ -170,7 +172,53 @@ footer p {
170172
grid-template-rows: auto;
171173
}
172174

175+
176+
173177
/* Sidebar styles */
178+
179+
180+
/* Ensure #menu-toggle is hidden on larger screens */
181+
#menu-toggle {
182+
display: none;
183+
}
184+
185+
/* Hide sidebar on smaller screens */
186+
@media (max-width: 768px) {
187+
.grid-container {
188+
grid-template-columns: 1fr;
189+
}
190+
191+
.sidebar-left {
192+
display: none;
193+
position: fixed;
194+
top: 40px;
195+
left: 0;
196+
height: 100%;
197+
width: 250px;
198+
background: #151b23;
199+
box-shadow: 2px 0 5px rgba(0, 0, 0, 0.1);
200+
overflow-y: auto;
201+
z-index: 1000;
202+
}
203+
204+
.sidebar-left.open {
205+
display: block;
206+
}
207+
208+
#menu-toggle {
209+
display: inline-block;
210+
background: none;
211+
border: none;
212+
font-size: 1.5rem;
213+
color: white;
214+
cursor: pointer;
215+
margin-left: auto;
216+
position: absolute;
217+
bottom: 20px;
218+
right: 20px;
219+
}
220+
}
221+
174222
.sidebar-left {
175223
padding: 20px;
176224
border-right: 1px solid #394a60;

web/resources/layout.html

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,15 @@
6868
{% if preview_mode %}
6969
<div class="preview-badge">Preview</div>
7070
{% endif %}
71-
71+
<!-- Add a menu button for mobile -->
72+
<button id="menu-toggle" aria-label="Toggle navigation">
73+
<i class="fa-solid fa-bars"></i>
74+
</button>
7275
</div>
7376
</header>
7477

7578
<div class="grid-container">
76-
<nav class="sidebar-left">
79+
<nav class="sidebar-left" id="sidebar">
7780
<ul>
7881
{% for item in navigation %}
7982
{% if item.path_html %}
@@ -101,5 +104,16 @@
101104
<p><a href="/privacy">Privacy policy</a></p>
102105
</div>
103106
</footer>
107+
108+
<script>
109+
document.addEventListener('DOMContentLoaded', () => {
110+
const menuToggle = document.getElementById('menu-toggle');
111+
const sidebar = document.getElementById('sidebar');
112+
113+
menuToggle.addEventListener('click', () => {
114+
sidebar.classList.toggle('open');
115+
});
116+
});
117+
</script>
104118
</body>
105119
</html>

web/scripts/builder.py

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ def create_function(self, function_name):
216216

217217
return function
218218

219-
def create_article(self, article_name, article_parent_path='', custom_web_path=False, custom_web_title=False):
219+
def create_article(self, article_name, article_parent_path='', custom_web_path=False):
220220
article_real_path = os.path.join(DOCS_REPO_PATH, 'articles', article_parent_path, article_name, f"article.yaml")
221221
article = utils.load_and_validate_yaml(article_real_path, self.schema_article)
222222

@@ -228,7 +228,7 @@ def create_article(self, article_name, article_parent_path='', custom_web_path=F
228228
article_template = self.input_env.get_template('article.html')
229229
article["html_content"] = markdown.markdown(article['content'])
230230
html_content = self.render_page(
231-
custom_web_title or article['title'],
231+
article['title'],
232232
article_template.render(article=article)
233233
)
234234
if custom_web_path:
@@ -346,25 +346,13 @@ def create_misc_pages(self):
346346
def create_pages(self):
347347
self.navigation = [
348348
{
349-
'name': 'Home',
349+
'name': 'Introduction',
350350
'path_html': '/',
351351
'article': {
352352
'name': 'introduction',
353353
'folder': '',
354354
},
355355
},
356-
{
357-
'name': 'How you can help',
358-
'path_html': '/How_you_can_help',
359-
},
360-
{
361-
'name': 'Recent changes',
362-
'path_html': '/Recent_changes',
363-
},
364-
{
365-
'name': 'Random page',
366-
'path_html': '/Random_page',
367-
},
368356
{
369357
'name': 'Guides',
370358
'subitems': [
@@ -438,7 +426,7 @@ def create_pages(self):
438426

439427
def create_item(item):
440428
if 'article' in item:
441-
self.create_article(item['article']['name'], item['article']['folder'], item['path_html'], item["name"])
429+
self.create_article(item['article']['name'], item['article']['folder'], item['path_html'])
442430
elif 'category' in item:
443431
self.create_category(item['path_html'], item['category'])
444432

0 commit comments

Comments
 (0)