Blockchain explorer for Ethereum based network and a tool for inspecting and analyzing EVM based blockchains.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
blockscout/apps/block_scout_web/assets/js/lib/dark_mode.js

37 lines
1.0 KiB

import Cookies from 'js-cookie'
function isDarkMode () {
const permanentDarkModeEnabled = isPermanentDarkModeEnabled()
const permanentLightModeEnabled = isPermanentLightModeEnabled()
if (permanentLightModeEnabled) {
return false
} else if (permanentDarkModeEnabled) {
return true
} else {
return Cookies.get('chakra-ui-color-mode') === 'dark'
}
}
function getThemeMode () {
const permanentDarkModeEnabled = isPermanentDarkModeEnabled()
const permanentLightModeEnabled = isPermanentLightModeEnabled()
if (permanentLightModeEnabled) {
return 'light'
} else if (permanentDarkModeEnabled) {
return 'dark'
} else {
return Cookies.get('chakra-ui-color-mode')
}
}
function isPermanentDarkModeEnabled () {
// @ts-ignore
return document.getElementById('permanent-dark-mode').textContent === 'true'
}
function isPermanentLightModeEnabled () {
// @ts-ignore
return document.getElementById('permanent-light-mode').textContent === 'true'
}
export { isDarkMode, getThemeMode }