From 22b3cd9d335ab874718606aaa994798f7721cb0d Mon Sep 17 00:00:00 2001 From: martholomew Date: Thu, 24 Oct 2024 18:26:46 -0600 Subject: [PATCH 1/5] Reduxed the action popup; added an svg to material.css; redid some logic in action-popup-main.js --- ext/action-popup.html | 125 +++++---------- ext/css/action-popup.css | 252 ++++++++++++++---------------- ext/css/material.css | 1 + ext/images/info.svg | 1 + ext/js/pages/action-popup-main.js | 34 +++- 5 files changed, 193 insertions(+), 220 deletions(-) create mode 100644 ext/images/info.svg diff --git a/ext/action-popup.html b/ext/action-popup.html index ddaec23206..c2f5c16f7f 100644 --- a/ext/action-popup.html +++ b/ext/action-popup.html @@ -11,94 +11,55 @@ + - -
- Loading... -
- -
-
- -
- - + - -
- - - + + + +
diff --git a/ext/css/action-popup.css b/ext/css/action-popup.css index c19dffa574..a894b949a7 100644 --- a/ext/css/action-popup.css +++ b/ext/css/action-popup.css @@ -38,7 +38,6 @@ --background-color: #f8f9fa; --text-color: #333333; --svg-filter: 0; - --animation-duration: 0.5s; } :root[data-theme=dark] { @@ -393,7 +392,6 @@ select.profile-select { cursor: pointer; } - .action-icon { flex: 0 0 auto; align-self: center; @@ -405,9 +403,13 @@ select.profile-select { height: 1.5em; } +.low-emphasis { + position: relative; +} + .action-item { position: relative; - padding: .5em; + padding: 0.5em; } .action-item:not([hidden]) { display: block; @@ -449,7 +451,7 @@ select.profile-select { align-items: center; align-content: center; justify-content: flex-end; - padding-left: .5em; + padding-left: 0.5em; } .action-container { @@ -465,7 +467,7 @@ select.profile-select { /* Misc */ -h2 { +h2.action-title { padding: 0; margin: 0; font-size: 1.125em; @@ -474,15 +476,21 @@ h2 { } .tooltip { - color: gray; + color: #808080; padding: 0; margin: 0; } -input[type=text] { - width: 12em; +.enable-dictionary-tooltip { + color: #ff0000; + font-weight: bold; + font-style: normal; } +.tooltip>a:link, a:visited { + color: #ff0000; + font-style: normal; +} /* Mobile overrides */ diff --git a/ext/css/material.css b/ext/css/material.css index d82acbfefd..9013365f6c 100644 --- a/ext/css/material.css +++ b/ext/css/material.css @@ -282,7 +282,6 @@ body { .icon[data-icon=connection] { --icon-image: url(/images/connection.svg); } .icon[data-icon=external-link] { --icon-image: url(/images/external-link.svg); } .icon[data-icon=monitor] { --icon-image: url(/images/monitor.svg); } -.icon[data-icon=info] { --icon-image: url(/images/info.svg); } .icon[data-icon=material-down-arrow] { --icon-image: url(/images/material-down-arrow.svg); --icon-size: var(--material-arrow-dimension2) var(--material-arrow-dimension1); diff --git a/ext/images/info.svg b/ext/images/info.svg deleted file mode 100644 index 7ec09ca679..0000000000 --- a/ext/images/info.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/ext/js/pages/action-popup-main.js b/ext/js/pages/action-popup-main.js index b8e6ef446b..19ff6c4231 100644 --- a/ext/js/pages/action-popup-main.js +++ b/ext/js/pages/action-popup-main.js @@ -20,6 +20,7 @@ import {ThemeController} from '../app/theme-controller.js'; import {Application} from '../application.js'; import {getAllPermissions, hasRequiredPermissionsForOptions} from '../data/permissions-util.js'; import {HotkeyHelpController} from '../input/hotkey-help-controller.js'; +import {HotkeyUtil} from '../input/hotkey-util.js'; class DisplayController { /** @@ -32,6 +33,8 @@ class DisplayController { this._optionsFull = null; /** @type {ThemeController} */ this._themeController = new ThemeController(document.documentElement); + /** @type {HotkeyUtil} */ + this._hotkeyUtil = new HotkeyUtil(); } /** */ @@ -40,6 +43,9 @@ class DisplayController { const manifest = chrome.runtime.getManifest(); + const {platform: {os}} = await this._api.getEnvironmentInfo(); + this._hotkeyUtil.os = os; + this._showExtensionInfo(manifest); void this._setupEnvironment(); this._setupButtonEvents('.action-open-search', 'openSearchPage', chrome.runtime.getURL('/search.html'), this._onSearchClick.bind(this)); @@ -58,7 +64,6 @@ class DisplayController { '' ); this._setupButtonEvents('.action-open-settings', 'openSettingsPage', chrome.runtime.getURL(optionsPageUrl)); - this._setupButtonEvents('.action-open-permissions', null, chrome.runtime.getURL('/permissions.html')); const {profiles, profileCurrent} = optionsFull; const defaultProfile = (profileCurrent >= 0 && profileCurrent < profiles.length) ? profiles[profileCurrent] : null; @@ -81,12 +86,29 @@ class DisplayController { // Private + /** */ _updateDisplayModifierKey() { const {profiles, profileCurrent} = /** @type {import('settings').Options} */ (this._optionsFull); /** @type {NodeListOf} */ - const modifierKeys = document.querySelectorAll('em.modifier-key'); - for (let i = 0; i < modifierKeys.length; i++) { - modifierKeys[i].textContent = profiles[profileCurrent].options.scanning.inputs[0].include ? profiles[profileCurrent].options.scanning.inputs[0].include : "no key"; // Change to your desired text + const modifierKeyHint = document.querySelectorAll('.tooltip'); + + const currentModifierKey = profiles[profileCurrent].options.scanning.inputs[0].include; + + /** @type {{ [key: string]: string }} */ + const modifierKeys = {}; + for (const value of /** @type {import('input').ModifierKey[]} */ (['alt', 'ctrl', 'shift', 'meta'])) { + const name = this._hotkeyUtil.getModifierDisplayValue(value); + modifierKeys[value] = name; + } + + for (let i = 0; i < modifierKeyHint.length; i++) { + modifierKeyHint[i].textContent = currentModifierKey ? 'Hold ' : 'Hover over text to scan'; + if (currentModifierKey) { + const em = document.createElement('em'); + em.textContent = modifierKeys[currentModifierKey]; + modifierKeyHint[i].appendChild(em); + modifierKeyHint[i].appendChild(document.createTextNode(' to scan')); + } } } @@ -216,13 +238,13 @@ class DisplayController { } toggle.addEventListener('change', onToggleChanged, false); } + void this._updateDisplayModifierKey(); void this._updateDictionariesEnabledWarnings(options); void this._updatePermissionsWarnings(options); this._themeController.theme = options.general.popupTheme; this._themeController.siteOverride = true; this._themeController.updateTheme(); - this._updateDisplayModifierKey(); } /** */ @@ -247,7 +269,6 @@ class DisplayController { /** @type {NodeListOf} */ const selects = document.querySelectorAll('.profile-select'); /** @type {NodeListOf} */ - // const optionGroups = document.querySelectorAll('.profile-select-option-group'); for (let i = 0; i < Math.min(selects.length); i++) { const fragment = document.createDocumentFragment(); for (let j = 0, jj = profiles.length; j < jj; ++j) { @@ -272,11 +293,14 @@ class DisplayController { const node = /** @type {HTMLInputElement} */ (event.currentTarget); const value = Number.parseInt(node.value, 10); if (typeof value === 'number' && Number.isFinite(value) && value >= 0 && value < /** @type {import('settings').Options} */ (this._optionsFull).profiles.length) { - void this._setDefaultProfileIndex(value); - this._optionsFull.profileCurrent = value; - const defaultProfile = this._optionsFull.profiles[this._optionsFull.profileCurrent]; - if (defaultProfile !== null) { - this._setupOptions(defaultProfile); + const optionsFull = this._optionsFull; + if (optionsFull && value < optionsFull.profiles.length) { + void this._setDefaultProfileIndex(value); + optionsFull.profileCurrent = value; + const defaultProfile = optionsFull.profiles[optionsFull.profileCurrent]; + if (defaultProfile !== null) { + this._setupOptions(defaultProfile); + } } } } @@ -300,7 +324,7 @@ class DisplayController { * @param {import('settings').ProfileOptions} options */ async _updateDictionariesEnabledWarnings(options) { - const noDictionariesEnabledWarnings = /** @type {NodeListOf} */ (document.querySelectorAll('.no-dictionaries-enabled-warning')); + const tooltip = document.querySelectorAll('.tooltip'); const dictionaries = await this._api.getDictionaryInfo(); const enabledDictionaries = new Set(); @@ -317,9 +341,11 @@ class DisplayController { } } - const hasEnabledDictionary = (enabledCount > 0); - for (const node of noDictionariesEnabledWarnings) { - node.hidden = hasEnabledDictionary; + if (enabledCount === 0) { + for (let i = 0; i < tooltip.length; i++) { + tooltip[i].innerHTML = 'No dictionary enabled'; + tooltip[i].classList.add('enable-dictionary-tooltip'); + } } } @@ -330,10 +356,11 @@ class DisplayController { const permissions = await getAllPermissions(); if (hasRequiredPermissionsForOptions(permissions, options)) { return; } - const warnings = /** @type {NodeListOf} */ (document.querySelectorAll('.action-open-permissions,.permissions-required-warning')); - for (const node of warnings) { - node.hidden = false; + const tooltip = document.querySelectorAll('.tooltip'); + for (let i = 0; i < tooltip.length; i++) { + tooltip[i].innerHTML = 'Please enable permissions'; } + this._setupButtonEvents('.action-open-permissions', null, chrome.runtime.getURL('/permissions.html')); } /** @returns {Promise} */ From 18b882549e80a0d7dfc314d6de2c799464742169 Mon Sep 17 00:00:00 2001 From: martholomew Date: Thu, 31 Oct 2024 17:48:59 -0600 Subject: [PATCH 5/5] change color of warnings --- ext/css/action-popup.css | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/ext/css/action-popup.css b/ext/css/action-popup.css index a894b949a7..7f513a4244 100644 --- a/ext/css/action-popup.css +++ b/ext/css/action-popup.css @@ -471,7 +471,6 @@ h2.action-title { padding: 0; margin: 0; font-size: 1.125em; - font-weight: normal; line-height: 1.5; } @@ -482,14 +481,11 @@ h2.action-title { } .enable-dictionary-tooltip { - color: #ff0000; - font-weight: bold; - font-style: normal; + color: #f0ad4e; } .tooltip>a:link, a:visited { - color: #ff0000; - font-style: normal; + color: #f0ad4e; }