mirror of
https://github.com/MeiK2333/github-style.git
synced 2025-10-07 10:04:04 +00:00
Merge pull request #149 from yuweizzz/fix
fix: no twitterIconElement raise error
This commit is contained in:
@@ -204,19 +204,19 @@ window.onscroll = function (e) {
|
||||
}
|
||||
};
|
||||
|
||||
var style = localStorage.getItem('data-color-mode');
|
||||
iconElement = document.getElementById('github-icon');
|
||||
twitterIconElement = document.getElementById('twitter-icon');
|
||||
var style = localStorage.getItem('data-color-mode')
|
||||
githubIconElement = document.getElementById('github-icon')
|
||||
twitterIconElement = document.getElementById('twitter-icon')
|
||||
if (style == 'light') {
|
||||
if (iconElement) iconElement.setAttribute('fill', '#24292e');
|
||||
if (twitterIconElement) twitterIconElement.setAttribute("fill","black")
|
||||
if (githubIconElement) githubIconElement.setAttribute('fill', '#24292e')
|
||||
if (twitterIconElement) twitterIconElement.setAttribute('fill', 'black')
|
||||
}
|
||||
else {
|
||||
if (iconElement) {
|
||||
iconElement.removeAttribute('fill');
|
||||
iconElement.setAttribute('class', 'octicon');
|
||||
iconElement.setAttribute('color', '#f0f6fc');
|
||||
if (githubIconElement) {
|
||||
githubIconElement.removeAttribute('fill')
|
||||
githubIconElement.setAttribute('class', 'octicon')
|
||||
githubIconElement.setAttribute('color', '#f0f6fc')
|
||||
}
|
||||
if (twitterIconElement) twitterIconElement.setAttribute("fill","white")
|
||||
if (twitterIconElement) twitterIconElement.setAttribute('fill', 'white')
|
||||
}
|
||||
</script>
|
||||
|
@@ -1,22 +1,12 @@
|
||||
function switchTheme() {
|
||||
const currentStyle = currentTheme();
|
||||
const iconElement = document.getElementById('github-icon');
|
||||
|
||||
const currentStyle = currentTheme()
|
||||
if (currentStyle === 'light') {
|
||||
setTheme('dark');
|
||||
setTheme('dark')
|
||||
setIconTheme('dark')
|
||||
if (iconElement) {
|
||||
iconElement.setAttribute('class', 'octicon');
|
||||
iconElement.setAttribute('color', '#f0f6fc');
|
||||
}
|
||||
}
|
||||
else {
|
||||
setTheme('light');
|
||||
setTheme('light')
|
||||
setIconTheme('light')
|
||||
if (iconElement) {
|
||||
iconElement.removeAttribute('color');
|
||||
iconElement.removeAttribute('class');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,11 +19,24 @@ function setTheme(style) {
|
||||
}
|
||||
|
||||
function setIconTheme(theme) {
|
||||
twitterIconElement = document.getElementById('twitter-icon');
|
||||
if (theme === 'light') {
|
||||
twitterIconElement.setAttribute("fill", "black")
|
||||
} else if (theme === 'dark') {
|
||||
twitterIconElement.setAttribute("fill", "white")
|
||||
const twitterIconElement = document.getElementById('twitter-icon')
|
||||
const githubIconElement = document.getElementById('github-icon')
|
||||
if (twitterIconElement) {
|
||||
if (theme === 'light') {
|
||||
twitterIconElement.setAttribute("fill", "black")
|
||||
} else if (theme === 'dark') {
|
||||
twitterIconElement.setAttribute("fill", "white")
|
||||
}
|
||||
}
|
||||
|
||||
if (githubIconElement) {
|
||||
if (theme === 'light') {
|
||||
githubIconElement.removeAttribute('color')
|
||||
githubIconElement.removeAttribute('class')
|
||||
} else if (theme === 'dark') {
|
||||
githubIconElement.setAttribute('class', 'octicon')
|
||||
githubIconElement.setAttribute('color', '#f0f6fc')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user