mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-27 19:26:36 +00:00
Add row divider for entities card (#1503)
* Add row divider for entities card * Add gallery demo * Change hr to div, less attributes needed
This commit is contained in:
parent
44ab96d590
commit
22ed241286
@ -121,6 +121,11 @@ const CONFIGS = [
|
|||||||
url: http://google.com/
|
url: http://google.com/
|
||||||
icon: mdi:google
|
icon: mdi:google
|
||||||
name: Google
|
name: Google
|
||||||
|
- type: divider
|
||||||
|
- type: divider
|
||||||
|
style:
|
||||||
|
height: 16px
|
||||||
|
background: center / contain url("https://d33wubrfki0l68.cloudfront.net/075995fe17a5351e2699b2dd878652ec4f1d8654/8bfdd/demo/favicon-192x192.png")
|
||||||
`
|
`
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
@ -11,12 +11,14 @@ import '../entity-rows/hui-text-entity-row.js';
|
|||||||
import '../entity-rows/hui-timer-entity-row.js';
|
import '../entity-rows/hui-timer-entity-row.js';
|
||||||
import '../entity-rows/hui-toggle-entity-row.js';
|
import '../entity-rows/hui-toggle-entity-row.js';
|
||||||
|
|
||||||
|
import '../special-rows/hui-divider-row.js';
|
||||||
import '../special-rows/hui-weblink-row.js';
|
import '../special-rows/hui-weblink-row.js';
|
||||||
|
|
||||||
import createErrorCardConfig from './create-error-card-config.js';
|
import createErrorCardConfig from './create-error-card-config.js';
|
||||||
|
|
||||||
const CUSTOM_TYPE_PREFIX = 'custom:';
|
const CUSTOM_TYPE_PREFIX = 'custom:';
|
||||||
const SPECIAL_TYPES = new Set([
|
const SPECIAL_TYPES = new Set([
|
||||||
|
'divider',
|
||||||
'weblink'
|
'weblink'
|
||||||
]);
|
]);
|
||||||
const DOMAIN_TO_ELEMENT_TYPE = {
|
const DOMAIN_TO_ELEMENT_TYPE = {
|
||||||
|
43
src/panels/lovelace/special-rows/hui-divider-row.js
Normal file
43
src/panels/lovelace/special-rows/hui-divider-row.js
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
import { html } from '@polymer/polymer/lib/utils/html-tag.js';
|
||||||
|
import { PolymerElement } from '@polymer/polymer/polymer-element.js';
|
||||||
|
|
||||||
|
class HuiDividerRow extends PolymerElement {
|
||||||
|
static get template() {
|
||||||
|
return html``;
|
||||||
|
}
|
||||||
|
|
||||||
|
setConfig(config) {
|
||||||
|
if (!config) {
|
||||||
|
throw new Error('Error in card configuration.');
|
||||||
|
}
|
||||||
|
this._config = config;
|
||||||
|
this._createDivider();
|
||||||
|
}
|
||||||
|
|
||||||
|
ready() {
|
||||||
|
super.ready();
|
||||||
|
this._createDivider();
|
||||||
|
}
|
||||||
|
|
||||||
|
_createDivider() {
|
||||||
|
const root = this.shadowRoot;
|
||||||
|
if (root === null) return;
|
||||||
|
|
||||||
|
while (root.lastChild) {
|
||||||
|
root.removeChild(root.lastChild);
|
||||||
|
}
|
||||||
|
|
||||||
|
const style = this._config.style || {
|
||||||
|
height: '1px',
|
||||||
|
'background-color': 'var(--secondary-text-color)'
|
||||||
|
};
|
||||||
|
|
||||||
|
const el = document.createElement('div');
|
||||||
|
Object.keys(style).forEach((prop) => {
|
||||||
|
el.style.setProperty(prop, style[prop]);
|
||||||
|
});
|
||||||
|
|
||||||
|
root.appendChild(el);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
customElements.define('hui-divider-row', HuiDividerRow);
|
Loading…
x
Reference in New Issue
Block a user