Merge pull request #650 from dermotduffy/editor.border
Improve editor submenu styling
This commit is contained in:
+42
-38
@@ -1,6 +1,7 @@
|
||||
import { fireEvent, HomeAssistant, LovelaceCardEditor } from 'custom-card-helpers';
|
||||
import { CSSResultGroup, html, LitElement, TemplateResult, unsafeCSS } from 'lit';
|
||||
import { customElement, property, state } from 'lit/decorators.js';
|
||||
import { classMap } from 'lit/directives/class-map.js';
|
||||
import {
|
||||
copyConfig,
|
||||
deleteConfigValue,
|
||||
@@ -598,7 +599,12 @@ export class FrigateCardEditor extends LitElement implements LovelaceCardEditor
|
||||
}
|
||||
|
||||
protected _renderViewScanMenu(): TemplateResult {
|
||||
const submenuClasses = {
|
||||
submenu: true,
|
||||
selected: !!this._expandedMenus[MENU_VIEW_SCAN],
|
||||
};
|
||||
return html`
|
||||
<div class="${classMap(submenuClasses)}">
|
||||
<div
|
||||
class="submenu-header"
|
||||
@click=${this._toggleMenu}
|
||||
@@ -633,6 +639,7 @@ export class FrigateCardEditor extends LitElement implements LovelaceCardEditor
|
||||
})}
|
||||
</div>`
|
||||
: ''}
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
|
||||
@@ -647,8 +654,13 @@ export class FrigateCardEditor extends LitElement implements LovelaceCardEditor
|
||||
{ value: 'matching', label: localize('config.menu.buttons.alignments.matching') },
|
||||
{ value: 'opposing', label: localize('config.menu.buttons.alignments.opposing') },
|
||||
];
|
||||
const submenuClasses = {
|
||||
submenu: true,
|
||||
selected: this._expandedMenus[MENU_BUTTONS] === button,
|
||||
};
|
||||
|
||||
return html`
|
||||
<div class="${classMap(submenuClasses)}">
|
||||
<div
|
||||
class="submenu-header"
|
||||
@click=${this._toggleMenu}
|
||||
@@ -689,38 +701,6 @@ export class FrigateCardEditor extends LitElement implements LovelaceCardEditor
|
||||
})}
|
||||
</div>`
|
||||
: ''}
|
||||
`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Render a camera header.
|
||||
* @param cameraIndex The index of the camera to edit/add.
|
||||
* @param cameraConfig The configuration of the camera in question.
|
||||
* @param addNewCamera Whether or not this is a header to add a new camera.
|
||||
* @returns A rendered template.
|
||||
*/
|
||||
protected _renderCameraHeader(
|
||||
cameraIndex: number,
|
||||
cameraConfig?: RawFrigateCardConfig,
|
||||
addNewCamera?: boolean,
|
||||
): TemplateResult {
|
||||
return html`
|
||||
<div
|
||||
class="submenu-header"
|
||||
@click=${this._toggleMenu}
|
||||
.domain=${MENU_CAMERAS}
|
||||
.key=${cameraIndex}
|
||||
>
|
||||
<ha-icon .icon=${addNewCamera ? 'mdi:video-plus' : 'mdi:video'}></ha-icon>
|
||||
<span>
|
||||
${addNewCamera
|
||||
? html` <span class="new-camera">
|
||||
[${localize('editor.add_new_camera')}...]
|
||||
</span>`
|
||||
: html`<span
|
||||
>${this._getEditorCameraTitle(cameraIndex, cameraConfig || {})}</span
|
||||
>`}
|
||||
</span>
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
@@ -772,8 +752,33 @@ export class FrigateCardEditor extends LitElement implements LovelaceCardEditor
|
||||
}
|
||||
};
|
||||
|
||||
const submenuClasses = {
|
||||
submenu: true,
|
||||
selected: this._expandedMenus[MENU_CAMERAS] === cameraIndex,
|
||||
};
|
||||
|
||||
return html`
|
||||
${this._renderCameraHeader(cameraIndex, cameras[cameraIndex], addNewCamera)}
|
||||
<div class="${classMap(submenuClasses)}">
|
||||
<div
|
||||
class="submenu-header"
|
||||
@click=${this._toggleMenu}
|
||||
.domain=${MENU_CAMERAS}
|
||||
.key=${cameraIndex}
|
||||
>
|
||||
<ha-icon .icon=${addNewCamera ? 'mdi:video-plus' : 'mdi:video'}></ha-icon>
|
||||
<span>
|
||||
${addNewCamera
|
||||
? html` <span class="new-camera">
|
||||
[${localize('editor.add_new_camera')}...]
|
||||
</span>`
|
||||
: html`<span
|
||||
>${this._getEditorCameraTitle(
|
||||
cameraIndex,
|
||||
cameras[cameraIndex] || {},
|
||||
)}</span
|
||||
>`}
|
||||
</span>
|
||||
</div>
|
||||
${this._expandedMenus[MENU_CAMERAS] === cameraIndex
|
||||
? html` <div class="values">
|
||||
<div class="controls">
|
||||
@@ -901,6 +906,7 @@ export class FrigateCardEditor extends LitElement implements LovelaceCardEditor
|
||||
)}
|
||||
</div>`
|
||||
: ``}
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
|
||||
@@ -1014,10 +1020,10 @@ export class FrigateCardEditor extends LitElement implements LovelaceCardEditor
|
||||
<div class="card-config">
|
||||
${this._renderOptionSetHeader('cameras')}
|
||||
${this._expandedMenus[MENU_OPTIONS] === 'cameras'
|
||||
? html` <div class="submenu">
|
||||
? html`
|
||||
${cameras.map((_, index) => this._renderCamera(cameras, index, entities))}
|
||||
${this._renderCamera(cameras, cameras.length, entities, true)}
|
||||
</div>`
|
||||
`
|
||||
: ''}
|
||||
${this._renderOptionSetHeader('view')}
|
||||
${this._expandedMenus[MENU_OPTIONS] === 'view'
|
||||
@@ -1051,7 +1057,6 @@ export class FrigateCardEditor extends LitElement implements LovelaceCardEditor
|
||||
min: BUTTON_SIZE_MIN,
|
||||
})}
|
||||
</div>
|
||||
<div class="submenu">
|
||||
${this._renderMenuButton('frigate') /* */}
|
||||
${this._renderMenuButton('cameras') /* */}
|
||||
${this._renderMenuButton('live') /* */}
|
||||
@@ -1063,7 +1068,6 @@ export class FrigateCardEditor extends LitElement implements LovelaceCardEditor
|
||||
${this._renderMenuButton('fullscreen')}
|
||||
${this._renderMenuButton('timeline')}
|
||||
${this._renderMenuButton('media_player')}
|
||||
</div>
|
||||
`
|
||||
: ''}
|
||||
${this._renderOptionSetHeader('live')}
|
||||
@@ -1305,7 +1309,7 @@ export class FrigateCardEditor extends LitElement implements LovelaceCardEditor
|
||||
const domain = ev.target.domain;
|
||||
const key = ev.target.key;
|
||||
|
||||
if (this._expandedMenus[domain] == key) {
|
||||
if (this._expandedMenus[domain] === key) {
|
||||
this._closeMenu(domain);
|
||||
} else {
|
||||
this._openMenu(domain, key);
|
||||
|
||||
+19
-8
@@ -23,10 +23,8 @@
|
||||
pointer-events: none;
|
||||
}
|
||||
.values {
|
||||
padding: 10px;
|
||||
background: var(--secondary-background-color);
|
||||
display: grid;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
div.upgrade {
|
||||
width: auto;
|
||||
@@ -42,26 +40,39 @@ div.upgrade span {
|
||||
|
||||
.submenu-header {
|
||||
display: flex;
|
||||
margin-top: 10px;
|
||||
padding: 10px;
|
||||
|
||||
cursor: pointer;
|
||||
}
|
||||
.submenu.selected .submenu-header {
|
||||
background-color: var(--primary-color);
|
||||
color: var(--primary-text-color);
|
||||
}
|
||||
|
||||
.submenu-header * {
|
||||
flex-basis: auto;
|
||||
|
||||
// Only allow clicks on the header.
|
||||
pointer-events: none;
|
||||
}
|
||||
.submenu-header ha-icon {
|
||||
padding-right: 10px;
|
||||
}
|
||||
.submenu-header .new-camera {
|
||||
font-style: italic;
|
||||
}
|
||||
.submenu:not(.selected) .submenu-header .new-camera {
|
||||
color: var(--secondary-text-color, 'black');
|
||||
}
|
||||
.submenu {
|
||||
margin: 5px 5px 10px 20px;
|
||||
|
||||
.submenu-header ha-icon {
|
||||
padding-right: 15px;
|
||||
}
|
||||
|
||||
.submenu {
|
||||
border: 1px solid var(--divider-color);
|
||||
}
|
||||
.submenu.selected {
|
||||
border: 1px solid var(--primary-color);
|
||||
}
|
||||
|
||||
.submenu .controls {
|
||||
display: inline-block;
|
||||
margin-left: auto;
|
||||
|
||||
Reference in New Issue
Block a user