mirror of
https://github.com/home-assistant/frontend.git
synced 2025-11-05 17:09:48 +00:00
113 lines
3.1 KiB
TypeScript
113 lines
3.1 KiB
TypeScript
import { css, html, LitElement } from "lit";
|
|
import { customElement, property } from "lit/decorators";
|
|
|
|
@customElement("ha-dialog-header")
|
|
export class HaDialogHeader extends LitElement {
|
|
@property({ type: String, attribute: "subtitle-position" })
|
|
public subtitlePosition: "above" | "below" = "below";
|
|
|
|
@property({ type: Boolean, reflect: true, attribute: "show-border" })
|
|
public showBorder = false;
|
|
|
|
protected render() {
|
|
const titleSlot = html`<div class="header-title">
|
|
<slot name="title"></slot>
|
|
</div>`;
|
|
|
|
const subtitleSlot = html`<div class="header-subtitle">
|
|
<slot name="subtitle"></slot>
|
|
</div>`;
|
|
|
|
return html`
|
|
<header class="header">
|
|
<div class="header-bar">
|
|
<section class="header-navigation-icon">
|
|
<slot name="navigationIcon"></slot>
|
|
</section>
|
|
<section class="header-content">
|
|
${this.subtitlePosition === "above"
|
|
? html`${subtitleSlot}${titleSlot}`
|
|
: html`${titleSlot}${subtitleSlot}`}
|
|
</section>
|
|
<section class="header-action-items">
|
|
<slot name="actionItems"></slot>
|
|
</section>
|
|
</div>
|
|
<slot></slot>
|
|
</header>
|
|
`;
|
|
}
|
|
|
|
static get styles() {
|
|
return [
|
|
css`
|
|
:host {
|
|
display: block;
|
|
}
|
|
:host([show-border]) {
|
|
border-bottom: 1px solid
|
|
var(--mdc-dialog-scroll-divider-color, rgba(0, 0, 0, 0.12));
|
|
}
|
|
.header-bar {
|
|
display: flex;
|
|
flex-direction: row;
|
|
align-items: center;
|
|
padding: 0 var(--ha-space-1);
|
|
box-sizing: border-box;
|
|
}
|
|
.header-content {
|
|
flex: 1;
|
|
padding: 10px var(--ha-space-1);
|
|
display: flex;
|
|
flex-direction: column;
|
|
justify-content: center;
|
|
min-height: var(--ha-space-12);
|
|
min-width: 0;
|
|
overflow: hidden;
|
|
text-overflow: ellipsis;
|
|
white-space: nowrap;
|
|
}
|
|
.header-title {
|
|
height: var(
|
|
--ha-dialog-header-title-height,
|
|
calc(var(--ha-font-size-xl) + var(--ha-space-1))
|
|
);
|
|
font-size: var(--ha-font-size-xl);
|
|
line-height: var(--ha-line-height-condensed);
|
|
font-weight: var(--ha-font-weight-medium);
|
|
}
|
|
.header-subtitle {
|
|
font-size: var(--ha-font-size-m);
|
|
line-height: var(--ha-line-height-normal);
|
|
color: var(--secondary-text-color);
|
|
}
|
|
@media all and (min-width: 450px) and (min-height: 500px) {
|
|
.header-bar {
|
|
padding: 0 var(--ha-space-2);
|
|
}
|
|
}
|
|
.header-navigation-icon {
|
|
flex: none;
|
|
min-width: var(--ha-space-2);
|
|
height: 100%;
|
|
display: flex;
|
|
flex-direction: row;
|
|
}
|
|
.header-action-items {
|
|
flex: none;
|
|
min-width: var(--ha-space-2);
|
|
height: 100%;
|
|
display: flex;
|
|
flex-direction: row;
|
|
}
|
|
`,
|
|
];
|
|
}
|
|
}
|
|
|
|
declare global {
|
|
interface HTMLElementTagNameMap {
|
|
"ha-dialog-header": HaDialogHeader;
|
|
}
|
|
}
|