From e7149e23bf9bc59e34ef146065409e5160cd66e0 Mon Sep 17 00:00:00 2001 From: Anna Bocharova Date: Fri, 11 Aug 2023 17:09:43 +0200 Subject: [PATCH] UI/UX Improvements (#167) * Monospace font for OS commands. * Going with FontAwesome terminal icon. * No 'OS' since we have icon, labeling 'ON' and 'OFF' for commands. * Labeling OFF for confirmation setting. * Prefexing GPIO input with BCM helper. * Moving and scaling icon previews. * Captions for previews. * Minor: shorter label. * Better preview caption appearance. * Adding help icon opening pins enumeration docs. * Reducing the help block on inverted relays. * Introducing CSS asset (not complete). * Easier CSS references and better markup. * CSS extracting complete. * Better info icons. * Ref: extracting css class bindings into 'let' ones. * Slightly smaller ON/OFF labels on the left side. * Updating tests. * UX: fading the tabs switching. * Updating snapshot. * Neat: icon preview border radius. * Changelog: the future 3.5.0. --- CHANGELOG.md | 7 + octoprint_octorelay/const.py | 5 +- octoprint_octorelay/static/css/octorelay.css | 63 + .../templates/octorelay_settings.jinja2 | 144 +- tests/snapshots/snap_test_templates.py | 2568 +++++++++++------ tests/test_init.py | 2 +- 6 files changed, 1802 insertions(+), 987 deletions(-) create mode 100644 octoprint_octorelay/static/css/octorelay.css diff --git a/CHANGELOG.md b/CHANGELOG.md index 4efe2408..dd96b974 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,13 @@ ## Version 3 +### 3.5.0 + +- A couple more improvements for the UI/UX. + - This version introduces a new asset — CSS file. + +![UI](https://user-images.githubusercontent.com/13189514/260043096-38e10e10-1285-401f-bf1f-18aa9e397c25.png) + ### 3.4.0 - New feature: event-based automation. diff --git a/octoprint_octorelay/const.py b/octoprint_octorelay/const.py index f9364097..eae8d022 100644 --- a/octoprint_octorelay/const.py +++ b/octoprint_octorelay/const.py @@ -260,7 +260,10 @@ def get_ui_vars(): } # Plugin's asset files to automatically include in the core UI -ASSETS = { "js": [ "js/octorelay.js" ] } +ASSETS = { + "js": [ "js/octorelay.js" ], + "css": [ "css/octorelay.css" ] +} # Public interface commands: UPDATE_COMMAND = "update" diff --git a/octoprint_octorelay/static/css/octorelay.css b/octoprint_octorelay/static/css/octorelay.css new file mode 100644 index 00000000..a7217158 --- /dev/null +++ b/octoprint_octorelay/static/css/octorelay.css @@ -0,0 +1,63 @@ +#settings_plugin_octorelay .tab-content { + position: relative +} + +#settings_plugin_octorelay .btn > input[type='radio'] { + display: none +} + +#settings_plugin_octorelay input.code { + font-family: monospace; +} + +#settings_plugin_octorelay .input-prepend > .add-on.tiny { + font-size: 0.45rem; + font-weight: 600; +} + +#settings_plugin_octorelay .help-inline a.same-color { + color: inherit; +} + +#settings_plugin_octorelay .control-label span.label { + zoom: 0.85; /* not scale */ +} + +#settings_plugin_octorelay .fa-info { + border: 2px solid currentColor; + padding: 3px 8px; + border-radius: 50%; + scale: 0.6; + transform-origin: left; +} + +#settings_plugin_octorelay .preview { + display: flex; + width: 24px; + height: 24px; + overflow: hidden; + line-height: unset; + font-size: 1.25rem; + align-items: center; + justify-content: center; + position: absolute; + top: 0; + scale: 3; + transform-origin: top left; + border: 0.3px dashed #00000066; + box-sizing: content-box; + border-radius: 2px; +} + +#settings_plugin_octorelay .preview-caption { + position: absolute; + top: 75px; + width: 75px; + display: flex; + justify-content: center; + align-items: baseline; + gap: 0.5ch; + white-space: nowrap; + scale: 0.75; + transform-origin: top; +} diff --git a/octoprint_octorelay/templates/octorelay_settings.jinja2 b/octoprint_octorelay/templates/octorelay_settings.jinja2 index 8e1b9c13..425d3fbd 100755 --- a/octoprint_octorelay/templates/octorelay_settings.jinja2 +++ b/octoprint_octorelay/templates/octorelay_settings.jinja2 @@ -17,26 +17,26 @@ {% for n in range(1,9) %}
-
{% for value, option in plugin_octorelay_boolean.items() %} -
@@ -46,6 +46,14 @@
+ {% for state, offset in {"on": 315, "off": 415}.items() %} +
+
+ {{ _(state.upper()) }} + {{ _('preview') }} +
+ {% endfor %} +
@@ -53,17 +61,44 @@
+ {% for state in ["on", "off"] %} +
+ +
+
+ + +
+
+
+ {% endfor %} +
- +
+ BCM + +
+ + + + +
@@ -72,54 +107,53 @@
{% for value, option in plugin_octorelay_boolean.items() %} -
- - {{ _('For normally closed relays: the electrical circuit is closed without applying current and the relay connects the power to the load.') }} + + {{ _('For normally closed relays') }} + + +
- {% for state in ["on", "off"] %} -
- -
- -
-
-
- {% endfor %} -
- +
{% for value, option in plugin_octorelay_boolean.items() %} -
@@ -131,16 +165,18 @@
{% for value, state in plugin_octorelay_tristate.items() %} -
@@ -154,9 +190,19 @@ {% for state in ["on", "off"] %}
- +
- +
+ + +
{% endfor %} diff --git a/tests/snapshots/snap_test_templates.py b/tests/snapshots/snap_test_templates.py index 5ebd1d50..99926bd0 100644 --- a/tests/snapshots/snap_test_templates.py +++ b/tests/snapshots/snap_test_templates.py @@ -130,38 +130,39 @@
-
-
@@ -171,6 +172,20 @@
+ +
+
+ ON + preview +
+ +
+
+ OFF + preview +
+ +
@@ -178,17 +193,61 @@
+ +
+ +
+
+ + +
+
+
+ +
+ +
+
+ + +
+
+
+ +
- +
+ BCM + +
+ + + + +
@@ -197,89 +256,79 @@
-
- - For normally closed relays: the electrical circuit is closed without applying current and the relay connects the power to the load. + + For normally closed relays + + +
- -
- -
- -
-
-
-
- -
- -
-
-
- - -
- +
-
@@ -291,38 +340,44 @@
-
@@ -338,38 +393,44 @@
-
@@ -385,38 +446,44 @@
-
@@ -430,16 +497,36 @@
- +
- +
+ + +
- +
- +
+ + +
@@ -449,38 +536,39 @@
-
-
@@ -490,6 +578,20 @@
+ +
+
+ ON + preview +
+ +
+
+ OFF + preview +
+ +
@@ -497,17 +599,61 @@
+ +
+ +
+
+ + +
+
+
+ +
+ +
+
+ + +
+
+
+ +
- +
+ BCM + +
+ + + + +
@@ -516,89 +662,79 @@
-
- - For normally closed relays: the electrical circuit is closed without applying current and the relay connects the power to the load. + + For normally closed relays + + +
- -
- -
- -
-
-
-
- -
- -
-
-
- - -
- +
-
@@ -610,38 +746,44 @@
-
@@ -657,38 +799,44 @@
-
@@ -704,38 +852,44 @@
-
@@ -749,16 +903,36 @@
- +
- +
+ + +
- +
- +
+ + +
@@ -768,38 +942,39 @@
-
-
@@ -809,6 +984,20 @@
+ +
+
+ ON + preview +
+ +
+
+ OFF + preview +
+ +
@@ -816,17 +1005,61 @@
+ +
+ +
+
+ + +
+
+
+ +
+ +
+
+ + +
+
+
+ +
- +
+ BCM + +
+ + + + +
@@ -835,89 +1068,79 @@
-
- - For normally closed relays: the electrical circuit is closed without applying current and the relay connects the power to the load. + + For normally closed relays + + +
- -
- -
- -
-
-
-
- -
- -
-
-
- - -
- +
-
@@ -929,38 +1152,44 @@
-
@@ -976,38 +1205,44 @@
-
@@ -1023,38 +1258,44 @@
-
@@ -1068,16 +1309,36 @@
- +
- +
+ + +
- +
- +
+ + +
@@ -1087,38 +1348,39 @@
-
-
@@ -1128,6 +1390,20 @@
+ +
+
+ ON + preview +
+ +
+
+ OFF + preview +
+ +
@@ -1135,17 +1411,61 @@
+ +
+ +
+
+ + +
+
+
+ +
+ +
+
+ + +
+
+
+ +
- +
+ BCM + +
+ + + + +
@@ -1154,89 +1474,79 @@
-
- - For normally closed relays: the electrical circuit is closed without applying current and the relay connects the power to the load. + + For normally closed relays + + +
- -
- -
- -
-
-
-
- -
- -
-
-
- - -
- +
-
@@ -1248,38 +1558,44 @@
-
@@ -1295,38 +1611,44 @@
-
@@ -1342,38 +1664,44 @@
-
@@ -1387,16 +1715,36 @@
- +
- +
+ + +
- +
- +
+ + +
@@ -1406,38 +1754,39 @@
-
-
@@ -1447,6 +1796,20 @@
+ +
+
+ ON + preview +
+ +
+
+ OFF + preview +
+ +
@@ -1454,17 +1817,61 @@
+ +
+ +
+
+ + +
+
+
+ +
+ +
+
+ + +
+
+
+ +
- +
+ BCM + +
+ + + + +
@@ -1473,89 +1880,79 @@
-
- - For normally closed relays: the electrical circuit is closed without applying current and the relay connects the power to the load. + + For normally closed relays + + +
- -
- -
- -
-
-
-
- -
- -
-
-
- - -
- +
-
@@ -1567,38 +1964,44 @@
-
@@ -1614,38 +2017,44 @@
-
@@ -1661,38 +2070,44 @@
-
@@ -1706,16 +2121,36 @@
- +
- +
+ + +
- +
- +
+ + +
@@ -1725,38 +2160,39 @@
-
-
@@ -1766,6 +2202,20 @@
+ +
+
+ ON + preview +
+ +
+
+ OFF + preview +
+ +
@@ -1773,17 +2223,61 @@
+ +
+ +
+
+ + +
+
+
+ +
+ +
+
+ + +
+
+
+ +
- +
+ BCM + +
+ + + + +
@@ -1792,89 +2286,79 @@
-
- - For normally closed relays: the electrical circuit is closed without applying current and the relay connects the power to the load. + + For normally closed relays + + +
- -
- -
- -
-
-
-
- -
- -
-
-
- - -
- +
-
@@ -1886,38 +2370,44 @@
-
@@ -1933,38 +2423,44 @@
-
@@ -1980,38 +2476,44 @@
-
@@ -2025,16 +2527,36 @@
- +
- +
+ + +
- +
- +
+ + +
@@ -2044,38 +2566,39 @@
-
-
@@ -2085,6 +2608,20 @@
+ +
+
+ ON + preview +
+ +
+
+ OFF + preview +
+ +
@@ -2092,17 +2629,61 @@
+ +
+ +
+
+ + +
+
+
+ +
+ +
+
+ + +
+
+
+ +
- +
+ BCM + +
+ + + + +
@@ -2111,89 +2692,79 @@
-
- - For normally closed relays: the electrical circuit is closed without applying current and the relay connects the power to the load. + + For normally closed relays + + +
- -
- -
- -
-
-
-
- -
- -
-
-
- - -
- +
-
@@ -2205,38 +2776,44 @@
-
@@ -2252,38 +2829,44 @@
-
@@ -2299,38 +2882,44 @@
-
@@ -2344,16 +2933,36 @@
- +
- +
+ + +
- +
- +
+ + +
@@ -2363,38 +2972,39 @@
-
-
@@ -2404,6 +3014,20 @@
+ +
+
+ ON + preview +
+ +
+
+ OFF + preview +
+ +
@@ -2411,17 +3035,61 @@
+ +
+ +
+
+ + +
+
+
+ +
+ +
+
+ + +
+
+
+ +
- +
+ BCM + +
+ + + + +
@@ -2430,89 +3098,79 @@
-
- - For normally closed relays: the electrical circuit is closed without applying current and the relay connects the power to the load. + + For normally closed relays + + +
- -
- -
- -
-
-
-
- -
- -
-
-
- - -
- +
-
@@ -2524,38 +3182,44 @@
-
@@ -2571,38 +3235,44 @@
-
@@ -2618,38 +3288,44 @@
-
@@ -2663,16 +3339,36 @@
- +
- +
+ + +
- +
- +
+ + +
diff --git a/tests/test_init.py b/tests/test_init.py index 731cf1ec..4130b184 100644 --- a/tests/test_init.py +++ b/tests/test_init.py @@ -337,7 +337,7 @@ def test_get_template_configs__immutable(self): def test_get_assets(self): # Should return the plugin assets configutation - expected = { "js": [ "js/octorelay.js" ] } + expected = { "js": [ "js/octorelay.js" ], "css": [ "css/octorelay.css" ] } actual = self.plugin_instance.get_assets() self.assertEqual(actual, expected)