diff --git a/src/drivers/webextension/css/styles.css b/src/drivers/webextension/css/styles.css index 6d8b06fc4..d019afa14 100644 --- a/src/drivers/webextension/css/styles.css +++ b/src/drivers/webextension/css/styles.css @@ -2,12 +2,10 @@ --color-primary: #4608ad; --color-primary-darken: #32067c; --color-primary-lighten: #f4f1fa; - --color-accent: #2196f3; --color-secondary: #fafafa; --color-secondary-darken: #f5f5f5; --color-text: #4a4a4a; - --color-text-dark: rgba(255, 255, 255, .8); - --color-light-grey: #fafafa; + --color-text-dark: var(--color-primary-lighten); } * { @@ -26,7 +24,7 @@ body { } a, a:focus, a:hover { - color: var(--color-accent); + color: var(--color-primary); outline: none; text-decoration: underline; } @@ -58,6 +56,10 @@ a, a:focus, a:hover { width: 1.1rem; } +.header__icon--hidden { + display: none; +} + .header__switch { height: 1.5rem; width: 1.5rem; @@ -159,7 +161,7 @@ a, a:focus, a:hover { .footer__button-link:hover:before { background: var(--color-primary); - border-radius: 3px; + border-radius: 4px; content: ''; position: absolute; top: 0; @@ -285,6 +287,7 @@ body.dynamic-icon .category__heading:hover .category__pin { .technology__link, .technology__link:active, .technology__link:hover { align-items: center; display: flex; + overflow: hidden; padding: .1rem 0; text-decoration: none; width: 200px; @@ -383,51 +386,59 @@ body.dynamic-icon .category__heading:hover .category__pin { margin-top: 1rem; } -@media (prefers-color-scheme: dark) { - body.theme-mode { - background: var(--color-primary-darken); - color: var(--color-text-dark); - } - - body.theme-mode .category__link, body.theme-mode .category__link:active, body.theme-mode .category__link:hover { - color: var(--color-text-dark); - } - - body.theme-mode .technology__link { - color: var(--color-text-dark); - } - - body.theme-mode .technology__icon { - background: var(--color-primary); - } - - body.theme-mode .technology__version { - background: var(--color-primary); - color: var(--color-text-dark); - } - - body.theme-mode .technology__confidence { - background: var(--color-primary); - color: var(--color-text-dark); - } - - body.theme-mode .footer { - background: var(--color-primary); - color: var(--color-text-dark); - } - - body.theme-mode .footer__button { - color: var(--color-text-dark); - } - - body.theme-mode .terms__button { - background-color: white; - color: var(--color-primary); - } - - body.theme-mode .terms__button--decline { - background-color: var(--color-primary-darken); - border: 1px solid white; - color: white; - } +/* Dark mode */ + +.dark { + background: var(--color-primary-darken); + color: var(--color-text-dark); +} + +.dark .category__link, .dark .category__link:active, .dark .category__link:hover { + color: var(--color-text-dark); +} + +.dark .technology__link { + color: var(--color-text-dark); +} + +.dark .technology__name { + opacity: .8; +} + +.dark .technology__icon { +} + +.dark .technology__version { + background: var(--color-primary); + color: var(--color-text-dark); +} + +.dark .technology__confidence { + background: var(--color-primary); + color: var(--color-text-dark); +} + +.dark .footer { + background: var(--color-primary); + color: var(--color-text-dark); +} + +.dark .footer__button-link, .dark .footer__button-link:active, .dark .footer__button-link:hover { + color: var(--color-text-dark); +} + +.dark .footer__button-link:hover:before { + background: var(--color-primary-lighten); +} + + +.dark .terms__button { + background-color: white; + color: var(--color-primary); +} + +.dark .terms__button--decline { + background-color: var(--color-primary-darken); + border: 1px solid white; + color: white; } diff --git a/src/drivers/webextension/html/options.html b/src/drivers/webextension/html/options.html index b07b09cab..f7ffb9182 100644 --- a/src/drivers/webextension/html/options.html +++ b/src/drivers/webextension/html/options.html @@ -37,12 +37,6 @@   - - diff --git a/src/drivers/webextension/html/popup.html b/src/drivers/webextension/html/popup.html index 4912b706a..59b2adc87 100644 --- a/src/drivers/webextension/html/popup.html +++ b/src/drivers/webextension/html/popup.html @@ -34,6 +34,14 @@ + + + + + + + +
@@ -97,7 +105,7 @@ diff --git a/src/drivers/webextension/js/options.js b/src/drivers/webextension/js/options.js index cfa4c8b48..c43ebcea1 100644 --- a/src/drivers/webextension/js/options.js +++ b/src/drivers/webextension/js/options.js @@ -9,13 +9,6 @@ const Options = { * Initialise options */ async init() { - // Theme mode - const themeMode = await getOption('themeMode', false) - - if (themeMode) { - document.querySelector('body').classList.add('theme-mode') - } - const termsAccepted = agent === 'chrome' || (await getOption('termsAccepted', false)) @@ -24,7 +17,6 @@ const Options = { ['dynamicIcon', false], ['badge', true], ['tracking', true], - ['themeMode', false], ].map(async ([option, defaultValue]) => { const el = document .querySelector( diff --git a/src/drivers/webextension/js/popup.js b/src/drivers/webextension/js/popup.js index 04552b8f7..c6a7dff8c 100644 --- a/src/drivers/webextension/js/popup.js +++ b/src/drivers/webextension/js/popup.js @@ -85,11 +85,17 @@ const Popup = { // Disabled domains let disabledDomains = await getOption('disabledDomains', []) - // Theme mode - const themeMode = await getOption('themeMode', false) + // Dark mode + const theme = await getOption('theme', 'light') - if (themeMode) { - document.querySelector('body').classList.add('theme-mode') + if (theme === 'dark') { + document.querySelector('body').classList.add('dark') + document + .querySelector('.header__theme--light') + .classList.remove('header__icon--hidden') + document + .querySelector('.header__theme--dark') + .classList.add('header__icon--hidden') } // Terms @@ -183,6 +189,28 @@ const Popup = { .querySelector('.header__settings') .addEventListener('click', () => chrome.runtime.openOptionsPage()) + // Theme + const body = document.querySelector('body') + const dark = document.querySelector('.header__theme--dark') + const light = document.querySelector('.header__theme--light') + + document.querySelectorAll('.header__theme').forEach((el) => + el.addEventListener('click', async () => { + const theme = await getOption('theme', 'light') + + body.classList[theme === 'dark' ? 'remove' : 'add']('dark') + body.classList[theme === 'dark' ? 'add' : 'remove']('light') + dark.classList[theme === 'dark' ? 'remove' : 'add']( + 'header__icon--hidden' + ) + light.classList[theme === 'dark' ? 'add' : 'remove']( + 'header__icon--hidden' + ) + + await setOption('theme', theme === 'dark' ? 'light' : 'dark') + }) + ) + // Footer const item = footers[Math.round(Math.random() * (footers.length - 1))]