Merge pull request #6838 from blockscout/vb-disable-dark-mode
Permanent light mode UIpull/6857/head
commit
4233c7db2a
@ -0,0 +1,33 @@ |
||||
import { isDarkMode } from './lib/dark_mode' |
||||
|
||||
function applyDarkMode () { |
||||
if (isDarkMode()) { |
||||
document.body.className += ' ' + 'dark-theme-applied' |
||||
document.body.style.backgroundColor = '#1c1d31' |
||||
} |
||||
} |
||||
window.onload = applyDarkMode() |
||||
|
||||
if (isDarkMode()) { |
||||
if (document.getElementById('top-navbar')) { |
||||
document.getElementById('top-navbar').style.backgroundColor = '#282945' |
||||
} |
||||
if (document.getElementById('navbar-logo')) { |
||||
document.getElementById('navbar-logo').style.filter = 'brightness(0) invert(1)' |
||||
} |
||||
const modeChanger = document.getElementById('dark-mode-changer') |
||||
if (modeChanger) { |
||||
modeChanger.className += ' ' + 'dark-mode-changer--dark' |
||||
} |
||||
|
||||
const search = document.getElementById('main-search-autocomplete') |
||||
const searchMobile = document.getElementById('main-search-autocomplete-mobile') |
||||
if (search && search.style) { |
||||
search.style.backgroundColor = '#22223a' |
||||
search.style.borderColor = '#22223a' |
||||
} |
||||
if (searchMobile && searchMobile.style) { |
||||
searchMobile.style.backgroundColor = '#22223a' |
||||
searchMobile.style.borderColor = '#22223a' |
||||
} |
||||
} |
@ -0,0 +1,17 @@ |
||||
import Cookies from 'js-cookie' |
||||
|
||||
function isDarkMode () { |
||||
// @ts-ignore
|
||||
const permanentDarkModeEnabled = document.getElementById('permanent-dark-mode').textContent === 'true' |
||||
// @ts-ignore
|
||||
const permanentLightModeEnabled = document.getElementById('permanent-light-mode').textContent === 'true' |
||||
if (permanentLightModeEnabled) { |
||||
return false |
||||
} else if (permanentDarkModeEnabled) { |
||||
return true |
||||
} else { |
||||
return Cookies.get('chakra-ui-color-mode') === 'dark' |
||||
} |
||||
} |
||||
|
||||
export { isDarkMode } |
@ -1,22 +1,12 @@ |
||||
import Cookies from 'js-cookie' |
||||
const permantDarkModeEl = document.getElementById('permanent-dark-mode') |
||||
// @ts-ignore
|
||||
const permanentDarkModeEnabled = false || (permantDarkModeEl && permantDarkModeEl.textContent === 'true') |
||||
// @ts-ignore
|
||||
const darkModeChangerEl = document.getElementsByClassName('dark-mode-changer')[0] |
||||
|
||||
if (permanentDarkModeEnabled) { |
||||
// @ts-ignore
|
||||
darkModeChangerEl.style.display = 'none' |
||||
} |
||||
|
||||
darkModeChangerEl && darkModeChangerEl.addEventListener('click', function () { |
||||
if (!permanentDarkModeEnabled) { |
||||
if (Cookies.get('chakra-ui-color-mode') === 'dark') { |
||||
Cookies.set('chakra-ui-color-mode', 'light') |
||||
} else { |
||||
Cookies.set('chakra-ui-color-mode', 'dark') |
||||
} |
||||
document.location.reload() |
||||
if (Cookies.get('chakra-ui-color-mode') === 'dark') { |
||||
Cookies.set('chakra-ui-color-mode', 'light') |
||||
} else { |
||||
Cookies.set('chakra-ui-color-mode', 'dark') |
||||
} |
||||
document.location.reload() |
||||
}) |
||||
|
Loading…
Reference in new issue