mirror of
https://github.com/MeiK2333/github-style.git
synced 2025-10-07 01:54:06 +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');
|
var style = localStorage.getItem('data-color-mode')
|
||||||
iconElement = document.getElementById('github-icon');
|
githubIconElement = document.getElementById('github-icon')
|
||||||
twitterIconElement = document.getElementById('twitter-icon');
|
twitterIconElement = document.getElementById('twitter-icon')
|
||||||
if (style == 'light') {
|
if (style == 'light') {
|
||||||
if (iconElement) iconElement.setAttribute('fill', '#24292e');
|
if (githubIconElement) githubIconElement.setAttribute('fill', '#24292e')
|
||||||
if (twitterIconElement) twitterIconElement.setAttribute("fill","black")
|
if (twitterIconElement) twitterIconElement.setAttribute('fill', 'black')
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (iconElement) {
|
if (githubIconElement) {
|
||||||
iconElement.removeAttribute('fill');
|
githubIconElement.removeAttribute('fill')
|
||||||
iconElement.setAttribute('class', 'octicon');
|
githubIconElement.setAttribute('class', 'octicon')
|
||||||
iconElement.setAttribute('color', '#f0f6fc');
|
githubIconElement.setAttribute('color', '#f0f6fc')
|
||||||
}
|
}
|
||||||
if (twitterIconElement) twitterIconElement.setAttribute("fill","white")
|
if (twitterIconElement) twitterIconElement.setAttribute('fill', 'white')
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
@@ -1,22 +1,12 @@
|
|||||||
function switchTheme() {
|
function switchTheme() {
|
||||||
const currentStyle = currentTheme();
|
const currentStyle = currentTheme()
|
||||||
const iconElement = document.getElementById('github-icon');
|
|
||||||
|
|
||||||
if (currentStyle === 'light') {
|
if (currentStyle === 'light') {
|
||||||
setTheme('dark');
|
setTheme('dark')
|
||||||
setIconTheme('dark')
|
setIconTheme('dark')
|
||||||
if (iconElement) {
|
|
||||||
iconElement.setAttribute('class', 'octicon');
|
|
||||||
iconElement.setAttribute('color', '#f0f6fc');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
setTheme('light');
|
setTheme('light')
|
||||||
setIconTheme('light')
|
setIconTheme('light')
|
||||||
if (iconElement) {
|
|
||||||
iconElement.removeAttribute('color');
|
|
||||||
iconElement.removeAttribute('class');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -29,11 +19,24 @@ function setTheme(style) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function setIconTheme(theme) {
|
function setIconTheme(theme) {
|
||||||
twitterIconElement = document.getElementById('twitter-icon');
|
const twitterIconElement = document.getElementById('twitter-icon')
|
||||||
if (theme === 'light') {
|
const githubIconElement = document.getElementById('github-icon')
|
||||||
twitterIconElement.setAttribute("fill", "black")
|
if (twitterIconElement) {
|
||||||
} else if (theme === 'dark') {
|
if (theme === 'light') {
|
||||||
twitterIconElement.setAttribute("fill", "white")
|
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