From fb534b774f09a458bbed8175132178a21d256ada Mon Sep 17 00:00:00 2001 From: ioedeveloper Date: Tue, 18 Aug 2020 11:31:07 +0100 Subject: [PATCH] Changed text color and refactored state changed logic. --- apps/remix-ide/src/app/tabs/settings-tab.js | 49 ++++++++++--------- .../app/tabs/styles/settings-tab-styles.js | 8 --- 2 files changed, 25 insertions(+), 32 deletions(-) diff --git a/apps/remix-ide/src/app/tabs/settings-tab.js b/apps/remix-ide/src/app/tabs/settings-tab.js index 4790f30b1a..f460dcd977 100644 --- a/apps/remix-ide/src/app/tabs/settings-tab.js +++ b/apps/remix-ide/src/app/tabs/settings-tab.js @@ -82,19 +82,15 @@ module.exports = class SettingsTab extends ViewPlugin { const gistRemoveToken = yo`` this._view.gistToken = yo`
${gistAccessToken}
${copyToClipboard(() => gistAccessToken.value)}${gistAddToken}${gistRemoveToken}
` this._view.optionVM = yo`` - this._view.optionVMLabel = yo`` + this._view.optionVMLabel = yo`` if (this.config.get('settings/always-use-vm') === undefined) this.config.set('settings/always-use-vm', true) - if (this.config.get('settings/always-use-vm')) { - this._view.optionVM.setAttribute('checked', '') - this._view.optionVMLabel.classList.remove("text-dark") - } else this._view.optionVMLabel.classList.add("text-dark") + if (this.config.get('settings/always-use-vm')) this._view.optionVM.setAttribute('checked', '') + elementStateChanged(self._view.optionVMLabel, !this.config.get('settings/always-use-vm')) this._view.textWrap = yo`` - this._view.textWrapLabel = yo`` - if (this.config.get('settings/text-wrap')) { - this._view.textWrap.setAttribute('checked', '') - this._view.textWrapLabel.classList.remove("text-dark") - } else this._view.textWrapLabel.classList.add("text-dark") + this._view.textWrapLabel = yo`` + if (this.config.get('settings/text-wrap')) this._view.textWrap.setAttribute('checked', '') + elementStateChanged(self._view.textWrapLabel, !this.config.get('settings/text-wrap')) const warnText = `Transaction sent over Web3 will use the web3.personal API - be sure the endpoint is opened before enabling it. This mode allows to provide the passphrase in the Remix interface without having to unlock the account. @@ -103,18 +99,14 @@ module.exports = class SettingsTab extends ViewPlugin { this._view.personal = yo`` this._view.warnPersonalMode = yo`` - this._view.personalLabel = yo`` - if (this.config.get('settings/personal-mode')) { - this._view.personal.setAttribute('checked', '') - this._view.personalLabel.classList.remove("text-dark") - } else this._view.personalLabel.classList.add("text-dark") + this._view.personalLabel = yo`` + if (this.config.get('settings/personal-mode')) this._view.personal.setAttribute('checked', '') + elementStateChanged(self._view.personalLabel, !this.config.get('settings/personal-mode')) this._view.generateContractMetadata = yo`` - this._view.generateContractMetadataLabel = yo`` - if (this.config.get('settings/generate-contract-metadata')) { - this._view.generateContractMetadata.setAttribute('checked', '') - this._view.generateContractMetadataLabel.classList.remove("text-dark") - } else this._view.generateContractMetadataLabel.classList.add("text-dark") + this._view.generateContractMetadataLabel = yo`` + if (this.config.get('settings/generate-contract-metadata')) this._view.generateContractMetadata.setAttribute('checked', '') + elementStateChanged(self._view.generateContractMetadataLabel, !this.config.get('settings/generate-contract-metadata')) this._view.pluginInput = yo`` @@ -172,26 +164,35 @@ module.exports = class SettingsTab extends ViewPlugin { const isChecked = self.config.get('settings/generate-contract-metadata') self.config.set('settings/generate-contract-metadata', !isChecked) - isChecked ? self._view.generateContractMetadataLabel.classList.add("text-dark") : self._view.generateContractMetadataLabel.classList.remove("text-dark") + elementStateChanged(self._view.generateContractMetadataLabel, isChecked) } function onchangeOption (event) { const isChecked = self.config.get('settings/always-use-vm') self.config.set('settings/always-use-vm', !isChecked) - isChecked ? self._view.optionVMLabel.classList.add("text-dark") : self._view.optionVMLabel.classList.remove("text-dark") + elementStateChanged(self._view.optionVMLabel, isChecked) } function textWrapEvent (event) { const isChecked = self.config.get('settings/text-wrap') self.config.set('settings/text-wrap', !isChecked) - isChecked ? self._view.textWrapLabel.classList.add("text-dark") : self._view.textWrapLabel.classList.remove("text-dark") + elementStateChanged(self._view.textWrapLabel, isChecked) self.editor.resize(!isChecked) } function onchangePersonal (event) { const isChecked = self.config.get('settings/personal-mode') self.config.set('settings/personal-mode', !isChecked) - isChecked ? self._view.personalLabel.classList.add("text-dark") : self._view.personalLabel.classList.remove("text-dark") + elementStateChanged(self._view.personalLabel, isChecked) + } + function elementStateChanged(el, isChanged){ + if (isChanged) { + el.classList.remove("text-dark") + el.classList.add("text-secondary") + } else { + el.classList.add("text-dark") + el.classList.remove("text-secondary") + } } this._deps.themeModule.switchTheme() diff --git a/apps/remix-ide/src/app/tabs/styles/settings-tab-styles.js b/apps/remix-ide/src/app/tabs/styles/settings-tab-styles.js index 1c5ac85870..513acbea8b 100644 --- a/apps/remix-ide/src/app/tabs/styles/settings-tab-styles.js +++ b/apps/remix-ide/src/app/tabs/styles/settings-tab-styles.js @@ -70,14 +70,6 @@ const css = csjs` display: inline; width: 32%; } - .customCheckBox::before, .customCheckBox::after { - top: .7em - } - .customRadio::before, .customRadio::after { - -moz-border-radius: 50%; - -webkit-border-radius: 50%; - border-radius: 50%; - } .text, .text:hover { text-decoration: none; }