From e3b461a9e8c7256fd2d1e508cb3e38d5bdf74a11 Mon Sep 17 00:00:00 2001
From: tophf
Date: Wed, 5 Apr 2017 16:14:59 +0300
Subject: [PATCH] manage: add new UI option
* align svg icons to pixel grid
* globalize enforceInputRange() and use it in manage
* 1 installed.onclick instead of 1000+ local ones
---
.eslintrc | 3 +
_locales/en/messages.json | 16 +++
manage.css | 198 +++++++++++++++++++++++++++-
manage.html | 67 +++++++++-
manage.js | 262 +++++++++++++++++++++++++++-----------
msgbox/msgbox.css | 7 +-
options/index.js | 15 +--
storage.js | 22 +++-
8 files changed, 489 insertions(+), 101 deletions(-)
diff --git a/.eslintrc b/.eslintrc
index d02a8b8c..1d17b783 100644
--- a/.eslintrc
+++ b/.eslintrc
@@ -57,7 +57,10 @@ globals:
isCheckbox: false
runTryCatch: false
tryRegExp: false
+ tryJSONparse: false
+ debounce: false
setupLivePrefs: false
+ enforceInputRange: false
getCodeMirrorThemes: false
styleSectionsEqual: false
diff --git a/_locales/en/messages.json b/_locales/en/messages.json
index e13a9670..c2ec7d38 100644
--- a/_locales/en/messages.json
+++ b/_locales/en/messages.json
@@ -282,6 +282,18 @@
"message": "Only edited styles",
"description": "Checkbox to show only locally edited styles"
},
+ "manageNewUI": {
+ "message": "New manage UI layout",
+ "description": "Label for the checkbox that toggles the new UI on manage page"
+ },
+ "manageFavicons": {
+ "message": "Favicons in applies-to column",
+ "description": "Label for the checkbox that toggles applies-to favicons in the new UI on manage page"
+ },
+ "manageMaxTargets": {
+ "message": "Number of applies-to items",
+ "description": "Label for the numeric input box to limit max number of applies-to targets in the new UI on manage page"
+ },
"manageText": {
"message": "Get styles on userstyles.org | Get help",
"description": "Help text on the manage page"
@@ -482,6 +494,10 @@
"message": "(Stylus can't affect this page.)",
"description": "Note in the toolbar pop-up when on a URL Stylus can't affect"
},
+ "toggleStyle": {
+ "message": "Toggle style",
+ "description": "Label for the checkbox to enable/disable a style"
+ },
"undo": {
"message": "Undo",
"description": "Button label"
diff --git a/manage.css b/manage.css
index f660abe9..1a9bbe36 100644
--- a/manage.css
+++ b/manage.css
@@ -47,10 +47,9 @@ a:hover {
.svg-icon {
cursor: pointer;
vertical-align: middle;
- margin-top: -4px;
transition: fill .5s;
- width: 16px;
- height: 16px;
+ width: 20px;
+ height: 20px;
fill: #000;
}
@@ -58,11 +57,21 @@ a:hover {
fill: #666;
}
+.svg-icon.delete {
+ width: 16px;
+ height: 16px;
+}
+
.homepage {
margin-left: 0.1em;
margin-right: 0.1em;
}
+.homepage .svg-icon {
+ margin-top: -4px;
+ margin-left: .5ex;
+}
+
.style-name {
margin-top: .25em;
word-break: break-word;
@@ -101,7 +110,7 @@ a:hover {
margin-right: .25rem;
}
-.applies-to > :first-child {
+.applies-to label {
margin-right: .5ex;
}
@@ -109,8 +118,9 @@ a:hover {
background-color: rgba(128, 128, 128, .15);
}
-.applies-to-extra {
+.applies-to-extra:not([open]) {
display: inline;
+ margin-left: 1ex;
}
summary {
@@ -142,6 +152,175 @@ summary {
display: none;
}
+/* compact layout */
+
+.newUI {
+ display: table;
+ margin: .75rem 0 .75rem 0;
+}
+
+.newUI .disabled {
+ opacity: 1;
+}
+
+.newUI .disabled .style-name,
+.newUI .disabled .applies-to {
+ opacity: .5;
+}
+
+.newUI .entry {
+ display: table-row;
+}
+
+.newUI .entry:nth-child(2n) {
+ background-color: rgba(128, 128, 128, 0.05);
+}
+
+.newUI .entry > * {
+ padding: .9rem 0 1rem;
+ margin: 0;
+ display: table-cell;
+ vertical-align: middle;
+}
+
+.newUI .checker {
+ position: relative;
+ top: 1px;
+ margin-right: 1ex;
+}
+
+.newUI .style-name {
+ font-size: 14px;
+ font-family: sans-serif;
+ text-indent: -2em;
+ padding-left: 3em;
+ padding-right: 30px;
+}
+
+.newUI .homepage .svg-icon {
+ position: absolute;
+ margin-top: 0;
+ margin-left: -28px;
+}
+
+.newUI .actions {
+ width: 60px;
+ height: 20px;
+ white-space: nowrap;
+ font-size: 0;
+}
+
+.newUI .actions > * {
+ margin: 0;
+}
+
+.newUI .actions .svg-icon {
+ margin-right: 8px;
+}
+
+.newUI .updater-icons > * {
+ transition: opacity 1s;
+ display: none;
+}
+
+.newUI .checking-update .check-update {
+ opacity: 0;
+ display: inline;
+ pointer-events: none;
+}
+
+.newUI .can-update .update,
+.newUI .no-update:not(.update-problem) .up-to-date,
+.newUI .no-update.update-problem .check-update,
+.newUI .update-done .updated {
+ display: inline;
+}
+
+.update-problem .check-update svg {
+ fill: darkred;
+}
+
+.newUI .applies-to {
+ padding-top: .25rem;
+ padding-bottom: .25rem;
+}
+
+.newUI .targets {
+ overflow: hidden;
+}
+
+.newUI .applies-to.expanded .targets {
+ max-height: 100vh;
+}
+
+.newUI .target {
+ display: block;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ max-width: calc(100vw - 280px - 60px - 25vw - 3rem);
+ box-sizing: border-box;
+ padding-right: 1rem;
+ line-height: 18px;
+}
+
+.newUI .applies-to .expander {
+ margin: 0;
+ cursor: pointer;
+ font-size: 3ex;
+ line-height: .5ex;
+ vertical-align: super;
+ letter-spacing: .1ex;
+}
+
+.newUI.has-favicons .target {
+ padding-left: 20px;
+}
+
+.newUI .target:hover {
+ background-color: inherit;
+}
+
+.newUI .target img {
+ width: 16px;
+ height: 16px;
+ vertical-align: sub;
+ margin-left: -20px;
+ margin-right: 4px;
+ transition: opacity .5s, filter .5s;
+ /* unprefixed since Chrome 53 */
+ -webkit-filter: grayscale(1);
+ filter: grayscale(1);
+ opacity: .25;
+ display: none;
+}
+
+.newUI.has-favicons .target img[src] {
+ display: inline;
+}
+
+.newUI .entry:hover .target img {
+ opacity: 1;
+ /* unprefixed since Chrome 53 */
+ -webkit-filter: grayscale(0);
+ filter: grayscale(0);
+}
+
+#newUIoptions label {
+ display: flex;
+ align-items: center;
+ margin-bottom: auto;
+}
+
+#newUIoptions input[type="number"] {
+ width: 3em;
+ margin-right: .5em;
+}
+
+input[id^="manage.newUI"] {
+ margin-left: 0;
+}
+
/* Default, no update buttons */
.update,
.check-update {
@@ -285,6 +464,15 @@ fieldset {
}
}
+@keyframes fadein-25pct {
+ from {
+ opacity: 0;
+ }
+ to {
+ opacity: .25;
+ }
+}
+
@media (max-width: 675px) {
#header {
height: auto;
diff --git a/manage.html b/manage.html
index a5c055a3..36ebeda0 100644
--- a/manage.html
+++ b/manage.html
@@ -6,10 +6,12 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -46,6 +68,10 @@
+
+ ...
+
+
@@ -85,6 +111,11 @@
-