Merge pull request #141 from nelvko/master

fix: replace icon.
This commit is contained in:
MeiK
2024-04-07 14:11:28 +08:00
committed by GitHub
8 changed files with 19 additions and 3 deletions

View File

@@ -19,9 +19,9 @@ pygmentsUseClasses = true
keywords = "blog, google analytics" keywords = "blog, google analytics"
rss = true rss = true
lastmod = true lastmod = true
favicon = "/images/github.png" favicon = "/images/github-mark.png"
avatar = "/images/avatar.png" avatar = "/images/avatar.png"
headerIcon = "/images/GitHub-Mark-Light-32px.png" headerIcon = "/images/github-mark-white.png"
location = "China" location = "China"
userStatusEmoji = "😀" userStatusEmoji = "😀"
enableGitalk = true enableGitalk = true

View File

@@ -118,7 +118,9 @@
{{ if .Site.Params.twitter}} {{ if .Site.Params.twitter}}
<a style="margin: 0 10px 10px 0;" href="https://twitter.com/{{ .Site.Params.twitter }}"> <a style="margin: 0 10px 10px 0;" href="https://twitter.com/{{ .Site.Params.twitter }}">
<img alt="@twitter" width="32" height="32" src="{{ "images/twitter.png" | absURL }}" class="avatar"> <svg width="32" height="32" viewBox="0 0 1200 1227" fill="none" xmlns="http://www.w3.org/2000/svg">
<path id="twitter-icon" d="M714.163 519.284L1160.89 0H1055.03L667.137 450.887L357.328 0H0L468.492 681.821L0 1226.37H105.866L515.491 750.218L842.672 1226.37H1200L714.137 519.284H714.163ZM569.165 687.828L521.697 619.934L144.011 79.6944H306.615L611.412 515.685L658.88 583.579L1055.08 1150.3H892.476L569.165 687.854V687.828Z" fill="white"/>
</svg>
</a> </a>
{{ end }} {{ end }}
@@ -204,12 +206,15 @@ window.onscroll = function (e) {
var style = localStorage.getItem('data-color-mode'); var style = localStorage.getItem('data-color-mode');
iconElement = document.getElementById('github-icon'); iconElement = document.getElementById('github-icon');
twitterIconElement = document.getElementById('twitter-icon');
if (style == 'light') { if (style == 'light') {
iconElement.setAttribute('fill', '#24292e'); iconElement.setAttribute('fill', '#24292e');
twitterIconElement.setAttribute("fill","black")
} }
else { else {
iconElement.removeAttribute('fill'); iconElement.removeAttribute('fill');
iconElement.setAttribute('class', 'octicon'); iconElement.setAttribute('class', 'octicon');
iconElement.setAttribute('color', '#f0f6fc'); iconElement.setAttribute('color', '#f0f6fc');
twitterIconElement.setAttribute("fill","white")
} }
</script> </script>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.7 KiB

View File

@@ -4,6 +4,7 @@ function switchTheme() {
if (currentStyle === 'light') { if (currentStyle === 'light') {
setTheme('dark'); setTheme('dark');
setIconTheme('dark')
if (iconElement) { if (iconElement) {
iconElement.setAttribute('class', 'octicon'); iconElement.setAttribute('class', 'octicon');
iconElement.setAttribute('color', '#f0f6fc'); iconElement.setAttribute('color', '#f0f6fc');
@@ -11,6 +12,7 @@ function switchTheme() {
} }
else { else {
setTheme('light'); setTheme('light');
setIconTheme('light')
if (iconElement) { if (iconElement) {
iconElement.removeAttribute('color'); iconElement.removeAttribute('color');
iconElement.removeAttribute('class'); iconElement.removeAttribute('class');
@@ -26,6 +28,15 @@ function setTheme(style) {
localStorage.setItem('data-color-mode', style); localStorage.setItem('data-color-mode', style);
} }
function setIconTheme(theme) {
twitterIconElement = document.getElementById('twitter-icon');
if (theme === 'light') {
twitterIconElement.setAttribute("fill", "black")
} else if (theme === 'dark') {
twitterIconElement.setAttribute("fill", "white")
}
}
function currentTheme() { function currentTheme() {
const localStyle = localStorage.getItem('data-color-mode'); const localStyle = localStorage.getItem('data-color-mode');
const systemStyle = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light'; const systemStyle = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';