AmoebeLabs / swiss-army-knife-card

The versatile custom Swiss Army Knife card for Home Assistant allows you to create your unique visualization using several graphical tools, styling options and animations.
232 stars 19 forks source link

Add Lock Tool #102

Open AmoebeLabs opened 2 years ago

AmoebeLabs commented 2 years ago

The Problem To Be Solved

All the tools that support user interaction respond directly to that user interaction. In most cases that is fine, but in some cases, a single - accidental - tap can have unwanted consequences.

It would be nice to be able to 'lock' those tools, where the 'lock' must be removed first, before the tool can be tapped!

Additional background:

Related Issues (if any)

(Optional): Suggested Solution

User action is based on the top HTML/SVG element to respond to user interactions.

One could overlay a tool with this Lock Tool that handles the user interactions first:

Configuration:

It will be a multi-part tool, just like the slider, switch, etc.

Visualization:

(Optional): Alternative Solutions

What if an extra user_action can be specified, that implements the above behavior? The only problem then is that we are missing a state for the lock, as the tool must respond to that state to allow tap actions to pass, instead of blocking them. Same for the Icon that displays a lock/unlock state with colors.

Maybe the extra user_action is a good idea to handle the tap events! In that way, one can specify some stuff. In a later stadium, that could enable the implementation of other unlock strategies, such as long-press (which I hate BTW!!!!!)

As we can have multiple of these Lock tools per card, it needs to store its state!