Skip to content

Commit 59b78ce

Browse files
committed
Navbar styling fixes and updated documentation
1 parent d5132bf commit 59b78ce

File tree

13 files changed

+326
-108
lines changed

13 files changed

+326
-108
lines changed

.vscode/cspell.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"hugo",
1616
"isset",
1717
"markdownify",
18+
"navbars",
1819
"nvmrc",
1920
"Occitan",
2021
"refcache",

assets/js/base.js

Lines changed: 17 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -32,33 +32,23 @@ limitations under the License.
3232
return element.offset().top + element.outerHeight();
3333
}
3434

35-
// Bootstrap Fixed Header
36-
$(function() {
37-
var promo = $(".js-td-cover");
38-
if (!promo.length) {
39-
return
40-
}
41-
42-
var promoOffset = bottomPos(promo);
43-
var navbarOffset = $('.js-navbar-scroll').offset().top;
44-
45-
var threshold = Math.ceil($('.js-navbar-scroll').outerHeight());
46-
if ((promoOffset - navbarOffset) < threshold) {
47-
$('.js-navbar-scroll').addClass('navbar-bg-onscroll');
48-
}
49-
50-
51-
$(window).on('scroll', function() {
52-
var navtop = $('.js-navbar-scroll').offset().top - $(window).scrollTop();
53-
var promoOffset = bottomPos($('.js-td-cover'));
54-
var navbarOffset = $('.js-navbar-scroll').offset().top;
55-
if ((promoOffset - navbarOffset) < threshold) {
56-
$('.js-navbar-scroll').addClass('navbar-bg-onscroll');
57-
} else {
58-
$('.js-navbar-scroll').removeClass('navbar-bg-onscroll');
59-
$('.js-navbar-scroll').addClass('navbar-bg-onscroll--fade');
60-
}
61-
});
35+
// Navbar transparency over cover images
36+
$(function () {
37+
const promo = $('.js-td-cover');
38+
if (!promo.length) return;
39+
const navbar = $('.js-navbar-scroll');
40+
if (!navbar.length) return;
41+
42+
const threshold = Math.ceil(navbar.outerHeight());
43+
44+
function adjustNavbarTransparency() {
45+
const promoOffset = bottomPos(promo);
46+
const navbarOffset = navbar.offset().top;
47+
navbar.toggleClass('td-navbar-transparent', (promoOffset - navbarOffset) >= threshold);
48+
}
49+
50+
adjustNavbarTransparency();
51+
$(window).on('scroll', adjustNavbarTransparency);
6252
});
6353

6454
// Navbar overflow detection with scroll indicators

assets/scss/td/_nav.scss

Lines changed: 32 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,25 @@
11
//
22
// Main navbar
33
//
4-
// cSpell:ignore onscroll
54

6-
.td-navbar-cover {
7-
@include media-breakpoint-up(md) {
8-
background: transparent !important;
9-
10-
.nav-link {
11-
text-shadow: 1px 1px 2px $dark;
12-
}
13-
}
14-
15-
&.navbar-bg-onscroll .nav-link {
16-
text-shadow: none;
17-
}
18-
}
19-
20-
.navbar-bg-onscroll {
21-
background: $primary !important;
22-
opacity: inherit;
23-
}
5+
$td-navbar-bg-color: var(--bs-body-bg) !default;
246

257
.td-navbar {
268
@extend .navbar;
279
@extend .navbar-expand;
2810

29-
background: $primary;
11+
--td-navbar-bg-color: #{$td-navbar-bg-color};
12+
--td-navbar-backdrop-filter: none;
13+
--td-navbar-border-bottom: 1px solid var(--bs-border-color);
14+
15+
// To ensure that all child elements (such as form inputs) can inherit the
16+
// right (light/dark) body color we set it explicitly here:
17+
color: var(--bs-body-color);
18+
19+
background-color: var(--td-navbar-bg-color);
20+
backdrop-filter: var(--td-navbar-backdrop-filter);
21+
border-bottom: var(--td-navbar-border-bottom);
22+
3023
min-height: 4rem;
3124
margin: 0;
3225
z-index: 32;
@@ -111,9 +104,11 @@
111104
&-text {
112105
display: none;
113106
}
107+
114108
&-code {
115109
display: inline;
116110
}
111+
117112
&::before {
118113
padding-right: 0;
119114
}
@@ -136,6 +131,21 @@
136131
}
137132
}
138133

134+
.td-navbar-cover {
135+
transition:
136+
background-color 0.3s ease,
137+
backdrop-filter 0.3s ease,
138+
border-bottom 0.3s ease;
139+
140+
&.td-navbar-transparent {
141+
@include media-breakpoint-up(md) {
142+
--td-navbar-bg-color: transparent;
143+
--td-navbar-backdrop-filter: blur(8px);
144+
--td-navbar-border-bottom: none;
145+
}
146+
}
147+
}
148+
139149
// Icons
140150
#main_navbar {
141151
li i {
@@ -147,6 +157,7 @@
147157
min-width: 1em;
148158
}
149159
}
160+
150161
.alert {
151162
background-color: inherit;
152163
padding: 0;
@@ -226,6 +237,7 @@ nav.foldable-nav {
226237
font-size: 1em;
227238
color: var(--bs-secondary-color);
228239
transition: all 0.5s;
240+
229241
&:hover {
230242
transform: rotate(90deg);
231243
}

assets/scss/td/_search.scss

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,12 @@
4242
}
4343

4444
&.form-control:focus {
45-
border-color: tint-color($primary, 95%);
46-
box-shadow: 0 0 0 2px tint-color($primary, 40%);
47-
color: var(--bs-body-color);
45+
color: inherit;
4846
}
4947

5048
// Styling adjustments for the navbar
5149
@at-root {
5250
.td-navbar & {
53-
border: none;
5451
color: inherit;
5552

5653
@include placeholder {

assets/scss/td/_sidebar-tree.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@
156156
}
157157

158158
&__search {
159-
padding: 1rem 0;
159+
padding: 1.5rem 0;
160160
}
161161

162162
&__inner {

docsy.dev/assets/scss/_styles_project.scss

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,33 @@
22
@import 'td/code-dark';
33
@import 'td/gcs-search-dark';
44
@import 'local/blog';
5+
6+
//
7+
// Color tuning for the Docsy website
8+
//
9+
10+
// For dark navbars, use primary bg color by default (i.e., on mobile)
11+
@include color-mode(dark) {
12+
&.td-navbar-cover {
13+
--td-navbar-bg-color: #{$primary};
14+
--td-navbar-border-bottom: none;
15+
16+
// Illustration of tinted transparent background color on desktop:
17+
@include media-breakpoint-up(md) {
18+
&.td-navbar-transparent {
19+
$rgba-primary: rgba($primary, 0.25);
20+
--td-navbar-bg-color: #{$rgba-primary};
21+
}
22+
}
23+
}
24+
}
25+
26+
// Add a border between the footer and page content for pages with dark content
27+
// in general (like the homepage), or in dark mode.
28+
.td-home,
29+
.td-section,
30+
.td-page {
31+
.td-footer {
32+
border-top: 1px solid var(--bs-border-color);
33+
}
34+
}

docsy.dev/content/en/_index.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
---
22
title: Docsy
33
description: A Hugo theme for creating great technical documentation sites
4+
params:
5+
ui: { navbar_theme: dark}
46
---
57

68
{{% blocks/cover title="Welcome to Docsy!" image_anchor="top" height="full" %}}

docsy.dev/content/en/about/index.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
title: About Docsy
33
linkTitle: About
44
menu: {main: {weight: 10}}
5+
params:
6+
ui: { navbar_theme: dark}
57
---
68

79
{{% blocks/cover title="About Docsy" height="auto" %}}

docsy.dev/content/en/blog/2026/0.14.0.md

Lines changed: 51 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ author: >-
88
message: Hello, world!
99
body_class: release-highlights published-draft-post
1010
tags: [release]
11-
cSpell:ignore: Chalin pageinfo docsy gohugoio subrepo lookandfeel
11+
cSpell:ignore: Chalin pageinfo docsy gohugoio subrepo lightdark lookandfeel
1212
---
1313

1414
{{% card header="Highlights" %}}
@@ -40,6 +40,8 @@ Docsy [0.14.0] comes with the following notable features and improvements:
4040
- Review {{% _param BADGE BREAKING warning %}} changes:
4141
- {{% _param BREAKING %}} How you [customize Swagger](#swagger-scss) UI's look
4242
and feel changes.
43+
- {{% _param BREAKING %}} Default [Navbar styles](#navbar) and how you
44+
customize them changes.
4345
- {{% _param BREAKING %}} [Hugo 0.153+ upgrade](#hugo) introduces breaking
4446
changes
4547
- Review changes to internal files:
@@ -73,6 +75,53 @@ and how to customize the appearance of alerts, see [Alerts][].
7375
[alert shortcode]: /docs/content/shortcodes/#alert
7476
[Alerts]: /docs/content/adding-content/#alerts
7577

78+
## {{% _param BREAKING %}} Navbar style improvements {#navbar}
79+
80+
Prior to 0.14.0, the [navbar] element always used a [dark color theme][],
81+
regardless of the site's color theme or the active color mode. This restriction
82+
has been removed:
83+
84+
- [Light/dark color theme][] is now configurable both site-wide and per page.
85+
86+
The default navbar style now matches the base page style, offering a clean and
87+
consistent look and feel.[^navbar-bg-color]
88+
89+
Learn more:
90+
91+
- Default navbar style: [Navbar]
92+
- Navbar customization options: [Customizing the navbar][]
93+
94+
[^navbar-bg-color]:
95+
Prior to 0.14.0, the navbar background was set to the primary color.
96+
97+
**Action may be required** to update your project in the following areas:
98+
99+
- {{% _param BREAKING %}} Navbar theme now follows the page theme (default
100+
`light`), instead of always forcing `dark`. Set `params.ui.navbar_theme` to
101+
`dark` to restore the old behavior. [Details][navbar-lightdark-theme].
102+
103+
- Review your project's navbar style overrides. The new style design, SCSS and
104+
CSS variables may simplify your [customization][Customizing the navbar].
105+
106+
- Review [_nav.html][] if your project overrides it.
107+
108+
- Internal [navbar cover-image translucency][] class changes (update your custom
109+
styles targeting these classes if present):
110+
- `.td-navbar-transparent` replaces `.navbar-bg-on-scroll` (used with
111+
`.td-navbar-cover`)
112+
- `.navbar-bg-onscroll--fade` has been dropped: it was not used by Docsy, and
113+
the transition effect is now handled by `.td-navbar-cover`
114+
115+
[_nav.html]:
116+
https://github.com/google/docsy/blob/main/layouts/_partials/navbar.html
117+
[Customizing the navbar]: /docs/content/lookandfeel/#navbar-customization
118+
[dark color theme]: /docs/content/lookandfeel/#lightdark-color-feature
119+
[Light/dark color theme]: /docs/content/lookandfeel/#navbar-lightdark-theme
120+
[navbar]: /docs/content/lookandfeel/#navbar
121+
[navbar-lightdark-theme]: /docs/content/lookandfeel/#navbar-lightdark-theme
122+
[navbar cover-image translucency]:
123+
/docs/content/lookandfeel/#customize-over-cover
124+
76125
## Improved separation of project and internal SCSS files {#improved-scss-soc}
77126

78127
Docsy 0.14.0 moves all internal SCSS files from `assets/scss/` into the
@@ -147,7 +196,7 @@ file.
147196
For details about style customizations, see [Project style files][] and
148197
[Advanced style customization][].
149198

150-
## {{% _param BREAKING %}} Swagger UI style customization {#swagger-scss}
199+
### {{% _param BREAKING %}} Swagger UI style customization {#swagger-scss}
151200

152201
Prior to 0.14.0, the Docsy User Guide incorrectly recommended overriding
153202
`_swagger.scss` to customize [Swagger UI][] styles. Docsy's internal SCSS files

0 commit comments

Comments
 (0)