Skip to content

Commit 64a7510

Browse files
author
Daniel Precioso, PhD
committed
Refactor navbar styles to simplify active link classes; enhance readability and maintainability
1 parent 36975f6 commit 64a7510

1 file changed

Lines changed: 22 additions & 3 deletions

File tree

layouts/partials/components/headers/navbar.html

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
<style>
2+
#nav-menu .nav-link.active,
3+
#nav-menu .nav-dropdown-link.active {
4+
font-weight: 700;
5+
color: rgb(var(--color-primary-700));
6+
}
7+
8+
.dark #nav-menu .nav-link.active,
9+
.dark #nav-menu .nav-dropdown-link.active {
10+
color: rgb(var(--color-primary-300));
11+
}
12+
13+
#nav-menu:hover .nav-link.active:not(:hover),
14+
#nav-menu:hover .nav-dropdown-link.active:not(:hover) {
15+
font-weight: 600;
16+
color: inherit;
17+
}
18+
</style>
19+
120
<header id="site-header" class="header">
221
<nav class="navbar px-3 flex justify-left">
322
<div class="order-0 h-100">
@@ -63,7 +82,7 @@
6382
class="nav-link {{ range .Children }}
6483
{{ $childURL := .URL | absLangURL }}
6584
{{ $active := eq $childURL $pageURL }}
66-
{{ if $active }}active font-bold text-black/90 dark:text-white{{ end }}
85+
{{ if $active }}active{{ end }}
6786
{{ end }} inline-flex items-center">
6887
{{ .Name }}
6988
<svg class="h-4 w-4 fill-current inline-block" viewBox="0 0 20 20">
@@ -87,7 +106,7 @@
87106
{{- end -}}
88107
<li class="nav-dropdown-item">
89108
<a
90-
class="nav-dropdown-link {{ if $active }}active font-bold text-black/90 dark:text-white{{- end -}}"
109+
class="nav-dropdown-link {{ if $active }}active{{- end -}}"
91110
{{ if findRE `^http` .URL }}
92111
target="_blank" rel="noopener"
93112
{{ end }}
@@ -110,7 +129,7 @@
110129
{{- end -}}
111130
<li class="nav-item">
112131
<a
113-
class="nav-link {{ if $active }}active font-bold text-black/90 dark:text-white{{- end -}}"
132+
class="nav-link {{ if $active }}active{{- end -}}"
114133
{{ if findRE `^http` .URL }}
115134
target="_blank" rel="noopener"
116135
{{ end }}

0 commit comments

Comments
 (0)