Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Canvas layout: Add interactive SVG support #2787

Merged
merged 31 commits into from
Nov 9, 2024

Conversation

stefan-hoehn
Copy link
Contributor

@stefan-hoehn stefan-hoehn commented Oct 2, 2024

This is major contribution to the fixed canvas layout which allows an SVG background to become an active part of the page. Through this feature the SVG itself can become an active component of the page.

Thanks to @florian-h05 for the intensive collaboration on this new feature.

See documentation here: openhab/openhab-docs#2398

It allows real embedding of an SVG if used as the background URL to become interactive:

image
  • Embed SVG = ON: Loads the SVG into the HTML DOM, so the elements are available for the openHAB page.
  • Embed SVG Flashing in Run-Mode in Run-Mode

image

Here is an example of a floorplan that has been implemented without any widget (note that widgets are still supported and are still recommended to be used) by showing some of the features:

image
embedded-svg.mov
  • The violet "led strip" can directly be clicked to turn on and off the light

  • The SVG element that represents that strip changes its color based on the real color of the light strip

  • The blue bar is a window whose rollershutter is partially closed. The blue color changes its transparency based on the opening percentage of the rollershutter (it becomes completely gray like the wall when the rollershutter is closed)

image
  • All other elements in the picture are completely contained in the SVG (some of which could have also been done via a widget but they serve as an example of the possible features.

  • State information can be directly written into an SVG-Element like the temperature here

image
  • Different representations can be achieved by enabling / disabling parts of the element like the bulb here:

OFF / ON (glow around the bulb, which could be even animated within the SVG)

image image

  • Style changes can be trigged based on an ON/STATE. Even animations that are contained in the SVG can be triggered via dynamic style changes manipulating the SVG like the following slider button that has been implemented within the SVG or the blinking astronaut on the right in the video. This allows endless ideas (e.g. energy flow within a house)

  • SVG that should become active elements for openHAB are marked with an "openhab" attribute (in the SVG editor). These will the be detected in the openHAB editor and made available for configuration:

flash.mov

and by clicking on it the element can be configured similarly like a widget:

config.mov

Keep in mind: it is not a replacement for widgets ... widgets can and should still be used but it allows the background itself to be as interactive as a widget.

PS: A comprehensive documentation will come soon

Copy link

relativeci bot commented Oct 2, 2024

#2469 Bundle Size — 10.87MiB (+0.1%).

4ac0310(current) vs 1e4e69e main#2465(baseline)

Warning

Bundle contains 2 duplicate packages – View duplicate packages

Bundle metrics  Change 3 changes Regression 1 regression
                 Current
#2469
     Baseline
#2465
Regression  Initial JS 1.91MiB(+0.56%) 1.9MiB
No change  Initial CSS 577.31KiB 577.31KiB
Change  Cache Invalidation 22.9% 17.47%
No change  Chunks 226 226
No change  Assets 249 249
Change  Modules 2940(+0.03%) 2939
No change  Duplicate Modules 152 152
No change  Duplicate Code 1.8% 1.8%
No change  Packages 96 96
No change  Duplicate Packages 2 2
Bundle size by type  Change 1 change Regression 1 regression
                 Current
#2469
     Baseline
#2465
Regression  JS 9.08MiB (+0.12%) 9.07MiB
No change  CSS 864KiB 864KiB
No change  Fonts 526.1KiB 526.1KiB
No change  Media 295.6KiB 295.6KiB
No change  IMG 140.74KiB 140.74KiB
No change  HTML 1.38KiB 1.38KiB
No change  Other 871B 871B

Bundle analysis reportBranch stefan-hoehn:fixed_canvas_svg_su...Project dashboard


Generated by RelativeCIDocumentationReport issue

@florian-h05 florian-h05 removed the request for review from ghys October 2, 2024 11:26
@florian-h05 florian-h05 marked this pull request as draft October 2, 2024 11:28
@florian-h05 florian-h05 added enhancement New feature or request main ui Main UI labels Oct 4, 2024
@florian-h05 florian-h05 force-pushed the fixed_canvas_svg_support branch 2 times, most recently from 77bb759 to c887fec Compare October 6, 2024 13:28
@stefan-hoehn stefan-hoehn changed the title DRAFT: fixed canvas SVG support Fixed Canvas interactive SVG support Oct 27, 2024
@stefan-hoehn stefan-hoehn changed the title Fixed Canvas interactive SVG support Fixed-Canvas interactive SVG support Oct 30, 2024
stefan-hoehn and others added 19 commits November 7, 2024 18:33
Signed-off-by: Stefan Höhn <mail@stefanhoehn.com>
Signed-off-by: Stefan Höhn <mail@stefanhoehn.com>
…r dependency issues

Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
Signed-off-by: Stefan Höhn <mail@stefanhoehn.com>
Signed-off-by: Stefan Höhn <mail@stefanhoehn.com>
Signed-off-by: Stefan Höhn <mail@stefanhoehn.com>
Signed-off-by: Stefan Höhn <mail@stefanhoehn.com>
Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
…p for state representation

Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
Signed-off-by: Stefan Höhn <mail@stefanhoehn.com>
Signed-off-by: Stefan Höhn <mail@stefanhoehn.com>
Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
Signed-off-by: Stefan Höhn <mail@stefanhoehn.com>
Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
florian-h05 and others added 8 commits November 7, 2024 18:33
Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
…lementForState, add min opacity param

Signed-off-by: Stefan Höhn <mail@stefanhoehn.com>
Signed-off-by: Stefan Höhn <mail@stefanhoehn.com>
Signed-off-by: Stefan Höhn <mail@stefanhoehn.com>
Signed-off-by: Stefan Höhn <mail@stefanhoehn.com>
Signed-off-by: Stefan Höhn <mail@stefanhoehn.com>
Signed-off-by: Stefan Höhn <mail@stefanhoehn.com>
Signed-off-by: Stefan Höhn <mail@stefanhoehn.com>
@florian-h05 florian-h05 force-pushed the fixed_canvas_svg_support branch 2 times, most recently from f0894b8 to e2f5210 Compare November 7, 2024 17:50
Signed-off-by: Florian Hotze <dev@florianhotze.com>
Signed-off-by: Florian Hotze <dev@florianhotze.com>
Signed-off-by: Florian Hotze <dev@florianhotze.com>
Signed-off-by: Florian Hotze <dev@florianhotze.com>
Copy link
Contributor

@florian-h05 florian-h05 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have rebased and refactored it a bit to use a better approach for widget actions than my first solution. It now also used Framework7 color conversion methods instead of your HSB to RGB implementation.

I have changed a few minor things in your code, code now LGTM!

Can you please test it @stefan-hoehn?

@florian-h05 florian-h05 added this to the 4.3 milestone Nov 7, 2024
@florian-h05 florian-h05 marked this pull request as ready for review November 7, 2024 20:00
@florian-h05 florian-h05 changed the title Fixed-Canvas interactive SVG support Canvas layout: Add interactive SVG support Nov 7, 2024
@stefan-hoehn
Copy link
Contributor Author

@florian-h05 First tests look pretty promising. I had to setup on item again but other than that all configured actions and items work well. I will do a bit of more testing today but I am pretty sure this finally can be merged.

@stefan-hoehn
Copy link
Contributor Author

LGTM, haven't found any issue, good job, Florian.

@florian-h05 florian-h05 merged commit 3dfe023 into openhab:main Nov 9, 2024
8 checks passed
@florian-h05 florian-h05 deleted the fixed_canvas_svg_support branch November 9, 2024 18:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request main ui Main UI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants