diff --git a/CHANGELOG.md b/CHANGELOG.md index bbc6e18cb9..9931e53506 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ ### Features +- [#6838](https://github.com/blockscout/blockscout/pull/6838) - Disable dark mode env var - [#6744](https://github.com/blockscout/blockscout/pull/6744) - API v2: smart contracts verification - [#6763](https://github.com/blockscout/blockscout/pull/6763) - Permanent UI dark mode - [#6721](https://github.com/blockscout/blockscout/pull/6721) - Implement fetching internal transactions from callTracer diff --git a/apps/block_scout_web/assets/js/lib/history_chart.js b/apps/block_scout_web/assets/js/lib/history_chart.js index ef0884665c..efd1b5c673 100644 --- a/apps/block_scout_web/assets/js/lib/history_chart.js +++ b/apps/block_scout_web/assets/js/lib/history_chart.js @@ -21,10 +21,14 @@ const grid = { function isDarkMode () { // @ts-ignore const permanentDarkModeEnabled = document.getElementById('permanent-dark-mode').textContent === 'true' - if (!permanentDarkModeEnabled) { - return Cookies.get('chakra-ui-color-mode') === 'dark' - } else { + // @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' } } diff --git a/apps/block_scout_web/assets/js/pages/dark-mode-switcher.js b/apps/block_scout_web/assets/js/pages/dark-mode-switcher.js index 0284c9e478..610e4d47b4 100644 --- a/apps/block_scout_web/assets/js/pages/dark-mode-switcher.js +++ b/apps/block_scout_web/assets/js/pages/dark-mode-switcher.js @@ -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() }) diff --git a/apps/block_scout_web/lib/block_scout_web/templates/csv_export/index.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/csv_export/index.html.eex index 07a1ee0d13..352304462d 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/csv_export/index.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/csv_export/index.html.eex @@ -34,7 +34,10 @@ 'sitekey': reCaptchaClientKey, 'theme': function () { const permanentDarkModeEnabled = document.getElementById('permanent-dark-mode').textContent === 'true' - if (permanentDarkModeEnabled) { + const permanentLightModeEnabled = document.getElementById('permanent-light-mode').textContent === 'true' + if (permanentLightModeEnabled) { + return 'light' + } else if (permanentDarkModeEnabled) { return 'dark' } else { return getCookie('chakra-ui-color-mode') diff --git a/apps/block_scout_web/lib/block_scout_web/templates/layout/_topnav.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/layout/_topnav.html.eex index 494934049d..2d8c4feb42 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/layout/_topnav.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/layout/_topnav.html.eex @@ -176,11 +176,13 @@ - + <%= unless Application.get_env(:block_scout_web, :permanent_light_mode_enabled) || Application.get_env(:block_scout_web, :permanent_dark_mode_enabled) do %> + + <% end %> <%= render BlockScoutWeb.LayoutView, "_account_menu_item.html", conn: @conn, current_user: @current_user %> <%= render BlockScoutWeb.LayoutView, "_search.html", conn: @conn, id: "main-search-autocomplete", additional_classes: ["mobile-search-hide"] %> diff --git a/apps/block_scout_web/lib/block_scout_web/templates/layout/app.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/layout/app.html.eex index 25a4d36fb2..f970aff1fd 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/layout/app.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/layout/app.html.eex @@ -157,6 +157,7 @@
<%= Application.get_env(:block_scout_web, :permanent_dark_mode_enabled) %>
+
<%= Application.get_env(:block_scout_web, :permanent_light_mode_enabled) %>
<%= Application.get_env(:indexer, :first_block) %>
<% show_maintenance_alert = Application.get_env(:block_scout_web, BlockScoutWeb.Chain)[:show_maintenance_alert] %> @@ -264,10 +265,13 @@ function isDarkMode() { const permanentDarkModeEnabled = document.getElementById('permanent-dark-mode').textContent === 'true' - if (!permanentDarkModeEnabled) { - return getCookie('chakra-ui-color-mode') === 'dark' - } else { + const permanentLightModeEnabled = document.getElementById('permanent-light-mode').textContent === 'true' + if (permanentLightModeEnabled) { + return false + } else if (permanentDarkModeEnabled) { return true + } else { + return getCookie('chakra-ui-color-mode') === 'dark' } } diff --git a/apps/block_scout_web/priv/gettext/default.pot b/apps/block_scout_web/priv/gettext/default.pot index 311b9a6ae5..a6b1805604 100644 --- a/apps/block_scout_web/priv/gettext/default.pot +++ b/apps/block_scout_web/priv/gettext/default.pot @@ -81,7 +81,7 @@ msgstr "" msgid ") may be added for each contract. Click the Add Library button to add an additional one." msgstr "" -#: lib/block_scout_web/templates/layout/app.html.eex:178 +#: lib/block_scout_web/templates/layout/app.html.eex:179 #, elixir-autogen, elixir-format msgid "- We're indexing this chain right now. Some of the counts may be inaccurate." msgstr "" diff --git a/apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po b/apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po index a2a3402bf4..5dafe0b01d 100644 --- a/apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po +++ b/apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po @@ -81,7 +81,7 @@ msgstr "" msgid ") may be added for each contract. Click the Add Library button to add an additional one." msgstr "" -#: lib/block_scout_web/templates/layout/app.html.eex:178 +#: lib/block_scout_web/templates/layout/app.html.eex:179 #, elixir-autogen, elixir-format msgid "- We're indexing this chain right now. Some of the counts may be inaccurate." msgstr "" diff --git a/config/runtime.exs b/config/runtime.exs index 56bad9a9cb..ecb0d7fe52 100644 --- a/config/runtime.exs +++ b/config/runtime.exs @@ -101,7 +101,8 @@ config :block_scout_web, chain_id: System.get_env("CHAIN_ID"), json_rpc: System.get_env("JSON_RPC"), verification_max_libraries: verification_max_libraries, - permanent_dark_mode_enabled: System.get_env("PERMANENT_DARK_MODE_ENABLED", "false") == "true" + permanent_dark_mode_enabled: System.get_env("PERMANENT_DARK_MODE_ENABLED", "false") == "true", + permanent_light_mode_enabled: System.get_env("PERMANENT_LIGHT_MODE_ENABLED", "false") == "true" default_api_rate_limit = 50 default_api_rate_limit_str = Integer.to_string(default_api_rate_limit)