From ec1f276ef8e985f19c0a3ba29d5bcc2e8e2d85ab Mon Sep 17 00:00:00 2001 From: BernatBC Date: Sat, 9 Mar 2024 10:32:35 +0100 Subject: [PATCH] Add dark logos --- assets/scripts/features/darkmode/index.js | 18 ++++++++++++++++++ layouts/partials/sections/education-alt.html | 8 ++++++-- layouts/partials/sections/education.html | 8 ++++++-- .../sections/experiences/positions.html | 12 ++++++++---- 4 files changed, 38 insertions(+), 8 deletions(-) diff --git a/assets/scripts/features/darkmode/index.js b/assets/scripts/features/darkmode/index.js index f268af400..be1ce5a07 100644 --- a/assets/scripts/features/darkmode/index.js +++ b/assets/scripts/features/darkmode/index.js @@ -39,6 +39,8 @@ window.addEventListener('load', async () => { // save preference to local storage saveScheme(newScheme) + + setImages(newScheme) } setScheme(loadScheme()) @@ -50,3 +52,19 @@ window.addEventListener('load', async () => { }) }) }) + +function setImages(newScheme) { + const els = Array.from(document.getElementsByClassName('logo-holder')); + for (const el of els) { + const light = el.querySelector('.light-logo'); + const dark = el.querySelector('.dark-logo'); + if (newScheme === "dark" && dark !== null) { + if (light !== null) light.style.display = 'none' + dark.style.display = 'inline' + } + else { + if (light !== null) light.style.display = 'inline' + if (dark !== null) dark.style.display = 'none' + } + } +} \ No newline at end of file diff --git a/layouts/partials/sections/education-alt.html b/layouts/partials/sections/education-alt.html index cbb6120bf..8716c5bd1 100644 --- a/layouts/partials/sections/education-alt.html +++ b/layouts/partials/sections/education-alt.html @@ -33,9 +33,13 @@

{{ $logoImage:= resources.Get .institution.logo}} + {{ $darkLogoImage:= resources.Get .institution.darkLogo}} {{ if $logoImage }} -
- +
+ + {{ if $darkLogoImage }} + + {{ end }}
{{ end }} diff --git a/layouts/partials/sections/education.html b/layouts/partials/sections/education.html index fcfb8e5d2..ced54048d 100644 --- a/layouts/partials/sections/education.html +++ b/layouts/partials/sections/education.html @@ -33,9 +33,13 @@

{{ $logoImage:= resources.Get .institution.logo}} + {{ $darkLogoImage:= resources.Get .institution.darkLogo}} {{ if $logoImage }} -
- +
+ + {{ if $darkLogoImage }} + + {{ end }}
{{ end }} diff --git a/layouts/partials/sections/experiences/positions.html b/layouts/partials/sections/experiences/positions.html index 367801b8f..0ee18bb9b 100644 --- a/layouts/partials/sections/experiences/positions.html +++ b/layouts/partials/sections/experiences/positions.html @@ -1,11 +1,15 @@
{{ $logoImage:= resources.Get .company.logo}} - {{ if $logoImage }} -
- -
+ {{ $darkLogoImage:= resources.Get .company.darkLogo}} + {{ if $logoImage }} +
+ + {{ if $darkLogoImage }} + {{ end }} +
+ {{ end }} {{ $oldestPosition := index (last 1 .positions) 0}} {{ $mostRecentPosition := index (first 1 .positions) 0}}