simplify/unify

This commit is contained in:
tophf 2022-03-29 14:18:41 +03:00
parent c01136c78a
commit ab940ca764
12 changed files with 42 additions and 35 deletions

View File

@ -336,7 +336,11 @@
}, },
"disableAllStyles": { "disableAllStyles": {
"message": "Turn all styles off", "message": "Turn all styles off",
"description": "Label for the checkbox that turns all enabled styles off." "description": "Label for the checkbox that turns all styles off."
},
"disableAllStylesOff": {
"message": "Styles are turned off",
"description": "Label for the checkbox that turns all styles off when it's checked."
}, },
"disableStyleLabel": { "disableStyleLabel": {
"message": "Disable", "message": "Disable",

View File

@ -271,6 +271,10 @@
<input type="checkbox" id="editor.livePreview"> <input type="checkbox" id="editor.livePreview">
<svg class="svg-icon checked"><use xlink:href="#svg-icon-checked"/></svg> <svg class="svg-icon checked"><use xlink:href="#svg-icon-checked"/></svg>
</label> </label>
<label id="disableAll-label" i18n="data-on:disableAllStyles, data-off:disableAllStylesOff">
<input id="disableAll" type="checkbox">
<svg class="svg-icon checked"><use xlink:href="#svg-icon-checked"/></svg>
</label>
<span id="preview-errors" hidden>!</span> <span id="preview-errors" hidden>!</span>
</div> </div>
</section> </section>

View File

@ -148,6 +148,7 @@ label {
margin-top: 2px; margin-top: 2px;
display: flex; display: flex;
align-items: center; align-items: center;
flex-wrap: wrap;
line-height: 16px; line-height: 16px;
} }

View File

@ -23,7 +23,7 @@
--accent-1: hsl(180, 100%, 95%); --accent-1: hsl(180, 100%, 95%);
--accent-3: hsl(180, 30%, 18%); --accent-3: hsl(180, 30%, 18%);
--input-bg: var(--c95); --input-bg: var(--c95);
--red1: hsl(0, 85%, 65%); --red1: hsl(0, 85%, 55%);
} }
textarea, textarea,
input[type=url], input[type=url],

View File

@ -308,27 +308,24 @@ summary {
position: absolute; position: absolute;
} }
.all-disabled #disableAll-label { html:not(.all-disabled) body:not(#stylus-popup) #disableAll-label:not([data-persist]) {
position: relative; display: none;
background: var(--red1); }
width: 100%; html:not(.all-disabled) #disableAll-label::before {
color: #fff; content: attr(data-on);
font-weight: bold;
} }
.all-disabled #disableAll-label::before { .all-disabled #disableAll-label::before {
position: absolute; content: attr(data-off);
content: ''; }
left: 0; .all-disabled #disableAll-label {
width: 100%; font-weight: bold;
height: 100%; color: var(--red1);
border: var(--outer-padding, 1rem) solid var(--red1);
margin: calc(-1 * var(--outer-padding, 1rem));
} }
.all-disabled #disableAll-label .svg-icon { .all-disabled #disableAll-label .svg-icon {
fill: #fff; fill: var(--red1);
} }
.all-disabled #disableAll { .all-disabled #disableAll {
border-color: #fff; border-color: var(--red1);
} }
:focus, :focus,

View File

