Fix flickering between light and custom themes

pull/3333/head
Victor Baranov 4 years ago
parent 71ca3a4f4e
commit 9d6efa6385
  1. 11
      apps/block_scout_web/lib/block_scout_web/templates/address/overview.html.eex
  2. 11
      apps/block_scout_web/lib/block_scout_web/templates/layout/app.html.eex
  3. 32
      apps/block_scout_web/priv/gettext/default.pot
  4. 32
      apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po

@ -2,17 +2,6 @@
<% dark_forest_address_var = Application.get_env(:block_scout_web, :dark_forest_address) %>
<% dark_forest_address = if dark_forest_address_var, do: String.downcase(dark_forest_address_var), else: nil %>
<% current_address = "0x" <> Base.encode16(@address.hash.bytes, case: :lower) %>
<script>
function applyCustomMode() {
const darkForestContractAddressHash = "<%= dark_forest_address %>"
const addressHash = "<%= @address.hash %>".toLowerCase()
if (addressHash == darkForestContractAddressHash) {
document.body.className += " " + "dark-forest-theme-applied";
}
}
window.onload = applyCustomMode()
</script>
<div class="row">
<!-- Address details -->
<div class="card-section col-md-12 col-lg-8 pr-0-md">

@ -36,7 +36,17 @@
</head>
<body>
<% dark_forest_address_var = Application.get_env(:block_scout_web, :dark_forest_address) %>
<% dark_forest_address = if dark_forest_address_var, do: String.downcase(dark_forest_address_var), else: nil %>
<script>
function applyCustomMode() {
const darkForestContractAddressHash = "<%= dark_forest_address %>"
const addressHash = "<%= @address.hash %>".toLowerCase()
if (window.location.pathname.toLowerCase().includes(darkForestContractAddressHash)) {
document.body.className += " " + "dark-forest-theme-applied";
}
}
function applyDarkMode() {
if (localStorage.getItem("current-color-mode") === "dark") {
document.body.className += " " + "dark-theme-applied";
@ -44,6 +54,7 @@
}
}
window.onload = applyDarkMode()
window.onload = applyCustomMode()
</script>
<div class="layout-container">
<%= if not Explorer.Chain.finished_indexing?() do %>

@ -72,7 +72,7 @@ msgid "(query)"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/layout/app.html.eex:56
#: lib/block_scout_web/templates/layout/app.html.eex:67
msgid "- We're indexing this chain right now. Some of the counts may be inaccurate."
msgstr ""
@ -406,8 +406,8 @@ msgid "Copy ABI"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address/overview.html.eex:41
#: lib/block_scout_web/templates/address/overview.html.eex:45
#: lib/block_scout_web/templates/address/overview.html.eex:30
#: lib/block_scout_web/templates/address/overview.html.eex:34
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:16
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:20
msgid "Copy Address"
@ -465,7 +465,7 @@ msgid "Create2"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address/overview.html.eex:124
#: lib/block_scout_web/templates/address/overview.html.eex:113
msgid "Created by"
msgstr ""
@ -536,7 +536,7 @@ msgid "Description"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address/overview.html.eex:36
#: lib/block_scout_web/templates/address/overview.html.eex:25
#: lib/block_scout_web/templates/api_docs/_action_tile.html.eex:166
#: lib/block_scout_web/templates/api_docs/_eth_rpc_item.html.eex:127
msgid "Details"
@ -627,7 +627,7 @@ msgid "Error: (Awaiting internal transactions for reason)"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address/overview.html.eex:137
#: lib/block_scout_web/templates/address/overview.html.eex:126
msgid "Error: Could not determine contract creator."
msgstr ""
@ -961,7 +961,7 @@ msgid "It could still be in the TX Pool of a different node, waiting to be broad
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address/overview.html.eex:109
#: lib/block_scout_web/templates/address/overview.html.eex:98
msgid "Last Balance Update: Block #"
msgstr ""
@ -1172,8 +1172,8 @@ msgid "Price"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address/overview.html.eex:61
#: lib/block_scout_web/templates/address/overview.html.eex:161
#: lib/block_scout_web/templates/address/overview.html.eex:50
#: lib/block_scout_web/templates/address/overview.html.eex:150
#: lib/block_scout_web/templates/tokens/instance/overview/_details.html.eex:51
#: lib/block_scout_web/templates/tokens/instance/overview/_details.html.eex:101
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:36
@ -1284,14 +1284,14 @@ msgid "Show"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address/overview.html.eex:62
#: lib/block_scout_web/templates/address/overview.html.eex:51
#: lib/block_scout_web/templates/tokens/instance/overview/_details.html.eex:52
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:37
msgid "Show QR Code"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address/overview.html.eex:76
#: lib/block_scout_web/templates/address/overview.html.eex:65
msgid "Show Validator Info"
msgstr ""
@ -1556,7 +1556,7 @@ msgid "Validator Data"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address/overview.html.eex:80
#: lib/block_scout_web/templates/address/overview.html.eex:69
msgid "Validator Info"
msgstr ""
@ -1656,7 +1656,7 @@ msgid "Yes"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address/overview.html.eex:129
#: lib/block_scout_web/templates/address/overview.html.eex:118
msgid "at"
msgstr ""
@ -1714,8 +1714,8 @@ msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address/_validator_metadata_modal.html.eex:37
#: lib/block_scout_web/templates/address/overview.html.eex:162
#: lib/block_scout_web/templates/address/overview.html.eex:170
#: lib/block_scout_web/templates/address/overview.html.eex:151
#: lib/block_scout_web/templates/address/overview.html.eex:159
#: lib/block_scout_web/templates/tokens/instance/overview/_details.html.eex:102
#: lib/block_scout_web/templates/tokens/instance/overview/_details.html.eex:110
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:122
@ -1987,6 +1987,6 @@ msgid "Bridged Tokens"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address/overview.html.eex:27
#: lib/block_scout_web/templates/address/overview.html.eex:16
msgid "zkSnark space warfare (v0.4)"
msgstr ""

