diff --git a/add-on/src/options/forms/api-form.js b/add-on/src/options/forms/api-form.js
index 17b0e194b..780ad2862 100644
--- a/add-on/src/options/forms/api-form.js
+++ b/add-on/src/options/forms/api-form.js
@@ -4,6 +4,7 @@
const browser = require('webextension-polyfill')
const html = require('choo/html')
const { normalizeGatewayURL } = require('../../lib/options')
+const switchToggle = require('../../pages/components/switch-toggle')
function apiForm ({ ipfsApiUrl, ipfsApiPollMs, automaticMode, onOptionChange }) {
const onIpfsApiUrlChange = onOptionChange('ipfsApiUrl', normalizeGatewayURL)
@@ -57,11 +58,7 @@ function apiForm ({ ipfsApiUrl, ipfsApiPollMs, automaticMode, onOptionChange })
${browser.i18n.getMessage('option_automaticMode_description')}
-
+ ${switchToggle({ id: 'automaticMode', checked: automaticMode, onchange: onAutomaticModeChange })}
diff --git a/add-on/src/options/forms/experiments-form.js b/add-on/src/options/forms/experiments-form.js
index 51b3fffdd..4bb3d012d 100644
--- a/add-on/src/options/forms/experiments-form.js
+++ b/add-on/src/options/forms/experiments-form.js
@@ -3,6 +3,7 @@
const browser = require('webextension-polyfill')
const html = require('choo/html')
+const switchToggle = require('../../pages/components/switch-toggle')
function experimentsForm ({
displayNotifications,
@@ -35,7 +36,7 @@ function experimentsForm ({
${browser.i18n.getMessage('option_displayNotifications_description')}
-
+ ${switchToggle({ id: 'displayNotifications', checked: displayNotifications, onchange: onDisplayNotificationsChange })}
-
+
${switchToggle({ id: 'preloadAtPublicGateway', checked: preloadAtPublicGateway, onchange: onPreloadAtPublicGatewayChange })}
-
+
${switchToggle({ id: 'catchUnhandledProtocols', checked: catchUnhandledProtocols, onchange: onCatchUnhandledProtocolsChange })}
-
+
${switchToggle({ id: 'linkify', checked: linkify, onchange: onLinkifyChange })}
-
+
${switchToggle({ id: 'detectIpfsPathHeader', checked: detectIpfsPathHeader, onchange: onDetectIpfsPathHeaderChange })}
-
+
diff --git a/add-on/src/options/forms/gateways-form.js b/add-on/src/options/forms/gateways-form.js
index df993b9cd..b16f0e763 100644
--- a/add-on/src/options/forms/gateways-form.js
+++ b/add-on/src/options/forms/gateways-form.js
@@ -3,6 +3,7 @@
const browser = require('webextension-polyfill')
const html = require('choo/html')
+const switchToggle = require('../../pages/components/switch-toggle')
const { normalizeGatewayURL, hostTextToArray, hostArrayToText } = require('../../lib/options')
// Warn about mixed content issues when changing the gateway
@@ -77,11 +78,7 @@ function gatewaysForm ({
${browser.i18n.getMessage('option_useCustomGateway_description')}
-
+ ${switchToggle({ id: 'useCustomGateway', checked: useCustomGateway, onchange: onUseCustomGatewayChange })}
` : null}
${supportRedirectToCustomGateway ? html`
@@ -96,7 +93,7 @@ function gatewaysForm ({
id="noRedirectHostnames"
spellcheck="false"
onchange=${onNoRedirectHostnamesChange}
- rows="4"
+ rows="4"
>${hostArrayToText(noRedirectHostnames)}
` : null}
diff --git a/add-on/src/options/forms/global-toggle-form.js b/add-on/src/options/forms/global-toggle-form.js
index f1f9d1487..68c7bffde 100644
--- a/add-on/src/options/forms/global-toggle-form.js
+++ b/add-on/src/options/forms/global-toggle-form.js
@@ -3,13 +3,14 @@
const browser = require('webextension-polyfill')
const html = require('choo/html')
+const switchToggle = require('../../pages/components/switch-toggle')
function globalToggleForm ({ active, onOptionChange }) {
- const toggle = onOptionChange('active', checked => !checked)
+ const toggle = onOptionChange('active')
return html`
diff --git a/add-on/src/options/options.css b/add-on/src/options/options.css
index 372a2a2f7..affef00d3 100644
--- a/add-on/src/options/options.css
+++ b/add-on/src/options/options.css
@@ -1,5 +1,7 @@
@import url('/ui-kit/tachyons.css');
@import url('/ui-kit/ipfs.css');
+@import url('../pages/components/switch-toggle.css');
+
html {
overflow: hidden;
}
@@ -51,7 +53,6 @@ fieldset > div > * {
label {
flex: 1;
}
-input[type=checkbox]:hover,
select:hover,
button:hover,
label:hover {
@@ -84,6 +85,7 @@ input, textarea, select {
padding: .5em;
font-family: monospace;
}
+fieldset > div > div,
#resetAllOptions {
flex: 1;
text-align: center;
@@ -95,12 +97,10 @@ textarea,
select {
-webkit-transition: all 0.30s ease-in-out;
-moz-transition: all 0.30s ease-in-out;
- border: 1px solid #ccc;
-}
-input[type=checkbox]:focus,
-input[type=checkbox]::-moz-focus-inner {
- border: 0;
- outline: none;
+ box-shadow: 0 1px 4px rgba(0,0,0,.04);
+ border-radius: 3px;
+ border: 1px solid #9ad4db;
+ background-color: white;
}
input[type=text]:focus,
input[type=url]:focus,
@@ -111,10 +111,26 @@ select:focus {
border: 1px solid #3E9398;
box-shadow: 0 0 5px #5FCBCF;
}
+
+button#resetAllOptions:hover,
input:invalid {
- border: 1px solid red !important;
+ border: 1px solid red;
background-color: #FFF0F0;
- box-shadow: 0 0 5px red !important;
+ box-shadow: 0 0 5px red;
color: red;
transition: box-shadow 0.3s;
}
+button#resetAllOptions {
+ box-shadow: 0 1px 4px rgba(0,0,0,.04);
+ border-radius: 3px;
+ border: 1px solid #f36149;
+ background-color: #f7f8fa;
+ color: #f36149;
+ padding: .5em;
+}
+button#resetAllOptions:active {
+ border: 1px solid #3E9398 !important;
+ box-shadow: 0 0 5px #5FCBCF !important;
+ color: #3E9398;
+ background-color: white;
+}
diff --git a/add-on/src/pages/components/switch-toggle.css b/add-on/src/pages/components/switch-toggle.css
new file mode 100644
index 000000000..f65e9f6a0
--- /dev/null
+++ b/add-on/src/pages/components/switch-toggle.css
@@ -0,0 +1,11 @@
+@import url('/ui-kit/mdc.switch.min.css');
+
+.mdc-switch {
+ --mdc-theme-secondary: #3e9096 /* teal */
+}
+
+.mdc-switch:not(.mdc-switch--checked) .mdc-switch__thumb,
+.mdc-switch:not(.mdc-switch--checked) .mdc-switch__track {
+ background-color: #7f8491; /* charcoal-muted */
+ border-color: #7f8491;
+}
diff --git a/add-on/src/popup/browser-action/switch-toggle.js b/add-on/src/pages/components/switch-toggle.js
similarity index 66%
rename from add-on/src/popup/browser-action/switch-toggle.js
rename to add-on/src/pages/components/switch-toggle.js
index 987c911c8..9ef4b735f 100644
--- a/add-on/src/popup/browser-action/switch-toggle.js
+++ b/add-on/src/pages/components/switch-toggle.js
@@ -3,14 +3,14 @@
const html = require('choo/html')
-function switchToggle ({ checked, disabled, style }) {
+function switchToggle ({ id, onchange, checked, disabled, style }) {
if (typeof checked === 'undefined') return
return html`
-
+
diff --git a/add-on/src/popup/browser-action/browser-action.css b/add-on/src/popup/browser-action/browser-action.css
index cc9f4aeb8..55554576c 100644
--- a/add-on/src/popup/browser-action/browser-action.css
+++ b/add-on/src/popup/browser-action/browser-action.css
@@ -1,7 +1,7 @@
@import url('/ui-kit/tachyons.css');
@import url('/ui-kit/ipfs.css');
-@import url('/ui-kit/mdc.switch.min.css');
@import url('../heartbeat.css');
+@import url('../../pages/components/switch-toggle.css');
.bg-near-white--hover:hover {
background-color: #F4F4F4;
@@ -43,12 +43,3 @@
from { opacity: 0; }
to { opacity: 1; }
}
-
-.mdc-switch {
- --mdc-theme-secondary: #3e9096 /* teal */
-}
-
-.mdc-switch:not(.mdc-switch--checked) .mdc-switch__thumb {
- background-color: #34373f; /* charcoal */
- border-color: #34373f;
-}
diff --git a/add-on/src/popup/browser-action/nav-item.js b/add-on/src/popup/browser-action/nav-item.js
index be5f1d490..ed5a5bb6e 100644
--- a/add-on/src/popup/browser-action/nav-item.js
+++ b/add-on/src/popup/browser-action/nav-item.js
@@ -2,7 +2,7 @@
/* eslint-env browser, webextensions */
const html = require('choo/html')
-const switchToggle = require('./switch-toggle')
+const switchToggle = require('../../pages/components/switch-toggle')
function navItem ({ icon, text, title, disabled, style, onClick, switchValue }) {
let buttonStyle = 'black button-reset db w-100 bg-white b--none outline-0--focus pv2 ph3 f5 tl'