diff --git a/Resources/css/main.css b/Resources/css/main.css index c781eb2..e276068 100644 --- a/Resources/css/main.css +++ b/Resources/css/main.css @@ -1,16 +1,24 @@ .codewars { width: 1rem; height: 1rem; - margin-bottom: 4px; - border-radius: 2px; - filter: opacity(60%); + margin-bottom: 1px; transition: filter ease-in-out 200ms; + vertical-align: sub !important; + filter: opacity(80%); } .codewars:hover { filter: opacity(100%); } +body.dark .codewars { + filter: opacity(80%); +} + +body.dark .codewars:hover { + filter: opacity(100%); +} + .navbar-translucent { opacity: 75%; transition: opacity ease-in-out 250ms; @@ -27,7 +35,7 @@ .gradient.masthead { text-align: center; - width: 100vw; + width: 100%; height: 50vh; padding-top: 25vh; /* Beautiful gradient effect */ @@ -35,6 +43,26 @@ animation: Rotate 10s ease infinite; } +#displayModeSwitch, label[for="displayModeSwitch"] { + cursor: pointer; + user-select: none; +} + +body.dark { + background-color: #252525 !important; + color: #eeeeee !important; +} + +body.dark .navbar, body.dark .navbar *:not(#displayModeSwitch) { + background-color: #202020 !important; + color: #eeeeee !important; +} + +body.dark #displayModeSwitch { + background-color: #00bee0 !important; + border-color: #00bee0 !important; +} + @keyframes Rotate { 0% { filter: hue-rotate(0deg); diff --git a/Resources/js/main.js b/Resources/js/main.js index e158976..60b7e29 100644 --- a/Resources/js/main.js +++ b/Resources/js/main.js @@ -1,9 +1,36 @@ +const ColorModes = { Dark: 'dark', Light: 'light' }; +// Set the current color mode to the default display mode +let currentColorMode = window.matchMedia('(prefers-color-scheme: dark)').matches + ? ColorModes.Dark : ColorModes.Light; + const urls = { - "/": "Home", - "/Portfolio/": "Portfolio", - "/Education/": "Education" + '/': 'Home', + '/Portfolio/': 'Portfolio', + '/Education/': 'Education' }; +const initColorScheme = () => { + const setting = window.localStorage.getItem('color-mode'); + if (setting) { + if (setting === 'dark') { + currentColorMode = 'dark'; + } else if (setting === 'light') { + currentColorMode = 'light'; + } + } + + window.localStorage.setItem('color-mode', currentColorMode); + if (currentColorMode === ColorModes.Dark) { + document.body.classList.add('dark'); + document.querySelector('#displayModeSwitch').checked = true; + } else { + document.body.classList.remove('dark'); + document.querySelector('#displayModeSwitch').checked = false; + } +}; + +const codewarsIcn = ``; + const bootstrapNavbar = () => { const title = urls[location.pathname]; @@ -55,7 +82,7 @@ const bootstrapNavbar = () => { +
+
+ + +
+
@@ -74,4 +107,16 @@ const bootstrapNavbar = () => { } }; -window.addEventListener("load", bootstrapNavbar); \ No newline at end of file +window.addEventListener('load', () => { + bootstrapNavbar(); + initColorScheme(); + + document.querySelector('#displayModeSwitch').addEventListener('click', () => { + currentColorMode = currentColorMode === ColorModes.Dark ? ColorModes.Light : ColorModes.Dark; + if (currentColorMode === ColorModes.Dark) { + document.body.classList.add('dark'); + } else { + document.body.classList.remove('dark'); + } + }); +}); \ No newline at end of file