From a252f2fd38bede0bdc11b793db1ad8ce9994a7df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Avijit=20=F0=9F=9A=80?= <526avijit@gmail.com> Date: Tue, 15 Jun 2021 18:43:33 +0200 Subject: [PATCH 1/2] Replace fa by feather icons --- exampleSite/config.toml | 4 ++-- themes/gokarna/layouts/partials/head.html | 5 ++--- themes/gokarna/layouts/partials/header.html | 2 +- themes/gokarna/static/css/main.css | 19 +++++++++++++++++-- themes/gokarna/static/js/main.js | 13 +++++++------ 5 files changed, 29 insertions(+), 14 deletions(-) diff --git a/exampleSite/config.toml b/exampleSite/config.toml index bd2c65a..360c72d 100644 --- a/exampleSite/config.toml +++ b/exampleSite/config.toml @@ -36,12 +36,12 @@ pygmentsCodeFencesGuessSyntax = true [[menu.main]] identifier = "linkedin" - pre = "" + pre = "" url = "/a/" weight = 5 [[menu.main]] identifier = "github" - pre = "" + pre = "" url = "/b/" weight = 6 diff --git a/themes/gokarna/layouts/partials/head.html b/themes/gokarna/layouts/partials/head.html index 5707fa5..ca8b689 100644 --- a/themes/gokarna/layouts/partials/head.html +++ b/themes/gokarna/layouts/partials/head.html @@ -1,15 +1,14 @@
- - - + + {{ $title := print .Site.Title " | " .Title }} {{ if .IsHome }}{{ $title = .Site.Title }}{{ end }} diff --git a/themes/gokarna/layouts/partials/header.html b/themes/gokarna/layouts/partials/header.html index d558a45..5a5707b 100644 --- a/themes/gokarna/layouts/partials/header.html +++ b/themes/gokarna/layouts/partials/header.html @@ -35,7 +35,7 @@ diff --git a/themes/gokarna/static/css/main.css b/themes/gokarna/static/css/main.css index f844bf4..1019397 100644 --- a/themes/gokarna/static/css/main.css +++ b/themes/gokarna/static/css/main.css @@ -86,13 +86,20 @@ html { border-left: 1px solid; margin-right: 4.5px; } -.nav-links #dark-light-theme-toggle:hover { +.nav-links #dark-theme-toggle:hover { cursor: pointer; } +#dark-theme-toggle .feather { + fill: #b8c2cc; + height: 24px; + stroke-linecap: round; + stroke-linejoin: round; + width: 24px; +} /* FOOTER */ .footer { - text-align: center; + text-align: center; } .footer a { @@ -101,6 +108,14 @@ html { } /** COMMON **/ + +/* ICONS */ +.feather { + height: 20px; + stroke-width: 1.5; + width: 20px; +} + /* TAGS */ .post-tags { list-style-type: none; diff --git a/themes/gokarna/static/js/main.js b/themes/gokarna/static/js/main.js index 0a3aaf2..566fa52 100644 --- a/themes/gokarna/static/js/main.js +++ b/themes/gokarna/static/js/main.js @@ -2,23 +2,24 @@ document.addEventListener('DOMContentLoaded', ready, false); const THEME_PREF_STORAGE_KEY = "theme-preference"; const THEME_TO_ICON_CLASS = { - 'dark': 'fa fa-sun-o', - 'light':'fa fa-moon-o' + 'dark': 'feather-moon', + 'light':'feather-sun' }; let toggleIcon = ''; let darkThemeCss = ''; function ready() { - toggleIcon = document.querySelector('#dark-theme-toggle span'); + feather.replace({ 'stroke-width': 1, width: 20, height: 20 }); darkThemeCss = document.getElementById("dark-theme"); const savedTheme = localStorage.getItem(THEME_PREF_STORAGE_KEY) || (window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark': 'light'); setTheme(savedTheme); document.getElementById('dark-theme-toggle').addEventListener('click', () => { - if (toggleIcon.className === THEME_TO_ICON_CLASS.dark) { + toggleIcon = document.querySelector("#dark-theme-toggle a svg.feather"); + if (toggleIcon.classList[1] === THEME_TO_ICON_CLASS.dark) { setTheme('light'); - } else if (toggleIcon.className === THEME_TO_ICON_CLASS.light) { + } else if (toggleIcon.classList[1] === THEME_TO_ICON_CLASS.light) { setTheme('dark'); } }); @@ -39,6 +40,6 @@ window.addEventListener('scroll', () => { function setTheme(themeToSet) { localStorage.setItem(THEME_PREF_STORAGE_KEY, themeToSet); darkThemeCss.disabled = themeToSet === 'light'; - toggleIcon.className = THEME_TO_ICON_CLASS[themeToSet]; + document.querySelector('#dark-theme-toggle a').innerHTML = feather.icons[THEME_TO_ICON_CLASS[themeToSet].split('-')[1]].toSvg(); } From dec51108d2f3ac479401d62766f9351d650dad77 Mon Sep 17 00:00:00 2001 From: Yash Mehrotra