Skip to content

Commit

Permalink
Disable dark mode env var
Browse files Browse the repository at this point in the history
  • Loading branch information
vbaranov committed Feb 8, 2023
1 parent 410be96 commit a3acc75
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 11 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion apps/block_scout_web/assets/js/lib/history_chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ const grid = {
function isDarkMode () {
// @ts-ignore
const permanentDarkModeEnabled = document.getElementById('permanent-dark-mode').textContent === 'true'
if (!permanentDarkModeEnabled) {
// @ts-ignore
const darkModeSwitcherDisabled = document.getElementById('dark-mode-switcher-disabled').textContent === 'true'
if (darkModeSwitcherDisabled) {
return false
} else if (!permanentDarkModeEnabled) {
return Cookies.get('chakra-ui-color-mode') === 'dark'
} else {
return true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@
'sitekey': reCaptchaClientKey,
'theme': function () {
const permanentDarkModeEnabled = document.getElementById('permanent-dark-mode').textContent === 'true'
if (permanentDarkModeEnabled) {
const darkModeSwitcherDisabled = document.getElementById('dark-mode-switcher-disabled').textContent === 'true'
if (darkModeSwitcherDisabled) {
return 'light'
} else if (permanentDarkModeEnabled) {
return 'dark'
} else {
return getCookie('chakra-ui-color-mode')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,11 +176,13 @@
</div>
</li>
<!-- Dark mode changer -->
<button class="dark-mode-changer" id="dark-mode-changer">
<svg xmlns="http://www.w3.org/2000/svg" width="15" height="16">
<path fill="#9B62FF" fill-rule="evenodd" d="M14.88 11.578a.544.544 0 0 0-.599-.166 5.7 5.7 0 0 1-1.924.321c-3.259 0-5.91-2.632-5.91-5.866 0-1.947.968-3.759 2.59-4.849a.534.534 0 0 0-.225-.97A5.289 5.289 0 0 0 8.059 0C3.615 0 0 3.588 0 8s3.615 8 8.059 8c2.82 0 5.386-1.423 6.862-3.806a.533.533 0 0 0-.041-.616z"/>
</svg>
</button>
<%= unless Application.get_env(:block_scout_web, :dark_mode_switcher_disabled) do %>
<button class="dark-mode-changer" id="dark-mode-changer">
<svg xmlns="http://www.w3.org/2000/svg" width="15" height="16">
<path fill="#9B62FF" fill-rule="evenodd" d="M14.88 11.578a.544.544 0 0 0-.599-.166 5.7 5.7 0 0 1-1.924.321c-3.259 0-5.91-2.632-5.91-5.866 0-1.947.968-3.759 2.59-4.849a.534.534 0 0 0-.225-.97A5.289 5.289 0 0 0 8.059 0C3.615 0 0 3.588 0 8s3.615 8 8.059 8c2.82 0 5.386-1.423 6.862-3.806a.533.533 0 0 0-.041-.616z"/>
</svg>
</button>
<% end %>
<%= render BlockScoutWeb.LayoutView, "_account_menu_item.html", conn: @conn, current_user: @current_user %>
</ul>
<%= render BlockScoutWeb.LayoutView, "_search.html", conn: @conn, id: "main-search-autocomplete", additional_classes: ["mobile-search-hide"] %>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@
<div class="layout-container">
<!-- Block for passing backend runtime env variables to frontend -->
<div id="permanent-dark-mode" class="d-none" ><%= Application.get_env(:block_scout_web, :permanent_dark_mode_enabled) %></div>
<div id="dark-mode-switcher-disabled" class="d-none" ><%= Application.get_env(:block_scout_web, :dark_mode_switcher_disabled) %></div>
<div id="indexer-first-block" class="d-none" ><%= Application.get_env(:indexer, :first_block) %></div>
<!-- -->
<% show_maintenance_alert = Application.get_env(:block_scout_web, BlockScoutWeb.Chain)[:show_maintenance_alert] %>
Expand Down Expand Up @@ -264,7 +265,10 @@
function isDarkMode() {
const permanentDarkModeEnabled = document.getElementById('permanent-dark-mode').textContent === 'true'
if (!permanentDarkModeEnabled) {
const darkModeSwitcherDisabled = document.getElementById('dark-mode-switcher-disabled').textContent === 'true'
if (darkModeSwitcherDisabled) {
return false
} else if (!permanentDarkModeEnabled) {
return getCookie('chakra-ui-color-mode') === 'dark'
} else {
return true
Expand Down
2 changes: 1 addition & 1 deletion apps/block_scout_web/priv/gettext/default.pot
Original file line number Diff line number Diff line change
Expand Up @@ -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 ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 ""
Expand Down
3 changes: 2 additions & 1 deletion config/runtime.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
dark_mode_switcher_disabled: System.get_env("DARK_MODE_SWITCHER_DISABLE", "false") == "true"

default_api_rate_limit = 50
default_api_rate_limit_str = Integer.to_string(default_api_rate_limit)
Expand Down

0 comments on commit a3acc75

Please sign in to comment.