Add support for different logo on dark mode (#1020)

This commit is contained in:
Emruz Hossain 2025-01-14 06:01:14 +06:00 committed by GitHub
parent 047bb517cb
commit 07372519ee
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 36 additions and 3 deletions

View file

@ -67,4 +67,4 @@ function setImages(newScheme) {
if (dark !== null) dark.style.display = 'none' if (dark !== null) dark.style.display = 'none'
} }
} }
} }

View file

@ -85,4 +85,4 @@ function setImages(newScheme) {
if (dark !== null) dark.style.display = 'none' if (dark !== null) dark.style.display = 'none'
} }
} }
} }

View file

@ -55,4 +55,22 @@ html[data-theme='dark'] {
.company-logo { .company-logo {
max-height: 100%; max-height: 100%;
width: auto; width: auto;
} }
.light-logo {
display: inline;
}
.dark-logo {
display: none;
}
html[data-theme='dark'] {
.light-logo {
display: none;
}
.dark-logo {
display: inline;
}
}

View file

@ -13,6 +13,7 @@
{{/* by default, don't use any logo */}} {{/* by default, don't use any logo */}}
{{ $mainLogo := "" }} {{ $mainLogo := "" }}
{{ $invertedLogo := "" }} {{ $invertedLogo := "" }}
{{ $darkLogo := "" }}
{{/* if custom logo has been provided, use them */}} {{/* if custom logo has been provided, use them */}}
{{ if site.Params.logo.main }} {{ if site.Params.logo.main }}
@ -21,6 +22,9 @@
{{ if site.Params.logo.inverted }} {{ if site.Params.logo.inverted }}
{{ $invertedLogo = site.Params.logo.inverted }} {{ $invertedLogo = site.Params.logo.inverted }}
{{ end }} {{ end }}
{{ if site.Params.logo.dark }}
{{ $darkLogo = site.Params.logo.dark }}
{{ end }}
{{/* resize the logos. don't resize svg because it is not supported */}} {{/* resize the logos. don't resize svg because it is not supported */}}
{{ if $mainLogo }} {{ if $mainLogo }}
@ -39,6 +43,14 @@
{{ $invertedLogo = $invertedLogo.RelPermalink}} {{ $invertedLogo = $invertedLogo.RelPermalink}}
{{ end }} {{ end }}
{{ if $darkLogo }}
{{ $darkLogo = resources.Get $darkLogo}}
{{ if and $darkLogo (ne $darkLogo.MediaType.SubType "svg")}}
{{ $darkLogo = $darkLogo.Resize "42x" }}
{{ end }}
{{ $darkLogo = $darkLogo.RelPermalink}}
{{ end }}
{{ $logo := $mainLogo }} {{ $logo := $mainLogo }}
{{ if .IsHome }} {{ if .IsHome }}
{{ $logo = $invertedLogo }} {{ $logo = $invertedLogo }}
@ -154,4 +166,7 @@
{{ if $invertedLogo }} {{ if $invertedLogo }}
<img src="{{ $invertedLogo }}" class="d-none" id="inverted-logo" alt="Inverted Logo"> <img src="{{ $invertedLogo }}" class="d-none" id="inverted-logo" alt="Inverted Logo">
{{ end }} {{ end }}
{{ if $darkLogo }}
<img src="{{ $darkLogo }}" class="d-none" id="dark-logo" alt="Dark Logo">
{{ end }}
</nav> </nav>