Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Dark-mode] Tweak of param, file and resource names #1913

Merged
merged 2 commits into from
Apr 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions assets/js/color-mode.js → assets/js/dark-mode.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
/*!
* This is a Docsy-adapted version of https://github.com/twbs/examples/blob/main/color-modes/js/color-modes.js.
*
* Original header:
*
* Color mode toggler for Bootstrap's docs (https://getbootstrap.com/)
* Copyright 2011-2024 The Bootstrap Authors
* Licensed under the Creative Commons Attribution 3.0 Unported License.
Expand All @@ -7,8 +11,9 @@
(() => {
'use strict'

const getStoredTheme = () => localStorage.getItem('theme')
const setStoredTheme = theme => localStorage.setItem('theme', theme)
const themeKey = 'td-color-theme'
const getStoredTheme = () => localStorage.getItem(themeKey)
const setStoredTheme = theme => localStorage.setItem(themeKey, theme)

const getPreferredTheme = () => {
const storedTheme = getStoredTheme()
Expand Down
11 changes: 11 additions & 0 deletions assets/scss/_nav.scss
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,17 @@
overflow-x: auto;
}
}

// Support for showLightDarkModeMenu:
.bi {
width: 1em;
height: 1em;
vertical-align: -.125em;
fill: currentcolor;
}
.td-navbar .dropdown-menu .active .bi {
display: block !important
}
}

// Icons
Expand Down
14 changes: 1 addition & 13 deletions layouts/partials/navbar.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,6 @@
-}}
{{ $baseURL := urls.Parse $.Site.Params.Baseurl -}}

<style>
.bi {
width: 1em;
height: 1em;
vertical-align: -.125em;
fill: currentcolor;
}
.td-navbar .dropdown-menu .active .bi {
display: block !important
}
</style>

<nav class="td-navbar js-navbar-scroll
{{- if $cover }} td-navbar-cover {{- end }}" data-bs-theme="dark">
<div class="container-fluid flex-column flex-md-row">
Expand Down Expand Up @@ -69,7 +57,7 @@
{{ partial "navbar-lang-selector.html" . -}}
</li>
{{ end -}}
{{ if .Site.Params.ui.colorModeEnabled -}}
{{ if .Site.Params.ui.showLightDarkModeMenu -}}
<li class="nav-item dropdown">
{{ partial "theme-toggler" . }}
</li>
Expand Down
4 changes: 2 additions & 2 deletions layouts/partials/scripts.html
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@
{{- partial "scripts/mermaid.html" . -}}
{{ end -}}

{{ if .Site.Params.ui.colorModeEnabled -}}
{{ $jsArray = $jsArray | append (resources.Get "js/color-mode.js") -}}
{{ if .Site.Params.ui.showLightDarkModeMenu -}}
{{ $jsArray = $jsArray | append (resources.Get "js/dark-mode.js") -}}
{{ end -}}

{{ $js := $jsArray | resources.Concat "js/main.js" -}}
Expand Down
2 changes: 1 addition & 1 deletion userguide/hugo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ params:
search:
# algolia:
ui:
colorModeEnabled: true
showLightDarkModeMenu: true
sidebar_cache_limit: 10
sidebar_menu_compact: true
sidebar_menu_foldable: false
Expand Down