Merge branch 'dev-dark-theme' into donfiguerres
This commit is contained in:
commit
734d30ed17
5 changed files with 18 additions and 5 deletions
|
@ -15,6 +15,12 @@
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body data-spy="scroll" data-target="#TableOfContents" data-offset="80">
|
<body data-spy="scroll" data-target="#TableOfContents" data-offset="80">
|
||||||
|
|
||||||
|
<!-- INITIALIZE DARK THEME -->
|
||||||
|
{{ if site.Params.darkTheme.enable }}
|
||||||
|
{{ partial "helpers/darkmode.html" . }}
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
<div class="container-fluid bg-dimmed wrapper">
|
<div class="container-fluid bg-dimmed wrapper">
|
||||||
<!----- ADD NAVBAR --------------->
|
<!----- ADD NAVBAR --------------->
|
||||||
{{ block "navbar" . }} {{ end }}
|
{{ block "navbar" . }} {{ end }}
|
||||||
|
|
|
@ -32,6 +32,11 @@
|
||||||
</head>
|
</head>
|
||||||
<body data-spy="scroll" data-target="#top-navbar" data-offset="100">
|
<body data-spy="scroll" data-target="#top-navbar" data-offset="100">
|
||||||
|
|
||||||
|
<!-- INITIALIZE DARK THEME -->
|
||||||
|
{{ if site.Params.darkTheme.enable }}
|
||||||
|
{{ partial "helpers/darkmode.html" . }}
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
<!--- NAVBAR ------------------------->
|
<!--- NAVBAR ------------------------->
|
||||||
{{- partial "navigators/navbar.html" . -}}
|
{{- partial "navigators/navbar.html" . -}}
|
||||||
|
|
||||||
|
|
3
layouts/partials/helpers/darkmode.html
Normal file
3
layouts/partials/helpers/darkmode.html
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
<!-- This is a 'hack' for initializing the color scheme selection. See /js/darkmode.js -->
|
||||||
|
<div id="themeInitialization" style="display: none;"
|
||||||
|
default-theme=" {{ site.Params.darkTheme.default }} "></div>
|
|
@ -1,6 +1,5 @@
|
||||||
<li class="nav-item dropdown">
|
<li class="nav-item dropdown">
|
||||||
<a class="nav-link dropdown-toggle" href="#" id="themeSelector"
|
<a class="nav-link dropdown-toggle" href="#" id="themeSelector" role="button"
|
||||||
default-theme=" {{ site.Params.darkTheme.default }} " role="button"
|
|
||||||
data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Theme</a>
|
data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Theme</a>
|
||||||
<div class="dropdown-menu" aria-labelledby="themeSelector">
|
<div class="dropdown-menu" aria-labelledby="themeSelector">
|
||||||
<a class="dropdown-item nav-link" href="#" onclick="enableLightTheme()">Light</a>
|
<a class="dropdown-item nav-link" href="#" onclick="enableLightTheme()">Light</a>
|
||||||
|
|
|
@ -22,11 +22,11 @@ function useSystemTheme() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function initializeColorScheme() {
|
function initializeColorScheme() {
|
||||||
// We're using the themeSelector attributes as a 'hack' for setting up the
|
// We're using the themeInitialization attributes as a 'hack' for setting up the
|
||||||
// default color scheme becauase we don't want to complicate this further by
|
// default color scheme becauase we don't want to complicate this further by
|
||||||
// creating custom javascript output in Hugo.
|
// creating custom javascript output in Hugo.
|
||||||
themeSelector = document.getElementById("themeSelector");
|
themeInitialization = document.getElementById("themeInitialization");
|
||||||
defaultColorScheme = themeSelector.getAttribute('default-theme');
|
defaultColorScheme = themeInitialization.getAttribute('default-theme');
|
||||||
// If the user has already selected a preferred theme then use that instead
|
// If the user has already selected a preferred theme then use that instead
|
||||||
// of the default theme. Also, the default theme gets loaded to localStorage
|
// of the default theme. Also, the default theme gets loaded to localStorage
|
||||||
// on the first visit.
|
// on the first visit.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue