Skip to content

Commit 9258979

Browse files
authored
Improve navigation styling and experience (#856)
Merge pull request 856
1 parent 1e8a445 commit 9258979

File tree

5 files changed

+73
-55
lines changed

5 files changed

+73
-55
lines changed

README.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,8 @@ Refers to snippets of code within the `_includes` directory that can be inserted
8585
- `google-analytics.html` — Inserts Google Analytics module (active only in production environment).
8686
- `head.html` &mdash; Code-block that defines the `<head></head>` in *default* layout.
8787
- `custom-head.html` &mdash; Placeholder to allow users to add more metadata to `<head />`.
88-
- `header.html` &mdash; Defines the site's main header section. By default, pages with a defined `title` attribute will have links displayed here.
88+
- `header.html` &mdash; Defines the site's main header section that consists of the site's *title* and *navigation*.
89+
- `nav-items.html` &mdash; Contains the logic and markup to render individual link items for the site's navigation.
8990
- `social.html` &mdash; Renders social-media icons based on the `minima:social_links` data in the config file using
9091
the latest version of Font Awesome Free webfonts via remote CDN.
9192
- `sub-footer.html` &mdash; Placeholder to allow inserting markup (e.g. deferred scripts) before the `</body>` tag.
@@ -215,10 +216,13 @@ This allows you to set which pages you want to appear in the navigation area and
215216
For instance, to only link to the `about` and the `portfolio` page, add the following to your `_config.yml`:
216217

217218
```yaml
218-
header_pages:
219-
- about.md
220-
- portfolio.md
219+
minima:
220+
nav_pages:
221+
- about.md
222+
- portfolio.md
221223
```
224+
> [!WARNING]
225+
> Please note that **`site.header_pages`** is **`site.minima.nav_pages`** in Minima 3.0
222226

223227

224228
### Change default date format

_config.yml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,6 @@ plugins:
2424
- jekyll-feed
2525
- jekyll-seo-tag
2626

27-
# Theme-specific settings
28-
29-
# If you want to link only specific pages in your header, use this and add the path to the pages
30-
# in order as they should show up.
31-
header_pages:
32-
- about.md
33-
3427
# Minima specific settings, which are only available from Minima 3.0 onward.
3528
minima:
3629
# Minima skin selection.
@@ -43,6 +36,12 @@ minima:
4336
# solarized Adaptive skin for solarized color scheme skins.
4437
skin: classic
4538

39+
# If you want to link only specific pages in the site-navigation, use this and list
40+
# the `path` property (as represented via Liquid) of the pages in the order they should
41+
# be rendered.
42+
nav_pages:
43+
- about.md
44+
4645
# Set to `true` to show excerpts on the homepage.
4746
#show_excerpts: false
4847

_includes/header.html

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,26 @@
22

33
<div class="wrapper">
44
{%- assign default_paths = site.pages | map: "path" -%}
5-
{%- assign page_paths = site.header_pages | default: default_paths -%}
6-
{%- assign titles_size = site.pages | map: 'title' | join: '' | size -%}
5+
{%- assign page_paths = site.minima.nav_pages | default: default_paths -%}
6+
{%- assign page_titles = site.pages | map: 'title' | compact %}
77
<a class="site-title" rel="author" href="{{ '/' | relative_url }}">{{ site.title | escape }}</a>
88

9-
{%- if titles_size > 0 -%}
9+
{%- unless page_titles == empty %}
1010
<nav class="site-nav">
1111
<input type="checkbox" id="nav-trigger" class="nav-trigger" />
1212
<label for="nav-trigger">
13-
<span class="menu-icon">
14-
<svg viewBox="0 0 18 15" width="18px" height="15px">
15-
<path d="M18,1.484c0,0.82-0.665,1.484-1.484,1.484H1.484C0.665,2.969,0,2.304,0,1.484l0,0C0,0.665,0.665,0,1.484,0 h15.032C17.335,0,18,0.665,18,1.484L18,1.484z M18,7.516C18,8.335,17.335,9,16.516,9H1.484C0.665,9,0,8.335,0,7.516l0,0 c0-0.82,0.665-1.484,1.484-1.484h15.032C17.335,6.031,18,6.696,18,7.516L18,7.516z M18,13.516C18,14.335,17.335,15,16.516,15H1.484 C0.665,15,0,14.335,0,13.516l0,0c0-0.82,0.665-1.483,1.484-1.483h15.032C17.335,12.031,18,12.695,18,13.516L18,13.516z"/>
16-
</svg>
17-
</span>
13+
<span class="menu-icon fas fa-bars fa-lg"></span>
1814
</label>
1915

20-
<div class="trigger">
21-
{%- for path in page_paths -%}
22-
{%- assign my_page = site.pages | where: "path", path | first -%}
23-
{%- if my_page.title -%}
24-
<a class="page-link" href="{{ my_page.url | relative_url }}">{{ my_page.title | escape }}</a>
25-
{%- endif -%}
26-
{%- endfor -%}
16+
<div class="drawer-container">
17+
<div class="drawer">
18+
{%- include nav-items.html paths = page_paths %}
19+
</div>
20+
</div>
21+
<div class="slab">
22+
{%- include nav-items.html paths = page_paths %}
2723
</div>
2824
</nav>
29-
{%- endif -%}
25+
{%- endunless %}
3026
</div>
3127
</header>

_includes/nav-items.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{%- for path in include.paths -%}
2+
{%- assign hyperpage = site.pages | where: "path", path | first -%}
3+
{%- if hyperpage.title %}
4+
<a class="nav-item" href="{{ hyperpage.url | relative_url }}">{{ hyperpage.title | escape }}</a>
5+
{%- endif -%}
6+
{%- endfor -%}

_sass/minima/_layout.scss

Lines changed: 41 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
* Site header
33
*/
44
.site-header {
5-
border-top: 5px solid $border-color-03;
6-
border-bottom: 1px solid $border-color-01;
5+
position: fixed;
6+
width: 100%;
77
min-height: $spacing-unit * 1.865;
88
line-height: $base-line-height * $base-font-size * 2.25;
9-
10-
// Positioning context for the mobile navigation icon
11-
position: relative;
9+
background-color: $background-color;
10+
border-top: 5px solid $border-color-03;
11+
border-bottom: 1px solid $border-color-01;
1212
}
1313

1414
.site-title {
@@ -37,7 +37,7 @@
3737
border-radius: 5px;
3838
text-align: right;
3939

40-
.nav-trigger {
40+
.nav-trigger, .slab {
4141
display: none;
4242
}
4343

@@ -46,7 +46,7 @@
4646
width: 36px;
4747
height: 26px;
4848
line-height: 0;
49-
padding-top: 10px;
49+
padding-top: 18px;
5050
text-align: center;
5151

5252
> svg path {
@@ -63,27 +63,39 @@
6363
cursor: pointer;
6464
}
6565

66-
input ~ .trigger {
66+
#nav-trigger ~ .drawer-container {
67+
position: absolute;
68+
top: 47px;
69+
right: -16px;
6770
clear: both;
68-
display: none;
71+
width: 0;
72+
height: calc(100vh - 60px);
73+
transition: width 1s;
74+
overflow: hidden;
75+
background-color: $background-color;
76+
border-left: 1px solid;
77+
border-left-color: transparent;
78+
.drawer { opacity: 0 }
6979
}
7080

71-
input:checked ~ .trigger {
72-
display: block;
81+
#nav-trigger:checked ~ .drawer-container {
82+
width: 180px;
7383
padding-bottom: 5px;
84+
transition: width 1s;
85+
overflow: auto;
86+
border-left-color: $border-color-01;
87+
.drawer {
88+
padding: $spacing-unit * 0.5;
89+
opacity: 1;
90+
transition: opacity 2s;
91+
}
7492
}
7593

76-
.page-link {
94+
.nav-item {
95+
display: block;
96+
padding: 5px 0;
7797
color: $text-color;
7898
line-height: $base-line-height;
79-
display: block;
80-
padding: 5px 10px;
81-
margin-left: 20px;
82-
83-
// Gaps between nav items, but not on the last one
84-
&:not(:last-child) {
85-
margin-right: 0;
86-
}
8799
}
88100

89101
@media screen and (min-width: $on-medium) {
@@ -92,25 +104,24 @@
92104
border: none;
93105
background-color: inherit;
94106

107+
.drawer-container,
108+
.menu-icon,
95109
label[for="nav-trigger"] {
96110
display: none;
97111
}
98112

99-
.menu-icon {
100-
display: none;
101-
}
102-
103-
input ~ .trigger {
113+
.slab {
104114
display: block;
115+
padding-top: 1px;
105116
}
106117

107-
.page-link {
118+
.nav-item {
108119
display: inline;
109120
padding: 0;
110121
margin-left: auto;
111122

112123
&:not(:last-child) {
113-
margin-right: 20px;
124+
margin-right: $spacing-unit * 0.5;
114125
}
115126
}
116127
}
@@ -201,7 +212,9 @@
201212
* Page content
202213
*/
203214
.page-content {
204-
padding: $spacing-unit 0;
215+
padding-top: 60px + $spacing-unit;
216+
padding-inline: 0;
217+
padding-bottom: $spacing-unit;
205218
flex: 1 0 auto;
206219
}
207220

0 commit comments

Comments
 (0)