Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions src/data/lovelace/config/view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export interface LovelaceBaseViewConfig {
title?: string;
path?: string;
icon?: string;
show_icon_and_title?: boolean;
theme?: string;
panel?: boolean;
background?: string | LovelaceViewBackgroundConfig;
Expand Down
6 changes: 6 additions & 0 deletions src/panels/lovelace/common/generate-lovelace-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,7 @@ export const generateViewConfig = (
path: string,
title: string | undefined,
icon: string | undefined,
show_icon_and_title: boolean | undefined,
entities: HassEntities
): LovelaceViewConfig => {
const ungroupedEntitites: Record<string, string[]> = {};
Expand Down Expand Up @@ -497,6 +498,9 @@ export const generateViewConfig = (
if (icon) {
view.icon = icon;
}
if (show_icon_and_title) {
view.show_icon_and_title = show_icon_and_title;
}

return view;
};
Expand All @@ -517,6 +521,7 @@ export const generateDefaultViewConfig = (
const path = "default_view";
const title = "Home";
const icon = undefined;
const show_icon_and_title = undefined;

// In the case of a default view, we want to use the group order attribute
const groupOrders = {};
Expand Down Expand Up @@ -566,6 +571,7 @@ export const generateDefaultViewConfig = (
path,
title,
icon,
show_icon_and_title,
splittedByGroups.ungrouped
);

Expand Down
8 changes: 8 additions & 0 deletions src/panels/lovelace/editor/view-editor/hui-view-editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ export class HuiViewEditor extends LitElement {
icon: {},
},
},
{
name: "show_icon_and_title",
selector: {
boolean: {},
},
},
{ name: "path", selector: { text: {} } },
{ name: "theme", selector: { theme: {} } },
{
Expand Down Expand Up @@ -207,6 +213,7 @@ export class HuiViewEditor extends LitElement {
case "path":
return this.hass!.localize("ui.panel.lovelace.editor.card.generic.url");
case "type":
case "show_icon_and_title":
case "subview":
case "max_columns":
case "dense_section_placement":
Expand All @@ -227,6 +234,7 @@ export class HuiViewEditor extends LitElement {
) => {
switch (schema.name) {
case "path":
case "show_icon_and_title":
case "subview":
case "dense_section_placement":
case "top_margin":
Expand Down
46 changes: 28 additions & 18 deletions src/panels/lovelace/hui-root.ts
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,10 @@ class HUIRoot extends LitElement {

const tabs = html`<ha-tab-group @wa-tab-show=${this._handleViewSelected}>
${views.map((view, index) => {
const icon_and_title =
view.show_icon_and_title && view.icon && view.title;
const icon_only = view.icon && !icon_and_title;
const title_only = !icon_only && !icon_and_title;
const hidden =
!this._editMode && (view.subview || _isTabHiddenForUser(view));
return html`
Expand All @@ -506,7 +510,8 @@ class HUIRoot extends LitElement {
.disabled=${hidden}
aria-label=${ifDefined(view.title)}
class=${classMap({
icon: Boolean(view.icon),
"icon-only": Boolean(icon_only),
"icon-and-title": Boolean(icon_and_title),
"hide-tab": Boolean(hidden),
})}
>
Expand All @@ -523,18 +528,20 @@ class HUIRoot extends LitElement {
></ha-icon-button-arrow-prev>
`
: nothing}
${view.icon
? html`
<ha-icon
class=${classMap({
"child-view-icon": Boolean(view.subview),
})}
title=${ifDefined(view.title)}
.icon=${view.icon}
></ha-icon>
`
: view.title ||
this.hass.localize("ui.panel.lovelace.views.unnamed_view")}
${icon_only || icon_and_title
? html`<ha-icon
class=${classMap({
"child-view-icon": Boolean(view.subview),
})}
title=${ifDefined(view.title)}
.icon=${view.icon}
></ha-icon>`
: nothing}
${icon_and_title ? view.title : nothing}
${title_only
? view.title ||
this.hass.localize("ui.panel.lovelace.views.unnamed_view")
: nothing}
${this._editMode
? html`
<ha-icon-button
Expand Down Expand Up @@ -1489,24 +1496,27 @@ class HUIRoot extends LitElement {
ha-tab-group-tab {
--ha-tab-group-tab-height: var(--header-height, 56px);
}
.tab-bar ha-tab-group-tab {
--ha-tab-group-tab-height: var(--tab-bar-height, 56px);
}
ha-tab-group-tab[aria-selected="true"] .edit-icon {
display: inline-flex;
}

ha-tab-group-tab::part(base) {
padding-inline-start: var(--ha-tab-padding-start, var(--wa-space-l));
padding-inline-end: var(--ha-tab-padding-end, var(--wa-space-l));
}
ha-tab-group-tab::part(base) {
padding-top: calc((var(--ha-tab-group-tab-height) - 20px) / 2);
}
ha-tab-group-tab.icon::part(base) {
ha-tab-group-tab.icon-only::part(base),
ha-tab-group-tab.icon-and-title::part(base) {
padding-top: calc((var(--ha-tab-group-tab-height) - 20px) / 2 - 2px);
padding-bottom: calc(
(var(--ha-tab-group-tab-height) - 20px) / 2 - 4px
);
}
.tab-bar ha-tab-group-tab {
--ha-tab-group-tab-height: var(--tab-bar-height, 56px);
ha-tab-group-tab.icon-and-title ha-icon {
margin-inline-end: var(--ha-space-2);
}
.edit-mode ha-tab-group-tab[aria-selected="true"]::part(base) {
padding: 0;
Expand Down
2 changes: 2 additions & 0 deletions src/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -7603,13 +7603,15 @@
"sidebar": "Sidebar",
"panel": "Panel (single card)"
},
"show_icon_and_title": "Show icon and title",
"subview": "Subview",
"max_columns": "Max number of sections wide",
"section_specifics": "Sections view specific settings",
"dense_section_placement": "Dense section placement",
"dense_section_placement_helper": "Will try to fill gaps with sections that fit the gap. This may make section placement less predictable.",
"top_margin": "Add additional space above",
"top_margin_helper": "Helps reveal more of the background",
"show_icon_and_title_helper": "Show both icon and text title.",
"subview_helper": "Subviews don't appear in tabs and have a back button.",
"path_helper": "This value will become part of the URL path to open this view.",
"edit_ui": "Edit in visual editor",
Expand Down
Loading