From 41f0699fb3db3ab1d9024ee7ad7840ecf1bb6774 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benedikt=20H=C3=BCbschen?= Date: Thu, 15 Aug 2024 22:06:09 +0200 Subject: [PATCH] support for fire-dom-event and url added --- CHANGELOG.md | 4 ++++ README.md | 4 +++- fab-card.js | 14 ++++++++++++++ package-lock.json | 4 ++-- package.json | 2 +- 5 files changed, 24 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3eda858..05b8cec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +### 1.0.2 (2024-08-15) + +support for "fire-dom-event" and "url" + ### 1.0.1 (2024-07-11) fixed navigation issues diff --git a/README.md b/README.md index 6aed90e..be2ee85 100644 --- a/README.md +++ b/README.md @@ -69,10 +69,12 @@ left: false | active_color | string | **Optional** | Background color of the button when active | `--accent-color` | | icon | string | **Required** | Icon to display on the FAB button | `mdi:menu` | | action | object | **Required** | Action to perform when the button is clicked | | -| action.action | string | **Required** | Type of action (`navigate`, `call-service`, etc.) | | +| action.action | string | **Required** | Type of action (`navigate`, `call-service`, `more-info`, `fire-dom-event`, `url`) | | | action.navigation_path | string | **Optional** | Path to navigate to (required if action is `navigate`) | | | action.service | string | **Optional** | Service to call (required if action is `call-service`) | | | action.service_data | object | **Optional** | Data to include with the service call (required if action is `call-service`) | | +| action.url_path | string | **Optional** | URL to navigate to (required if action is `url`) | +| action.target | string | **Optional** | Sets the target-frame/window/tab of the URL (optional if action is `url`) | | entity | string | **Optional** | Entity to monitor for state changes | | | positive_states | list | **Optional** | List of states considered positive | `['true', 'on', 'open', 'active', 'detected', 'occupied', 'unlocked', 'home', 'above_horizon', 'ready']` | | left | boolean | **Optional** | Position the button on the left side | `false` | diff --git a/fab-card.js b/fab-card.js index 607bdaf..8673d33 100644 --- a/fab-card.js +++ b/fab-card.js @@ -112,6 +112,20 @@ class FABCard extends HTMLElement { config.service_data, ); break; + case 'fire-dom-event': + const event = new Event('ll-custom', { composed: true, bubbles: true }); + event.detail = config; + this.dispatchEvent(event); + break; + case 'url': + if (config.url_path) { + if (config.target) { + window.open(config.url_path, config.target); + } else { + window.location.href = config.url_path; + } + } + break; default: break; } diff --git a/package-lock.json b/package-lock.json index 3ce63ae..934b906 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@bhuebschen/fab-card", - "version": "1.0.1", + "version": "1.0.12", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@bhuebschen/fab-card", - "version": "1.0.1", + "version": "1.0.12", "license": "MIT", "dependencies": { "custom-card-helpers": "^1.6.4", diff --git a/package.json b/package.json index 3dabe9c..e8a5872 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@bhuebschen/fab-card", - "version": "1.0.1", + "version": "1.0.2", "description": "Floating ActionButton for Home Assistant Lovelace UI", "main": "dist/fab-card.js", "scripts": {