1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-11-07 03:12:33 +01:00

Fine tune material design-based checkbox code

Summary:
- Make checkbox nodes self-contained
  (a > b) instead of (a + b)
- Revisit logger to use new checkboxes
This commit is contained in:
Raymond Hill 2020-04-26 08:44:00 -04:00
parent fefc7e21b2
commit 8ed60af0f9
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2
6 changed files with 66 additions and 46 deletions

View File

@ -24,10 +24,10 @@
</div> </div>
<div> <div>
<div class="li"><label><input type="checkbox" id="autoUpdate"><span class="checkbox"><svg><use href="img/material-design.svg#checkmark" /></svg></span><span data-i18n="3pAutoUpdatePrompt1"></span></label></div> <div class="li"><label><span class="input checkbox"><input type="checkbox" id="autoUpdate"><svg><use href="img/material-design.svg#checkmark" /></svg></span><span data-i18n="3pAutoUpdatePrompt1"></span></label></div>
<div class="li"><label><input type="checkbox" id="parseCosmeticFilters"><span class="checkbox"><svg><use href="img/material-design.svg#checkmark" /></svg></span><span><span data-i18n="3pParseAllABPHideFiltersPrompt1"></span>&nbsp;<span class="fa-icon info" data-i18n-title="3pParseAllABPHideFiltersInfo">question-circle</span></span></label> <div class="li"><label><span class="input checkbox"><input type="checkbox" id="parseCosmeticFilters"><svg><use href="img/material-design.svg#checkmark" /></svg></span><span><span data-i18n="3pParseAllABPHideFiltersPrompt1"></span>&nbsp;<span class="fa-icon info" data-i18n-title="3pParseAllABPHideFiltersInfo">question-circle</span></span></label>
</div> </div>
<div class="li"><label><input type="checkbox" id="ignoreGenericCosmeticFilters"><span class="checkbox"><svg><use href="img/material-design.svg#checkmark" /></svg></span><span><span data-i18n="3pIgnoreGenericCosmeticFilters"></span>&nbsp;<span class="fa-icon info" data-i18n-title="3pIgnoreGenericCosmeticFiltersInfo">question-circle</span></span></label> <div class="li"><label><span class="input checkbox"><input type="checkbox" id="ignoreGenericCosmeticFilters"><svg><use href="img/material-design.svg#checkmark" /></svg></span><span><span data-i18n="3pIgnoreGenericCosmeticFilters"></span>&nbsp;<span class="fa-icon info" data-i18n-title="3pIgnoreGenericCosmeticFiltersInfo">question-circle</span></span></label>
</div> </div>
</div> </div>
@ -45,7 +45,7 @@
<div class="listEntries"></div> <div class="listEntries"></div>
</div> </div>
<div class="li listEntry"> <div class="li listEntry">
<label><input type="checkbox"><span class="checkbox"><svg><use href="img/material-design.svg#checkmark" /></svg></span><span><span class="listname forinput"></span> <span class="iconbar"><!-- <label><span class="input checkbox"><input type="checkbox"><svg><use href="img/material-design.svg#checkmark" /></svg></span><span><span class="listname forinput"></span> <span class="iconbar"><!--
--><a class="fa-icon content" href="#" type="text/plain" target="_blank" data-i18n-title="3pViewContent">eye-open</a><!-- --><a class="fa-icon content" href="#" type="text/plain" target="_blank" data-i18n-title="3pViewContent">eye-open</a><!--
--><a class="fa-icon support" href="#" target="_blank">home</a><!-- --><a class="fa-icon support" href="#" target="_blank">home</a><!--
--><span class="fa-icon remove">trash-o</span><!-- --><span class="fa-icon remove">trash-o</span><!--

View File

@ -68,7 +68,6 @@ body.hideUnused #listsOfBlockedHostsPrompt::before,
.listEntry .listname { .listEntry .listname {
white-space: nowrap; white-space: nowrap;
} }
.listEntry.toRemove input[type="checkbox"],
.listEntry.toRemove .checkbox { .listEntry.toRemove .checkbox {
visibility: hidden; visibility: hidden;
} }

