Skip to content
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
d25805a
initial styling
maykar Oct 16, 2020
01e50b8
Delete package-lock.json
maykar Oct 16, 2020
e7000a0
fix media browser heading spacing
maykar Oct 16, 2020
d533aba
Add compact header user profile option
maykar Oct 16, 2020
a3e63df
compact mixin/types
maykar Oct 16, 2020
bbdb63c
add mixin to hass-elem
maykar Oct 16, 2020
819e590
cleanup
maykar Oct 16, 2020
4ea3fb3
add compact mode to hui-root and styles
maykar Oct 16, 2020
ea92013
Fix fireEvent
maykar Oct 17, 2020
c8f70d7
Update connection-mixin.ts
maykar Oct 17, 2020
a82e99a
adjust height calc for new app-header height
maykar Oct 17, 2020
d2f40fe
start conversion to UI overhaul
maykar Oct 17, 2020
1160b39
Update ha-panel-profile.ts
maykar Oct 17, 2020
363674a
Update ha-pref-storage.ts
maykar Oct 17, 2020
838d2a0
Update connection-mixin.ts
maykar Oct 17, 2020
1e2e73f
Update provide_hass.ts
maykar Oct 17, 2020
95c6823
Only use tabs div in edit mode
maykar Oct 17, 2020
57aaacc
hui-root styling
maykar Oct 17, 2020
6f7f69f
ha-tabs styling
maykar Oct 17, 2020
9ca219e
Update styles.ts
maykar Oct 17, 2020
2de146d
Header styling
maykar Oct 17, 2020
5abec48
styling tweaks
maykar Oct 17, 2020
73eb69c
set background on ha-app-layout
maykar Oct 19, 2020
74141c6
adjust view height
maykar Oct 20, 2020
0d3897f
center tabs
maykar Oct 20, 2020
bffbc05
Remove .tabs-hidden
maykar Oct 20, 2020
d0635e2
@query app-header, remove unusedentities background, var(--header-hei…
maykar Oct 20, 2020
bf0b087
restore header height
maykar Oct 20, 2020
9f13cf6
Revert sidebar changes
maykar Oct 20, 2020
5cb9e8f
Update ha-sidebar.ts
maykar Oct 20, 2020
e69aaa6
Update header height
bramkragten Oct 20, 2020
7cb3367
remove unnecessary styling
maykar Oct 20, 2020
a25a0d6
edit mode ha-tab styling
maykar Oct 20, 2020
7f53c61
ha-tabs styling & clear background
maykar Oct 20, 2020
5467c64
ha-tabs height as header height
maykar Oct 20, 2020
fafc718
--header-height
maykar Oct 20, 2020
1324b2e
resize on editmode in update
maykar Oct 20, 2020
5443fb0
more --header-height
maykar Oct 20, 2020
becfd8f
Correct height for edit mode
bramkragten Oct 21, 2020
17c88c9
Move voice button to overflow on mobile
bramkragten Oct 21, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions src/components/ha-sidebar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -386,9 +386,7 @@ class HaSidebar extends LitElement {
.hass=${hass}
></ha-user-badge>

<span class="item-text">
${hass.user ? hass.user.name : ""}
</span>
<span class="item-text">${hass.user ? hass.user.name : ""}</span>
</paper-icon-item>
</a>
<div disabled class="bottom-spacer"></div>
Expand Down Expand Up @@ -737,7 +735,7 @@ class HaSidebar extends LitElement {
}
.menu {
box-sizing: border-box;
height: 65px;
height: 48px;
display: flex;
padding: 0 8.5px;
border-bottom: 1px solid transparent;
Expand Down Expand Up @@ -790,11 +788,11 @@ class HaSidebar extends LitElement {
}

paper-listbox {
padding: 4px 0;
padding: 8px 0 4px 0;
display: flex;
flex-direction: column;
box-sizing: border-box;
height: calc(100% - 196px - env(safe-area-inset-bottom));
height: calc(100% - 176px - env(safe-area-inset-bottom));
overflow-x: hidden;
background: none;
margin-left: env(safe-area-inset-left);
Expand Down
3 changes: 3 additions & 0 deletions src/components/ha-tabs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ export class HaTabs extends PaperTabs {

superStyle!.appendChild(
document.createTextNode(`
:host {
padding-top: .5px;
Comment thread
maykar marked this conversation as resolved.
}
.not-visible {
display: none;
}
Expand Down
1 change: 1 addition & 0 deletions src/fake_data/provide_hass.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ export const provideHass = (
translationMetadata: translationMetadata as any,
dockedSidebar: "auto",
vibrate: true,
compactHeader: false,
suspendWhenHidden: false,
moreInfoEntityId: null as any,
// @ts-ignore
Expand Down
2 changes: 1 addition & 1 deletion src/panels/calendar/ha-panel-calendar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ class PanelCalendar extends LitElement {
}

:host(:not([narrow])) .content {
height: calc(100vh - 64px);
height: calc(100vh - 48px);
}

.calendar-list {
Expand Down
2 changes: 1 addition & 1 deletion src/panels/lovelace/cards/hui-starting-card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export class HuiStartingCard extends LitElement implements LovelaceCard {
return css`
:host {
display: block;
height: calc(100vh - 64px);
height: calc(100vh - 48px);
}
ha-circular-progress {
padding-bottom: 20px;
Expand Down
55 changes: 51 additions & 4 deletions src/panels/lovelace/hui-root.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,44 @@ class HUIRoot extends LitElement {
.hass=${this.hass}
.narrow=${this.narrow}
></ha-menu-button>
<div main-title>${this.config.title || "Home Assistant"}</div>
${this.hass.compactHeader &&
this.lovelace!.config.views.length > 1
? html`
<ha-tabs
scrollable
.selected="${this._curView}"
@iron-activate="${this._handleViewSelected}"
dir="${computeRTLDirection(this.hass!)}"
>
${this.lovelace!.config.views.map(
(view) => html`
<paper-tab
aria-label="${view.title}"
class="${classMap({
"hide-tab": Boolean(
view.visible !== undefined &&
((Array.isArray(view.visible) &&
!view.visible.some(
(e) => e.user === this.hass!.user!.id
)) ||
view.visible === false)
),
})}"
>
${view.icon
? html`
<ha-icon
title="${view.title}"
.icon="${view.icon}"
></ha-icon>
`
: view.title || "Unnamed view"}
</paper-tab>
`
)}
</ha-tabs>
`
: html`<div main-title>${this.config.title}</div>`}
${this._conversation(this.hass.config.components)
? html`
<mwc-icon-button
Expand Down Expand Up @@ -280,7 +317,9 @@ class HUIRoot extends LitElement {
</ha-button-menu>
</app-toolbar>
`}
${this.lovelace!.config.views.length > 1 || this._editMode
${(this.lovelace!.config.views.length > 1 &&
!this.hass.compactHeader) ||
this._editMode
? html`
<div sticky>
<ha-tabs
Expand Down Expand Up @@ -372,7 +411,9 @@ class HUIRoot extends LitElement {
id="view"
class="${classMap({
"tabs-hidden":
!this._editMode && this.lovelace!.config.views.length < 2,
!this._editMode &&
(this.lovelace!.config.views.length < 2 ||
this.hass.compactHeader),
})}"
@ll-rebuild="${this._debouncedConfigChanged}"
></div>
Expand Down Expand Up @@ -554,10 +595,12 @@ class HUIRoot extends LitElement {

private _enableEditMode(): void {
this.lovelace!.setEditMode(true);
fireEvent(this, "iron-resize");
Comment thread
maykar marked this conversation as resolved.
Outdated
}

private _editModeDisable(): void {
this.lovelace!.setEditMode(false);
fireEvent(this, "iron-resize");
}

private _editLovelace() {
Expand Down Expand Up @@ -704,6 +747,10 @@ class HUIRoot extends LitElement {
--paper-tabs-selection-bar-color: var(--text-primary-color, #fff);
text-transform: uppercase;
}
app-toolbar ha-tabs {
width: 100%;
margin: 0 8px;
}
.edit-mode {
background-color: var(--dark-color, #455a64);
color: var(--text-dark-color);
Expand Down Expand Up @@ -762,7 +809,7 @@ class HUIRoot extends LitElement {
max-width: 100%;
}
#view.tabs-hidden {
min-height: calc(100vh - 64px);
min-height: calc(100vh - 48px);
}
.hide-tab {
display: none;
Expand Down
5 changes: 3 additions & 2 deletions src/panels/lovelace/views/hui-masonry-view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -261,9 +261,10 @@ export class MasonryView extends LitElement implements LovelaceViewElement {
:host {
display: block;
background: var(--lovelace-background);
padding-top: 4px;
height: 100%;
padding-top: 100px;
height: calc(100% + 112px);
box-sizing: border-box;
margin-top: -96px;
}

#badges {
Expand Down
5 changes: 4 additions & 1 deletion src/panels/lovelace/views/hui-panel-view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,10 @@ export class PanelView extends LitElement implements LovelaceViewElement {
:host {
display: block;
background: var(--lovelace-background);
height: 100%;
height: calc(100% + 116px);
margin-top: -100px;
box-sizing: border-box;
padding-top: 100px;
}

mwc-fab {
Expand Down
2 changes: 1 addition & 1 deletion src/panels/map/ha-panel-map.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class HaPanelMap extends LocalizeMixin(PolymerElement) {
return html`
<style include="ha-style">
#map {
height: calc(100vh - 64px);
height: calc(100vh - 48px);
width: 100%;
z-index: 0;
background: inherit;
Expand Down
3 changes: 2 additions & 1 deletion src/panels/media-browser/ha-panel-media-browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,15 @@ class PanelMediaBrowser extends LitElement {
--mdc-theme-primary: var(--app-header-text-color);
}
ha-media-player-browse {
height: calc(100vh - 64px);
height: calc(100vh - 48px);
Comment thread
maykar marked this conversation as resolved.
Outdated
}
:host([narrow]) app-toolbar mwc-button {
width: 65px;
}
.heading {
overflow: hidden;
white-space: nowrap;
margin-top: 4px;
}
.heading .secondary-text {
font-size: 14px;
Expand Down
5 changes: 5 additions & 0 deletions src/panels/profile/ha-panel-profile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import "./ha-pick-language-row";
import "./ha-pick-theme-row";
import "./ha-push-notifications-row";
import "./ha-refresh-tokens-card";
import "./ha-set-compact-header-row";
import "./ha-set-suspend-row";
import "./ha-set-vibrate-row";

Expand Down Expand Up @@ -132,6 +133,10 @@ class HaPanelProfile extends LitElement {
></ha-force-narrow-row>
`
: ""}
<ha-set-compact-header-row
.narrow=${this.narrow}
.hass=${this.hass}
></ha-set-compact-header-row>
${"vibrate" in navigator
? html`
<ha-set-vibrate-row
Expand Down
52 changes: 52 additions & 0 deletions src/panels/profile/ha-set-compact-header-row.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import {
customElement,
html,
LitElement,
property,
TemplateResult,
} from "lit-element";
import { fireEvent } from "../../common/dom/fire_event";
import "../../components/ha-switch";
import type { HaSwitch } from "../../components/ha-switch";
import type { HomeAssistant } from "../../types";
import "../../components/ha-settings-row";

@customElement("ha-set-compact-header-row")
class HaSetCompactHeaderRow extends LitElement {
@property({ attribute: false }) public hass!: HomeAssistant;

@property() public narrow!: boolean;

protected render(): TemplateResult {
return html`
<ha-settings-row .narrow=${this.narrow}>
<span slot="heading">
${this.hass.localize("ui.panel.profile.compact_header.header")}
</span>
<span slot="description">
${this.hass.localize("ui.panel.profile.compact_header.description")}
</span>
<ha-switch
.checked=${this.hass.compactHeader}
@change=${this._checkedChanged}
></ha-switch>
</ha-settings-row>
`;
}

private async _checkedChanged(ev: Event) {
const compact = (ev.target as HaSwitch).checked;
if (compact === this.hass.compactHeader) {
return;
}
fireEvent(this, "hass-compact-header", {
compact,
});
}
}

declare global {
interface HTMLElementTagNameMap {
"ha-set-compact-header-row": HaSetCompactHeaderRow;
}
}
5 changes: 5 additions & 0 deletions src/resources/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,11 @@ export const haStyle = css`
color: var(--app-header-text-color, white);
}

app-toolbar,
Comment thread
maykar marked this conversation as resolved.
Outdated
div[sticky] {
Comment thread
maykar marked this conversation as resolved.
Outdated
height: 48px;
Comment thread
maykar marked this conversation as resolved.
}

app-toolbar [main-title] {
margin-left: 20px;
}
Expand Down
31 changes: 31 additions & 0 deletions src/state/compact-header.mixin.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { HASSDomEvent } from "../common/dom/fire_event";
import { Constructor, HomeAssistant } from "../types";
import type { PropertyValues } from "lit-element";
import { storeState } from "../util/ha-pref-storage";
import { HassBaseEl } from "./hass-base-mixin";

interface CompactHeaderParams {
compact: HomeAssistant["compactHeader"];
}

declare global {
// for fire event
interface HASSDomEvents {
"hass-compact-header": CompactHeaderParams;
}
// for add event listener
interface HTMLElementEventMap {
"hass-compact-header": HASSDomEvent<CompactHeaderParams>;
}
}

export default <T extends Constructor<HassBaseEl>>(superClass: T) =>
Comment thread
maykar marked this conversation as resolved.
Outdated
class extends superClass {
protected firstUpdated(changedProps: PropertyValues) {
super.firstUpdated(changedProps);
this.addEventListener("hass-compact-header", (ev) => {
this._updateHass({ compactHeader: ev.detail.compact });
storeState(this.hass!);
});
}
};
1 change: 1 addition & 0 deletions src/state/connection-mixin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export const connectionMixin = <T extends Constructor<HassBaseEl>>(
translationMetadata,
dockedSidebar: "docked",
vibrate: true,
compactHeader: false,
suspendWhenHidden: true,
moreInfoEntityId: null,
hassUrl: (path = "") => new URL(path, auth.data.hassUrl).toString(),
Expand Down
2 changes: 2 additions & 0 deletions src/state/hass-element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { connectionMixin } from "./connection-mixin";
import { dialogManagerMixin } from "./dialog-manager-mixin";
import DisconnectToastMixin from "./disconnect-toast-mixin";
import { hapticMixin } from "./haptic-mixin";
import compactHeaderMixin from "./compact-header.mixin";
import { HassBaseEl } from "./hass-base-mixin";
import MoreInfoMixin from "./more-info-mixin";
import NotificationMixin from "./notification-mixin";
Expand Down Expand Up @@ -31,4 +32,5 @@ export class HassElement extends ext(HassBaseEl, [
hapticMixin,
panelTitleMixin,
loggingMixin,
compactHeaderMixin,
Comment thread
maykar marked this conversation as resolved.
Outdated
]) {}
4 changes: 4 additions & 0 deletions src/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -2615,6 +2615,10 @@
"description": "You can also press and hold the header of the sidebar to activate edit mode.",
"button": "Edit"
},
"compact_header": {
"header": "Compact the Lovelace header",
"description": "Removes header title and compresses the Lovelace header."
},
"vibrate": {
"header": "Vibrate",
"description": "Enable or disable vibration on this device when controlling devices."
Expand Down
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ export interface HomeAssistant {
suspendWhenHidden: boolean;
vibrate: boolean;
dockedSidebar: "docked" | "always_hidden" | "auto";
compactHeader: boolean;
defaultPanel: string;
moreInfoEntityId: string | null;
user?: CurrentUser;
Expand Down
1 change: 1 addition & 0 deletions src/util/ha-pref-storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const STORED_STATE = [
"selectedLanguage",
"vibrate",
"suspendWhenHidden",
"compactHeader",
"defaultPanel",
];
const STORAGE = window.localStorage || {};
Expand Down