mirror of
https://github.com/TrezOne/congo-hindi-gujarati.git
synced 2026-07-18 00:45:46 -04:00
🚧 Add dark mode toggle button
This commit is contained in:
@@ -16,26 +16,50 @@
|
||||
</ul>
|
||||
</nav>
|
||||
{{ end }}
|
||||
{{/* Copyright */}}
|
||||
<p class="text-sm text-neutral-400 dark:text-neutral-500">
|
||||
{{- with .Site.Copyright }}
|
||||
{{ . | emojify | markdownify }}
|
||||
{{- else }}
|
||||
©
|
||||
{{ now.Format "2006" }}
|
||||
{{ .Site.Author.name | markdownify | emojify }}
|
||||
{{- end }}
|
||||
</p>
|
||||
{{/* Theme attribution */}}
|
||||
{{ if .Site.Params.attribution | default true }}
|
||||
<p class="text-xs text-neutral-300 dark:text-neutral-600">
|
||||
{{ $hugo := printf `<a class="hover:underline hover:underline-primary-300 hover:text-primary-400"
|
||||
href="https://gohugo.io/" target="_blank" rel="noopener noreferrer">Hugo</a>`
|
||||
}}
|
||||
{{ $congo := printf `<a class="hover:underline hover:underline-primary-300 hover:text-primary-400" href="https://git.io/hugo-congo" target="_blank" rel="noopener noreferrer">Congo</a>` }}
|
||||
{{ i18n "footer.powered_by" (dict "Hugo" $hugo "Congo" $congo) | safeHTML }}
|
||||
</p>
|
||||
{{ end }}
|
||||
<div class="flex justify-between">
|
||||
<div>
|
||||
{{/* Copyright */}}
|
||||
<p class="text-sm text-neutral-400 dark:text-neutral-500">
|
||||
{{- with .Site.Copyright }}
|
||||
{{ . | emojify | markdownify }}
|
||||
{{- else }}
|
||||
©
|
||||
{{ now.Format "2006" }}
|
||||
{{ .Site.Author.name | markdownify | emojify }}
|
||||
{{- end }}
|
||||
</p>
|
||||
{{/* Theme attribution */}}
|
||||
{{ if .Site.Params.attribution | default true }}
|
||||
<p class="text-xs text-neutral-300 dark:text-neutral-600">
|
||||
{{ $hugo := printf `<a class="hover:underline hover:underline-primary-300 hover:text-primary-400"
|
||||
href="https://gohugo.io/" target="_blank" rel="noopener noreferrer">Hugo</a>`
|
||||
}}
|
||||
{{ $congo := printf `<a class="hover:underline hover:underline-primary-300 hover:text-primary-400" href="https://git.io/hugo-congo" target="_blank" rel="noopener noreferrer">Congo</a>` }}
|
||||
{{ i18n "footer.powered_by" (dict "Hugo" $hugo "Congo" $congo) | safeHTML }}
|
||||
</p>
|
||||
{{ end }}
|
||||
</div>
|
||||
<div class="text-sm cursor-pointer text-neutral-400 dark:text-neutral-500">
|
||||
<button
|
||||
id="dark-toggle"
|
||||
onclick="setPreferredScheme('dark');"
|
||||
oncontextmenu="setPreferredScheme('default'); return false;"
|
||||
class="inline px-2 py-1 border rounded-md border-neutral-200 dark:hidden hover:text-primary-500 hover:border-primary-400"
|
||||
title="Switch to dark mode"
|
||||
>
|
||||
{{ partial "icon.html" "moon" }}
|
||||
</button>
|
||||
<button
|
||||
id="light-toggle"
|
||||
onclick="setPreferredScheme('light');"
|
||||
oncontextmenu="setPreferredScheme('default'); return false;"
|
||||
class="hidden px-2 py-1 border rounded-md cursor-pointer dark:inline border-neutral-700 hover:text-primary-400 hover:border-primary-500"
|
||||
title="Switch to light mode"
|
||||
>
|
||||
{{ partial "icon.html" "sun" }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
{{/* Extend footer - eg. for extra scripts, etc. */}}
|
||||
{{ if templates.Exists "partials/extend-footer.html" }}
|
||||
{{ partialCached "extend-footer.html" . }}
|
||||
|
||||
@@ -62,6 +62,24 @@
|
||||
integrity="{{ $customStyles.Data.Integrity }}"
|
||||
/>
|
||||
{{ end }}
|
||||
<script>
|
||||
function loadPreferredScheme() {
|
||||
if (localStorage.preferredScheme === 'dark' || (!('preferredScheme' in localStorage) && window.matchMedia('(prefers-color-scheme: dark)').matches)) {
|
||||
document.documentElement.classList.add('dark');
|
||||
} else {
|
||||
document.documentElement.classList.remove('dark');
|
||||
}
|
||||
}
|
||||
function setPreferredScheme(scheme) {
|
||||
if (scheme == "default") {
|
||||
localStorage.removeItem("preferredScheme");
|
||||
} else {
|
||||
localStorage.preferredScheme = scheme;
|
||||
}
|
||||
loadPreferredScheme();
|
||||
}
|
||||
loadPreferredScheme();
|
||||
</script>
|
||||
{{/* Icons */}}
|
||||
{{ if templates.Exists "partials/favicons.html" }}
|
||||
{{ partialCached "favicons.html" .Site }}
|
||||
|
||||
Reference in New Issue
Block a user