Merge pull request #628 from dermotduffy/auto-drawer

Open/close the drawer automatically for mouse users
This commit is contained in:
Dermot Duffy
2022-06-05 16:37:52 -07:00
committed by GitHub
+14 -5
View File
@@ -1,17 +1,16 @@
import { import {
CSSResultGroup, CSSResultGroup,
LitElement,
TemplateResult,
html, html,
unsafeCSS, LitElement,
PropertyValues, PropertyValues,
TemplateResult,
unsafeCSS,
} from 'lit'; } from 'lit';
import { customElement, property } from 'lit/decorators.js'; import { customElement, property } from 'lit/decorators.js';
import { createRef, ref, Ref } from 'lit/directives/ref.js'; import { createRef, ref, Ref } from 'lit/directives/ref.js';
import 'side-drawer'; import 'side-drawer';
import drawerStyle from '../scss/drawer.scss';
import drawerInjectStyle from '../scss/drawer-inject.scss'; import drawerInjectStyle from '../scss/drawer-inject.scss';
import drawerStyle from '../scss/drawer.scss';
@customElement('frigate-card-drawer') @customElement('frigate-card-drawer')
export class FrigateCardDrawer extends LitElement { export class FrigateCardDrawer extends LitElement {
@@ -92,6 +91,11 @@ export class FrigateCardDrawer extends LitElement {
${ref(this._refDrawer)} ${ref(this._refDrawer)}
location="${this.location}" location="${this.location}"
?open=${this.open} ?open=${this.open}
@mouseleave=${() => {
if (this.open) {
this.open = false;
}
}}
> >
${this.control ${this.control
? html` ? html`
@@ -104,6 +108,11 @@ export class FrigateCardDrawer extends LitElement {
<ha-icon <ha-icon
class="control" class="control"
icon="${this.open ? 'mdi:menu-open' : 'mdi:menu'}" icon="${this.open ? 'mdi:menu-open' : 'mdi:menu'}"
@mouseenter=${() => {
if (!this.open) {
this.open = true;
}
}}
> >
</ha-icon> </ha-icon>
</div> </div>