@ -72,7 +72,7 @@ msgid "(query)"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/layout/app.html.eex:56
#: lib/block_scout_web/templates/layout/app.html.eex:67
msgid "- We're indexing this chain right now. Some of the counts may be inaccurate."
msgstr ""
@ -406,8 +406,8 @@ msgid "Copy ABI"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address/overview.html.eex:41
#: lib/block_scout_web/templates/address/overview.html.eex:45
#: lib/block_scout_web/templates/address/overview.html.eex:30
#: lib/block_scout_web/templates/address/overview.html.eex:34
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:16
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:20
msgid "Copy Address"
@ -465,7 +465,7 @@ msgid "Create2"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address/overview.html.eex:124
#: lib/block_scout_web/templates/address/overview.html.eex:113
msgid "Created by"
msgstr ""
@ -536,7 +536,7 @@ msgid "Description"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address/overview.html.eex:36
#: lib/block_scout_web/templates/address/overview.html.eex:25
#: lib/block_scout_web/templates/api_docs/_action_tile.html.eex:166
#: lib/block_scout_web/templates/api_docs/_eth_rpc_item.html.eex:127
msgid "Details"
@ -627,7 +627,7 @@ msgid "Error: (Awaiting internal transactions for reason)"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address/overview.html.eex:137
#: lib/block_scout_web/templates/address/overview.html.eex:126
msgid "Error: Could not determine contract creator."
msgstr ""
@ -961,7 +961,7 @@ msgid "It could still be in the TX Pool of a different node, waiting to be broad
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address/overview.html.eex:109
#: lib/block_scout_web/templates/address/overview.html.eex:98
msgid "Last Balance Update: Block #"
msgstr ""
@ -1172,8 +1172,8 @@ msgid "Price"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address/overview.html.eex:61
#: lib/block_scout_web/templates/address/overview.html.eex:161
#: lib/block_scout_web/templates/address/overview.html.eex:50
#: lib/block_scout_web/templates/address/overview.html.eex:150
#: lib/block_scout_web/templates/tokens/instance/overview/_details.html.eex:51
#: lib/block_scout_web/templates/tokens/instance/overview/_details.html.eex:101
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:36
@ -1284,14 +1284,14 @@ msgid "Show"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address/overview.html.eex:62
#: lib/block_scout_web/templates/address/overview.html.eex:51
#: lib/block_scout_web/templates/tokens/instance/overview/_details.html.eex:52
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:37
msgid "Show QR Code"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address/overview.html.eex:76
#: lib/block_scout_web/templates/address/overview.html.eex:65
msgid "Show Validator Info"
msgstr ""
@ -1556,7 +1556,7 @@ msgid "Validator Data"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address/overview.html.eex:80
#: lib/block_scout_web/templates/address/overview.html.eex:69
msgid "Validator Info"
msgstr ""
@ -1656,7 +1656,7 @@ msgid "Yes"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address/overview.html.eex:129
#: lib/block_scout_web/templates/address/overview.html.eex:118
msgid "at"
msgstr ""
@ -1714,8 +1714,8 @@ msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address/_validator_metadata_modal.html.eex:37
#: lib/block_scout_web/templates/address/overview.html.eex:162
#: lib/block_scout_web/templates/address/overview.html.eex:170
#: lib/block_scout_web/templates/address/overview.html.eex:151
#: lib/block_scout_web/templates/address/overview.html.eex:159
#: lib/block_scout_web/templates/tokens/instance/overview/_details.html.eex:102
#: lib/block_scout_web/templates/tokens/instance/overview/_details.html.eex:110
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:122
@ -1987,6 +1987,6 @@ msgid "Bridged Tokens"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address/overview.html.eex:27
#: lib/block_scout_web/templates/address/overview.html.eex:16
msgid "zkSnark space warfare (v0.4)"
msgstr ""

Loading…
Cancel
Save