Minor tweaks & improvements
This commit is contained in:
parent
1cf834a864
commit
1baa51c7c5
2 changed files with 19 additions and 23 deletions
|
|
@ -11,14 +11,6 @@
|
||||||
filter: opacity(100%);
|
filter: opacity(100%);
|
||||||
}
|
}
|
||||||
|
|
||||||
body.dark .codewars {
|
|
||||||
filter: opacity(80%);
|
|
||||||
}
|
|
||||||
|
|
||||||
body.dark .codewars:hover {
|
|
||||||
filter: opacity(100%);
|
|
||||||
}
|
|
||||||
|
|
||||||
.navbar-translucent {
|
.navbar-translucent {
|
||||||
opacity: 75%;
|
opacity: 75%;
|
||||||
transition: opacity ease-in-out 250ms;
|
transition: opacity ease-in-out 250ms;
|
||||||
|
|
@ -53,11 +45,6 @@ body.dark {
|
||||||
color: #eeeeee !important;
|
color: #eeeeee !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
body.dark .navbar, body.dark .navbar *:not(#displayModeSwitch) {
|
|
||||||
background-color: #202020 !important;
|
|
||||||
color: #eeeeee !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
body.dark #displayModeSwitch {
|
body.dark #displayModeSwitch {
|
||||||
background-color: #00bee0 !important;
|
background-color: #00bee0 !important;
|
||||||
border-color: #00bee0 !important;
|
border-color: #00bee0 !important;
|
||||||
|
|
@ -68,13 +55,13 @@ body.dark #displayModeSwitch {
|
||||||
filter: hue-rotate(0deg);
|
filter: hue-rotate(0deg);
|
||||||
}
|
}
|
||||||
25% {
|
25% {
|
||||||
filter: hue-rotate(90deg);
|
filter: hue-rotate(45deg);
|
||||||
}
|
}
|
||||||
50% {
|
50% {
|
||||||
filter: hue-rotate(180deg);
|
filter: hue-rotate(90deg);
|
||||||
}
|
}
|
||||||
75% {
|
75% {
|
||||||
filter: hue-rotate(90deg);
|
filter: hue-rotate(45deg);
|
||||||
}
|
}
|
||||||
100% {
|
100% {
|
||||||
filter: hue-rotate(0deg);
|
filter: hue-rotate(0deg);
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ const urls = {
|
||||||
};
|
};
|
||||||
|
|
||||||
const initColorScheme = () => {
|
const initColorScheme = () => {
|
||||||
const setting = window.localStorage.getItem('color-mode');
|
const setting = localStorage.getItem('color-mode');
|
||||||
if (setting) {
|
if (setting) {
|
||||||
if (setting === 'dark') {
|
if (setting === 'dark') {
|
||||||
currentColorMode = 'dark';
|
currentColorMode = 'dark';
|
||||||
|
|
@ -19,13 +19,11 @@ const initColorScheme = () => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
window.localStorage.setItem('color-mode', currentColorMode);
|
localStorage.setItem('color-mode', currentColorMode);
|
||||||
if (currentColorMode === ColorModes.Dark) {
|
if (currentColorMode === ColorModes.Dark) {
|
||||||
document.body.classList.add('dark');
|
document.body.classList.add('dark');
|
||||||
document.querySelector('#displayModeSwitch').checked = true;
|
|
||||||
} else {
|
} else {
|
||||||
document.body.classList.remove('dark');
|
document.body.classList.remove('dark');
|
||||||
document.querySelector('#displayModeSwitch').checked = false;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -39,7 +37,7 @@ const bootstrapNavbar = () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
document.body.innerHTML = `
|
document.body.innerHTML = `
|
||||||
<nav class="navbar navbar-expand-lg navbar-light bg-light fixed-top ${title === "Home" ? 'navbar-translucent' : ''}">
|
<nav class="navbar navbar-expand-lg navbar-${currentColorMode === 'dark' ? 'dark' : 'light'} bg-${currentColorMode === 'dark' ? 'dark' : 'light'} fixed-top ${title === "Home" ? 'navbar-translucent' : ''}" id="main-nav">
|
||||||
<div class="container-fluid">
|
<div class="container-fluid">
|
||||||
<a class="navbar-brand" href="#">Jose's Portfolio</a>
|
<a class="navbar-brand" href="#">Jose's Portfolio</a>
|
||||||
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent"
|
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent"
|
||||||
|
|
@ -92,7 +90,7 @@ const bootstrapNavbar = () => {
|
||||||
</ul>
|
</ul>
|
||||||
<form class="d-flex">
|
<form class="d-flex">
|
||||||
<div class="form-check form-switch">
|
<div class="form-check form-switch">
|
||||||
<input class="form-check-input" type="checkbox" id="displayModeSwitch">
|
<input class="form-check-input" type="checkbox" id="displayModeSwitch" ${currentColorMode === 'dark' && 'checked'}>
|
||||||
<label class="form-check-label" for="displayModeSwitch">Dark Mode</label>
|
<label class="form-check-label" for="displayModeSwitch">Dark Mode</label>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
@ -108,8 +106,8 @@ const bootstrapNavbar = () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
window.addEventListener('load', () => {
|
window.addEventListener('load', () => {
|
||||||
bootstrapNavbar();
|
|
||||||
initColorScheme();
|
initColorScheme();
|
||||||
|
bootstrapNavbar();
|
||||||
|
|
||||||
document.querySelector('#displayModeSwitch').addEventListener('click', () => {
|
document.querySelector('#displayModeSwitch').addEventListener('click', () => {
|
||||||
currentColorMode = currentColorMode === ColorModes.Dark ? ColorModes.Light : ColorModes.Dark;
|
currentColorMode = currentColorMode === ColorModes.Dark ? ColorModes.Light : ColorModes.Dark;
|
||||||
|
|
@ -118,5 +116,16 @@ window.addEventListener('load', () => {
|
||||||
} else {
|
} else {
|
||||||
document.body.classList.remove('dark');
|
document.body.classList.remove('dark');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const nav = document.querySelector('#main-nav');
|
||||||
|
nav.classList.remove('navbar-light');
|
||||||
|
nav.classList.remove('navbar-dark');
|
||||||
|
nav.classList.remove('bg-light');
|
||||||
|
nav.classList.remove('bg-dark');
|
||||||
|
|
||||||
|
nav.classList.add(`navbar-${currentColorMode === 'dark' ? 'dark' : 'light'}`);
|
||||||
|
nav.classList.add(`bg-${currentColorMode === 'dark' ? 'dark' : 'light'}`);
|
||||||
|
|
||||||
|
localStorage.setItem('color-mode', currentColorMode);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
Loading…
Reference in a new issue