@ -1,6 +1,7 @@
/* global $$ $ $create focusAccessibility getEventKeyName moveFocus */// dom.js /* global $$ $ $create focusAccessibility getEventKeyName moveFocus */// dom.js
/* global CHROME clamp debounce */// toolbox.js /* global CHROME clamp debounce */// toolbox.js
/* global msg */ /* global msg */
/* global prefs */
/* global t */// localization.js /* global t */// localization.js
'use strict'; 'use strict';
@ -33,6 +34,9 @@
} }
} }
} }
prefs.subscribe('disableAll', () => {
$('#disableAll-label').dataset.persist = ''; // avoids hiding if already shown
});
function changeFocusedInputOnWheel(event) { function changeFocusedInputOnWheel(event) {
const el = document.activeElement; const el = document.activeElement;

View File

@ -355,6 +355,7 @@ async function showSpinner(parent) {
} }
function toggleDataset(el, prop, state) { function toggleDataset(el, prop, state) {
if (!el) return;
const wasEnabled = el.dataset[prop] != null; // avoids mutating DOM unnecessarily const wasEnabled = el.dataset[prop] != null; // avoids mutating DOM unnecessarily
if (state) { if (state) {
if (!wasEnabled) el.dataset[prop] = ''; if (!wasEnabled) el.dataset[prop] = '';

View File

@ -154,6 +154,11 @@
<div id="header"> <div id="header">
<h1 id="manage-heading" i18n="manageHeading"></h1> <h1 id="manage-heading" i18n="manageHeading"></h1>
<label id="disableAll-label" i18n="data-on:disableAllStyles, data-off:disableAllStylesOff">
<input id="disableAll" type="checkbox">
<svg class="svg-icon checked"><use xlink:href="#svg-icon-checked"/></svg>
</label>
<div id="manage-settings"> <div id="manage-settings">
<div class="settings-column"> <div class="settings-column">
<details id="filters" data-pref="manage.filters.expanded"> <details id="filters" data-pref="manage.filters.expanded">
@ -349,11 +354,6 @@
<span><a href="https://github.com/openstyles/stylus/wiki" target="_blank" i18n="linkStylusWiki"></a></span> <span><a href="https://github.com/openstyles/stylus/wiki" target="_blank" i18n="linkStylusWiki"></a></span>
<span><a href="https://www.transifex.com/github-7/Stylus" target="_blank" i18n="linkTranslate"></a></span> <span><a href="https://www.transifex.com/github-7/Stylus" target="_blank" i18n="linkTranslate"></a></span>
</div> </div>
<label id="disableAll-label" i18n="disableAllStyles" hidden>
<input id="disableAll" type="checkbox">
<svg class="svg-icon checked"><use xlink:href="#svg-icon-checked"/></svg>
</label>
</div> </div>
</div> </div>

View File

@ -69,16 +69,13 @@ a:hover {
text-align: left; text-align: left;
} }
#disableAll-label:not([hidden]) {
display: block;
margin-top: 1rem;
}
#header h1 { #header h1 {
margin-top: 0; margin-top: 0;
margin-bottom: .3em; margin-bottom: .3em;
} }
.all-disabled h1 {
color: var(--red1);
}
#header a[href^="edit"] { #header a[href^="edit"] {
text-decoration: none; text-decoration: none;
margin-right: 8px; margin-right: 8px;

View File

@ -71,11 +71,6 @@ newUI.renderClass();
router.makeToggle('update-history', (...args) => showUpdateHistory(...args), [ router.makeToggle('update-history', (...args) => showUpdateHistory(...args), [
'/manage/updater-ui', /* global showUpdateHistory */ '/manage/updater-ui', /* global showUpdateHistory */
]); ]);
if (prefs.get('disableAll')) {
$('#disableAll-label').hidden = false;
} else {
prefs.subscribe('disableAll', () => ($('#disableAll-label').hidden = false));
}
$$('#header a[href^="http"]').forEach(a => (a.onclick = Events.external)); $$('#header a[href^="http"]').forEach(a => (a.onclick = Events.external));
window.on('pageshow', handleVisibilityChange); window.on('pageshow', handleVisibilityChange);
window.on('pagehide', handleVisibilityChange); window.on('pagehide', handleVisibilityChange);

View File

@ -192,7 +192,7 @@
</div> </div>
<div class="actions" id="main-actions"> <div class="actions" id="main-actions">
<label id="disableAll-label" i18n="disableAllStyles"> <label id="disableAll-label" i18n="data-on:disableAllStyles, data-off:disableAllStylesOff">
<input id="disableAll" type="checkbox"> <input id="disableAll" type="checkbox">
<svg class="svg-icon checked"><use xlink:href="#svg-icon-checked"/></svg> <svg class="svg-icon checked"><use xlink:href="#svg-icon-checked"/></svg>
</label> </label>

View File

@ -2,6 +2,10 @@
--inner-padding: 18px; /* checkbox + gap */ --inner-padding: 18px; /* checkbox + gap */
--outer-padding: 9px; --outer-padding: 9px;
--hotkey-margin: 16px; --hotkey-margin: 16px;
--red1: hsl(0, 70%, 45%);
}
[data-ui-theme="dark"] {
--red1: hsl(0, 85%, 65%);
} }
html, body { html, body {
@ -36,7 +40,7 @@ body:not(.blocked) .if-blocked,
z-index: 4; z-index: 4;
} }
#main-actions > * { #main-actions > * {
margin-top: var(--outer-padding); margin-top: .75em;
padding-left: var(--inner-padding); padding-left: var(--inner-padding);
display: block; display: block;
} }