Skip to content

Commit 1fb862b

Browse files
committed
hugo: improve site layout on medium screens
- Keep the top-nav menu on medium screens - Keep the sidebar navigation on medium screens - Keep the right-hand toc on large screens - Adjust breakpoints Signed-off-by: David Karlsson <[email protected]>
1 parent 46a3512 commit 1fb862b

File tree

9 files changed

+19
-17
lines changed

9 files changed

+19
-17
lines changed

hugo_stats.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -270,13 +270,14 @@
270270
"leading-snug",
271271
"left-0",
272272
"lg:block",
273-
"lg:flex",
274273
"lg:grid-cols-2",
275274
"lg:grid-cols-3",
276275
"lg:grid-cols-main-lg",
277276
"lg:hidden",
278277
"lg:max-w-[300px]",
279278
"lg:ml-auto",
279+
"lg:no-underline",
280+
"lg:pb-2",
280281
"lg:scale-100",
281282
"lg:text-base",
282283
"lg:w-[1200px]",
@@ -294,11 +295,14 @@
294295
"mb-8",
295296
"md:block",
296297
"md:col-start-3",
298+
"md:flex",
297299
"md:flex-row",
298300
"md:gap-8",
299301
"md:grid-cols-2",
300302
"md:grid-cols-3",
303+
"md:grid-cols-main-md",
301304
"md:h-[334px]",
305+
"md:hidden",
302306
"md:max-w-[66%]",
303307
"md:scale-100",
304308
"min-h-screen",
@@ -417,10 +421,7 @@
417421
"warning",
418422
"xl:grid-cols-3",
419423
"xl:grid-cols-4",
420-
"xl:grid-cols-main",
421-
"xl:hidden",
422-
"xl:no-underline",
423-
"xl:pb-2",
424+
"xl:grid-cols-main-xl",
424425
"xl:w-[1200px]",
425426
"youtube-video",
426427
"z-10",

layouts/_default/baseof.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77

88
<body class="bg-background-light text-base dark:bg-background-dark dark:text-white">
99
{{ partial "header.html" . }}
10-
<main class="grid grid-cols-1 xl:grid-cols-main lg:grid-cols-main-lg">
10+
<main class="grid grid-cols-1 xl:grid-cols-main-xl lg:grid-cols-main-lg md:grid-cols-main-md">
1111
<!-- First column: visible on lg and xl -->
12-
<div class="hidden lg:block bg-background-light dark:bg-gray-dark-100"
12+
<div class="hidden md:block bg-background-light dark:bg-gray-dark-100 overflow-y-scroll"
1313
{{- $classes := "'fixed', 'z-20', 'left-0', 'top-16', 'w-full', 'flex', 'h-lvh'" }}
1414
x-data @togglesidebar.window="
1515
if ($store.showSidebar == false) {

layouts/_default/list.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
{{ with .Title }}
99
<h1 class="scroll-mt-36">{{ . }}</h1>
1010
{{ end }}
11-
<div class="block xl:hidden">
11+
<div class="block lg:hidden">
1212
{{ partial "pagemeta.html" . }}
1313
</div>
1414
{{ .Content }}

layouts/_default/single.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
{{ with .Title }}
99
<h1 class="scroll-mt-36">{{ . }}</h1>
1010
{{ end }}
11-
<div class="block xl:hidden">
11+
<div class="block lg:hidden">
1212
{{ partial "pagemeta.html" . }}
1313
<hr>
1414
</div>

layouts/partials/header.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<div class="flex h-full items-center md:gap-8 gap-2">
44
{{ if not .IsHome }}
55
<button x-data @click="$dispatch('togglesidebar')"
6-
class="icon-svg block px-4 lg:hidden h-full" aria-label="Menu">
6+
class="icon-svg block px-4 md:hidden h-full" aria-label="Menu">
77
{{ partialCached "icon" "menu" "menu" }}
88
</button>
99
{{ end }}

layouts/partials/pagemeta.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
</div>
1515
{{- end }}
1616
{{- with $toc }}
17-
<div class="text-lg pb-0 xl:pb-2">{{ T "tableOfContents" }}</div>
17+
<div class="text-lg pb-0 lg:pb-2">{{ T "tableOfContents" }}</div>
1818
<nav class="toc">
1919
{{ $root := (index page.Fragments.Headings 0).Headings }}
2020
{{- template "walkHeadingFragments" $root }}
@@ -30,7 +30,7 @@
3030
{{- range . }}
3131
{{- if and (ge .Level $min) (le .Level $max) }}
3232
<li>
33-
<a class="link xl:no-underline" href="#{{ .ID }}">{{ .Title }}</a>
33+
<a class="link lg:no-underline" href="#{{ .ID }}">{{ .Title }}</a>
3434
</li>
3535
{{- end }}
3636
{{- with .Headings }}

layouts/partials/sidebar.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
{{ $firstSection := (index ($scratch.GetSortedMapValues "sections") 0).title }}
77

88
{{/* Render the top-nav in sidebar for small screens */}}
9-
<nav class="text-sm pb-4 gap-4 flex lg:hidden flex-col justify-evenly">
9+
<nav class="text-sm pb-4 gap-4 flex md:hidden flex-col justify-evenly">
1010
<div class="text-gray-light dark:text-gray-dark">Main sections</div>
1111
{{ range site.Menus.main }}
1212
<div class="pl-2 underline-offset-8 decoration-2 hover:underline decoration-blue-light dark:decoration-blue-dark hover:opacity-75
@@ -23,7 +23,7 @@
2323
{{ $allSections = $allSections | append (index $e "title") }}
2424
{{ end }}
2525
<nav id="sectiontree" class="text-sm flex flex-col">
26-
<div class="block py-4 lg:hidden text-gray-light dark:text-gray-dark">This section</div>
26+
<div class="block py-4 md:hidden text-gray-light dark:text-gray-dark">This section</div>
2727
{{/* The current page is in the table of contents */}}
2828
<ul>
2929
{{/* Walk the toc.yaml nodes under the current main section */}}

layouts/partials/top-nav.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
{{ $firstSection := (index ($scratch.GetSortedMapValues "sections") 0).title }}
33
<div>
44
<nav>
5-
<ul class="mt-1 box-content hidden gap-4 lg:flex">
5+
<ul class="mt-1 box-content hidden gap-4 md:flex">
66
{{ range site.Menus.main }}
77
<li {{- if or (eq $firstSection .Name) }} class="border-b-4" {{- end }}>
88
<a class="block px-2 py-1" href="{{ .URL }}">{{ .Name }}</a>

tailwind.config.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,9 @@ module.exports = {
4646
}),
4747

4848
gridTemplateColumns: {
49-
'main': 'minmax(300px, 1fr) minmax(840px, 1fr) 1fr',
50-
'main-lg': '300px 1fr',
49+
'main-xl': 'minmax(300px, 1fr) minmax(100ch, 1fr) 1fr',
50+
'main-lg': '300px minmax(75ch, 2fr) 1fr',
51+
'main-md': '250px 1fr',
5152
},
5253
},
5354

0 commit comments

Comments
 (0)