View File

@ -143,38 +143,43 @@ label {
Firefox Preview design guidelines. Firefox Preview design guidelines.
- To have a single checkbox design across all platforms. - To have a single checkbox design across all platforms.
*/ */
input[type="checkbox"]:not(.native) { .checkbox {
--margin-end: calc(var(--font-size) * 0.75); --margin-end: calc(var(--font-size) * 0.75);
box-sizing: border-box;
display: inline-flex;
height: var(--checkbox-size); height: var(--checkbox-size);
margin: 0; margin: 0;
margin-inline-end: var(--margin-end); margin-inline-end: var(--margin-end);
-webkit-margin-end: var(--margin-end); -webkit-margin-end: var(--margin-end);
min-width: var(--checkbox-size); position: relative;
opacity: 0;
width: var(--checkbox-size); width: var(--checkbox-size);
} }
input[type="checkbox"] + .checkbox { .checkbox > input[type="checkbox"] {
box-sizing: border-box;
height: 100%;
margin: 0;
min-width: var(--checkbox-size);
opacity: 0;
position: absolute;
width: 100%;
}
.checkbox > input[type="checkbox"] + svg {
background-color: transparent; background-color: transparent;
border: 2px solid var(--checkbox-ink); border: 2px solid var(--checkbox-ink);
border-radius: 2px; border-radius: 2px;
box-sizing: border-box; box-sizing: border-box;
display: inline-flex;
height: var(--checkbox-size);
pointer-events: none;
position: absolute;
width: var(--checkbox-size);
}
input[type="checkbox"] + .checkbox > svg {
fill: none; fill: none;
height: 100%; height: 100%;
pointer-events: none;
position: absolute;
stroke: none;
stroke-width: 3.12px;
width: 100%; width: 100%;
} }
input[type="checkbox"]:checked + .checkbox { .checkbox > input[type="checkbox"]:checked + svg {
background-color: var(--checkbox-checked-ink); background-color: var(--checkbox-checked-ink);
border-color: var(--checkbox-checked-ink); border-color: var(--checkbox-checked-ink);
fill: var(--checkbox-checked-ink);
stroke: var(--default-surface); stroke: var(--default-surface);
stroke-width: 3.12px;
} }
.hidden { .hidden {

View File

@ -26,7 +26,8 @@
// This file should always be included at the end of the `body` tag, so as // This file should always be included at the end of the `body` tag, so as
// to ensure all i18n targets are already loaded. // to ensure all i18n targets are already loaded.
(function() { {
// >>>>> start of local scope
/******************************************************************************/ /******************************************************************************/
@ -187,8 +188,22 @@ vAPI.i18n.render = function(context) {
if ( pos !== -1 ) { if ( pos !== -1 ) {
part = part.slice(0, pos) + part.slice(-2); part = part.slice(0, pos) + part.slice(-2);
} }
const node = elem.querySelector(part.slice(2, -2)); const selector = part.slice(2, -2);
if ( node !== null ) { let node;
// Ideally, the i18n strings explicitly refer to the
// class of the element to insert. However for now we
// will create a class from what is currently found in
// the placeholder and first try to lookup the resulting
// selector. This way we don't have to revisit all
// translations just for the sake of declaring the proper
// selector in the placeholder field.
if ( selector.charCodeAt(0) !== 0x2E /* '.' */ ) {
node = elem.querySelector(`.${selector}`);
}
if ( node instanceof Element === false ) {
node = elem.querySelector(selector);
}
if ( node instanceof Element ) {
safeTextToDOM(textBefore, fragment); safeTextToDOM(textBefore, fragment);
fragment.appendChild(node); fragment.appendChild(node);
textBefore = ''; textBefore = '';
@ -255,6 +270,7 @@ vAPI.i18n.renderElapsedTimeToString = function(tstamp) {
/******************************************************************************/ /******************************************************************************/
})(); // <<<<< end of local scope
}
/******************************************************************************/ /******************************************************************************/

View File

@ -187,20 +187,20 @@
<div id="loggerSettingsDialog"> <div id="loggerSettingsDialog">
<div><span data-i18n="loggerSettingDiscardPrompt"></span> <div><span data-i18n="loggerSettingDiscardPrompt"></span>
<ul> <ul>
<li><label data-i18n="loggerSettingPerEntryMaxAge"><input type="number" min="0" max="50000" /></label> <li><label><span data-i18n="loggerSettingPerEntryMaxAge"><input type="number" min="0" max="50000" step="15" /></span></label>
<li><label data-i18n="loggerSettingPerTabMaxLoads"><input type="number" min="0" max="1000000" /></label> <li><label><span data-i18n="loggerSettingPerTabMaxLoads"><input type="number" min="0" max="1000000" /></span></label>
<li><label data-i18n="loggerSettingPerTabMaxEntries"><input type="number" min="0" max="1000000" /></label> <li><label><span data-i18n="loggerSettingPerTabMaxEntries"><input type="number" min="0" max="1000000" step="100" /></span></label>
</ul> </ul>
</div> </div>
<div><span data-i18n="loggerSettingHideColumnsPrompt"></span> <div><span data-i18n="loggerSettingHideColumnsPrompt"></span>
<ul> <ul>
<li><label data-i18n="loggerSettingHideColumnTime"><input type="checkbox" class="native" data-column="0" /></label> <li><label data-i18n="loggerSettingHideColumnTime"><span class="input checkbox"><input type="checkbox" data-column="0" /><svg><use href="img/material-design.svg#checkmark" /></svg></span></label>
<li><label data-i18n="loggerSettingHideColumnFilter"><input type="checkbox" class="native" data-column="1" /></label> <li><label data-i18n="loggerSettingHideColumnFilter"><span class="input checkbox"><input type="checkbox" data-column="1" /><svg><use href="img/material-design.svg#checkmark" /></svg></span></label>
<li><label data-i18n="loggerSettingHideColumnContext"><input type="checkbox" class="native" data-column="3" /></label> <li><label data-i18n="loggerSettingHideColumnContext"><span class="input checkbox"><input type="checkbox" data-column="3" /><svg><use href="img/material-design.svg#checkmark" /></svg></span></label>
<li><label data-i18n="loggerSettingHideColumnPartyness"><input type="checkbox" class="native" data-column="4" /></label> <li><label data-i18n="loggerSettingHideColumnPartyness"><span class="input checkbox"><input type="checkbox" data-column="4" /><svg><use href="img/material-design.svg#checkmark" /></svg></span></label>
</ul> </ul>
</div> </div>
<div><label data-i18n="loggerSettingPerEntryLineCount"><input type="number" min="2" max="6"></label></div> <div><label><span data-i18n="loggerSettingPerEntryLineCount"><input type="number" min="2" max="6"></span></label></div>
</div> </div>
</div> </div>

View File

@ -13,30 +13,30 @@
<body> <body>
<div class="fieldset"> <div class="fieldset">
<div class="li"><label><input type="checkbox" data-setting-name="collapseBlocked" data-setting-type="bool"><span class="checkbox"><svg><use href="img/material-design.svg#checkmark" /></svg></span><span data-i18n="settingsCollapseBlockedPrompt"></span></label></div> <div class="li"><label><span class="input checkbox"><input type="checkbox" data-setting-name="collapseBlocked" data-setting-type="bool"><svg><use href="img/material-design.svg#checkmark" /></svg></span><span data-i18n="settingsCollapseBlockedPrompt"></span></label></div>
<div class="li"><label><input type="checkbox" data-setting-name="showIconBadge" data-setting-type="bool"><span class="checkbox"><svg><use href="img/material-design.svg#checkmark" /></svg></span><span data-i18n="settingsIconBadgePrompt"></span></label></div> <div class="li"><label><span class="input checkbox"><input type="checkbox" data-setting-name="showIconBadge" data-setting-type="bool"><svg><use href="img/material-design.svg#checkmark" /></svg></span><span data-i18n="settingsIconBadgePrompt"></span></label></div>
<div class="li"><label><input type="checkbox" data-setting-name="contextMenuEnabled" data-setting-type="bool"><span class="checkbox"><svg><use href="img/material-design.svg#checkmark" /></svg></span><span data-i18n="settingsContextMenuPrompt"></span></label></div> <div class="li"><label><span class="input checkbox"><input type="checkbox" data-setting-name="contextMenuEnabled" data-setting-type="bool"><svg><use href="img/material-design.svg#checkmark" /></svg></span><span data-i18n="settingsContextMenuPrompt"></span></label></div>
<div class="li"><label><input type="checkbox" data-setting-name="tooltipsDisabled" data-setting-type="bool"><span class="checkbox"><svg><use href="img/material-design.svg#checkmark" /></svg></span><span data-i18n="settingsTooltipsPrompt"></span></label></div> <div class="li"><label><span class="input checkbox"><input type="checkbox" data-setting-name="tooltipsDisabled" data-setting-type="bool"><svg><use href="img/material-design.svg#checkmark" /></svg></span><span data-i18n="settingsTooltipsPrompt"></span></label></div>
<div class="li"><label><input type="checkbox" data-setting-name="colorBlindFriendly" data-setting-type="bool"><span class="checkbox"><svg><use href="img/material-design.svg#checkmark" /></svg></span><span data-i18n="settingsColorBlindPrompt"></span></label></div> <div class="li"><label><span class="input checkbox"><input type="checkbox" data-setting-name="colorBlindFriendly" data-setting-type="bool"><svg><use href="img/material-design.svg#checkmark" /></svg></span><span data-i18n="settingsColorBlindPrompt"></span></label></div>
<div class="li"><label><input type="checkbox" data-setting-name="cloudStorageEnabled" data-setting-type="bool"><span class="checkbox"><svg><use href="img/material-design.svg#checkmark" /></svg></span><span><span data-i18n="settingsCloudStorageEnabledPrompt"></span>&nbsp;<a class="fa-icon info" href="https://github.com/gorhill/uBlock/wiki/Cloud-storage" target="_blank">info-circle</a></span></label></div> <div class="li"><label><span class="input checkbox"><input type="checkbox" data-setting-name="cloudStorageEnabled" data-setting-type="bool"><svg><use href="img/material-design.svg#checkmark" /></svg></span><span><span data-i18n="settingsCloudStorageEnabledPrompt"></span>&nbsp;<a class="fa-icon info" href="https://github.com/gorhill/uBlock/wiki/Cloud-storage" target="_blank">info-circle</a></span></label></div>
<div class="li"><label><input type="checkbox" data-setting-name="advancedUserEnabled" data-setting-type="bool"><span class="checkbox"><svg><use href="img/material-design.svg#checkmark" /></svg></span><span><span data-i18n="settingsAdvancedUserPrompt"></span>&nbsp;<a class="fa-icon info" href="advanced-settings.html" data-i18n-title="settingsAdvancedUserSettings">cogs</a></span></label></div> <div class="li"><label><span class="input checkbox"><input type="checkbox" data-setting-name="advancedUserEnabled" data-setting-type="bool"><svg><use href="img/material-design.svg#checkmark" /></svg></span><span><span data-i18n="settingsAdvancedUserPrompt"></span>&nbsp;<a class="fa-icon info" href="advanced-settings.html" data-i18n-title="settingsAdvancedUserSettings">cogs</a></span></label></div>
</div> </div>
<hr> <hr>
<div class="fieldset"> <div class="fieldset">
<div class="fieldset-header" data-i18n="3pGroupPrivacy"></div> <div class="fieldset-header" data-i18n="3pGroupPrivacy"></div>
<div class="li"><label><input type="checkbox" data-setting-name="prefetchingDisabled" data-setting-type="bool"><span class="checkbox"><svg><use href="img/material-design.svg#checkmark" /></svg></span><span><span data-i18n="settingsPrefetchingDisabledPrompt"></span>&nbsp;<a class="fa-icon info" href="https://github.com/gorhill/uBlock/wiki/Dashboard:-Settings#disable-pre-fetching" target="_blank">info-circle</a></span></label></div> <div class="li"><label><span class="input checkbox"><input type="checkbox" data-setting-name="prefetchingDisabled" data-setting-type="bool"><svg><use href="img/material-design.svg#checkmark" /></svg></span><span><span data-i18n="settingsPrefetchingDisabledPrompt"></span>&nbsp;<a class="fa-icon info" href="https://github.com/gorhill/uBlock/wiki/Dashboard:-Settings#disable-pre-fetching" target="_blank">info-circle</a></span></label></div>
<div class="li"><label><input type="checkbox" data-setting-name="hyperlinkAuditingDisabled" data-setting-type="bool"><span class="checkbox"><svg><use href="img/material-design.svg#checkmark" /></svg></span><span><span data-i18n="settingsHyperlinkAuditingDisabledPrompt"></span>&nbsp;<a class="fa-icon info important" href="https://github.com/gorhill/uBlock/wiki/Dashboard:-Settings#disable-hyperlink-auditing" target="_blank">info-circle</a></span></label></div> <div class="li"><label><span class="input checkbox"><input type="checkbox" data-setting-name="hyperlinkAuditingDisabled" data-setting-type="bool"><svg><use href="img/material-design.svg#checkmark" /></svg></span><span><span data-i18n="settingsHyperlinkAuditingDisabledPrompt"></span>&nbsp;<a class="fa-icon info important" href="https://github.com/gorhill/uBlock/wiki/Dashboard:-Settings#disable-hyperlink-auditing" target="_blank">info-circle</a></span></label></div>
<div class="li"><label><input type="checkbox" data-setting-name="webrtcIPAddressHidden" data-setting-type="bool"><span class="checkbox"><svg><use href="img/material-design.svg#checkmark" /></svg></span><span><span data-i18n="settingsWebRTCIPAddressHiddenPrompt"></span>&nbsp;<a class="fa-icon info important" href="https://github.com/gorhill/uBlock/wiki/Prevent-WebRTC-from-leaking-local-IP-address" target="_blank">info-circle</a></span></label></div> <div class="li"><label><span class="input checkbox"><input type="checkbox" data-setting-name="webrtcIPAddressHidden" data-setting-type="bool"><svg><use href="img/material-design.svg#checkmark" /></svg></span><span><span data-i18n="settingsWebRTCIPAddressHiddenPrompt"></span>&nbsp;<a class="fa-icon info important" href="https://github.com/gorhill/uBlock/wiki/Prevent-WebRTC-from-leaking-local-IP-address" target="_blank">info-circle</a></span></label></div>
<div class="li"><label><input type="checkbox" data-setting-name="noCSPReports" data-setting-type="bool"><span class="checkbox"><svg><use href="img/material-design.svg#checkmark" /></svg></span><span><span data-i18n="settingsNoCSPReportsPrompt"></span>&nbsp;<a class="fa-icon info" href="https://github.com/gorhill/uBlock/wiki/Dashboard:-Settings#block-csp-reports" target="_blank">info-circle</a></span></label></div> <div class="li"><label><span class="input checkbox"><input type="checkbox" data-setting-name="noCSPReports" data-setting-type="bool"><svg><use href="img/material-design.svg#checkmark" /></svg></span><span><span data-i18n="settingsNoCSPReportsPrompt"></span>&nbsp;<a class="fa-icon info" href="https://github.com/gorhill/uBlock/wiki/Dashboard:-Settings#block-csp-reports" target="_blank">info-circle</a></span></label></div>
</div> </div>
<hr> <hr>
<div class="fieldset"> <div class="fieldset">
<div class="fieldset-header" data-i18n="settingPerSiteSwitchGroup"></div> <div class="fieldset-header" data-i18n="settingPerSiteSwitchGroup"></div>
<div class="li synopsis"><legend><span data-i18n="settingPerSiteSwitchGroupSynopsis"></span>&nbsp;<a class="fa-icon info" href="https://github.com/gorhill/uBlock/wiki/Per-site-switches" target="_blank">info-circle</a></legend></div> <div class="li synopsis"><legend><span data-i18n="settingPerSiteSwitchGroupSynopsis"></span>&nbsp;<a class="fa-icon info" href="https://github.com/gorhill/uBlock/wiki/Per-site-switches" target="_blank">info-circle</a></legend></div>
<div class="li"><label><input type="checkbox" data-setting-name="noCosmeticFiltering" data-setting-type="bool"><span class="checkbox"><svg><use href="img/material-design.svg#checkmark" /></svg></span><span><span data-i18n="settingsNoCosmeticFilteringPrompt"></span>&nbsp;<a class="fa-icon info" href="https://github.com/gorhill/uBlock/wiki/Per-site-switches#no-cosmetic-filtering" target="_blank">info-circle</a></span></label></div> <div class="li"><label><span class="input checkbox"><input type="checkbox" data-setting-name="noCosmeticFiltering" data-setting-type="bool"><svg><use href="img/material-design.svg#checkmark" /></svg></span><span><span data-i18n="settingsNoCosmeticFilteringPrompt"></span>&nbsp;<a class="fa-icon info" href="https://github.com/gorhill/uBlock/wiki/Per-site-switches#no-cosmetic-filtering" target="_blank">info-circle</a></span></label></div>
<div class="li"><label><input type="checkbox" data-setting-name="noLargeMedia" data-setting-type="bool"><span class="checkbox"><svg><use href="img/material-design.svg#checkmark" /></svg></span><span><span data-i18n="settingsNoLargeMediaPrompt"><input type="number" min="0"></span>&nbsp;<a class="fa-icon info" href="https://github.com/gorhill/uBlock/wiki/Per-site-switches#no-large-media-elements" target="_blank">info-circle</a></span></label></div> <div class="li"><label><span class="input checkbox"><input type="checkbox" data-setting-name="noLargeMedia" data-setting-type="bool"><svg><use href="img/material-design.svg#checkmark" /></svg></span><span><span data-i18n="settingsNoLargeMediaPrompt"><input type="number" min="0"></span>&nbsp;<a class="fa-icon info" href="https://github.com/gorhill/uBlock/wiki/Per-site-switches#no-large-media-elements" target="_blank">info-circle</a></span></label></div>
<div class="li"><label><input type="checkbox" data-setting-name="noRemoteFonts" data-setting-type="bool"><span class="checkbox"><svg><use href="img/material-design.svg#checkmark" /></svg></span><span><span data-i18n="settingsNoRemoteFontsPrompt"></span>&nbsp;<a class="fa-icon info" href="https://github.com/gorhill/uBlock/wiki/Per-site-switches#no-remote-fonts" target="_blank">info-circle</a></span></label></div> <div class="li"><label><span class="input checkbox"><input type="checkbox" data-setting-name="noRemoteFonts" data-setting-type="bool"><svg><use href="img/material-design.svg#checkmark" /></svg></span><span><span data-i18n="settingsNoRemoteFontsPrompt"></span>&nbsp;<a class="fa-icon info" href="https://github.com/gorhill/uBlock/wiki/Per-site-switches#no-remote-fonts" target="_blank">info-circle</a></span></label></div>
<div class="li"><label><input type="checkbox" data-setting-name="noScripting" data-setting-type="bool"><span class="checkbox"><svg><use href="img/material-design.svg#checkmark" /></svg></span><span><span data-i18n="settingsNoScriptingPrompt"></span>&nbsp;<a class="fa-icon info" href="https://github.com/gorhill/uBlock/wiki/Per-site-switches#no-scripting" target="_blank">info-circle</a></span></label></div> <div class="li"><label><span class="input checkbox"><input type="checkbox" data-setting-name="noScripting" data-setting-type="bool"><svg><use href="img/material-design.svg#checkmark" /></svg></span><span><span data-i18n="settingsNoScriptingPrompt"></span>&nbsp;<a class="fa-icon info" href="https://github.com/gorhill/uBlock/wiki/Per-site-switches#no-scripting" target="_blank">info-circle</a></span></label></div>
</div> </div>
<hr> <hr>
<div id="localData" class="fieldset"> <div id="localData" class="fieldset">