Skip to content

Commit

Permalink
Use ha-label for some chips
Browse files Browse the repository at this point in the history
  • Loading branch information
piitaya committed Nov 9, 2023
1 parent 7908404 commit 8eb8111
Show file tree
Hide file tree
Showing 11 changed files with 84 additions and 122 deletions.
3 changes: 0 additions & 3 deletions gallery/src/pages/components/ha-chips.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,6 @@ export class DemoHaChips extends LitElement {
max-width: 600px;
margin: 24px auto;
}
ha-chip {
margin-bottom: 4px;
}
.card-content {
display: flex;
flex-direction: column;
Expand Down
1 change: 0 additions & 1 deletion gallery/src/pages/misc/entity-state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { computeStateDisplay } from "../../../../src/common/entity/compute_state
import "../../../../src/components/data-table/ha-data-table";
import type { DataTableColumnContainer } from "../../../../src/components/data-table/ha-data-table";
import "../../../../src/components/entity/state-badge";
import "../../../../src/components/ha-chip";
import { provideHass } from "../../../../src/fake_data/provide_hass";
import { HomeAssistant } from "../../../../src/types";

Expand Down
4 changes: 0 additions & 4 deletions hassio/src/addon-view/info/hassio-addon-info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import { navigate } from "../../../../src/common/navigate";
import "../../../../src/components/buttons/ha-progress-button";
import "../../../../src/components/ha-alert";
import "../../../../src/components/ha-card";
import "../../../../src/components/ha-chip";
import "../../../../src/components/chips/ha-chip-set";
import "../../../../src/components/chips/ha-assist-chip";
import "../../../../src/components/ha-markdown";
Expand Down Expand Up @@ -1323,9 +1322,6 @@ class HassioAddonInfo extends LitElement {
}
@media (max-width: 720px) {
ha-chip {
line-height: 36px;
}
.addon-options {
max-width: 100%;
}
Expand Down
85 changes: 0 additions & 85 deletions src/components/ha-chip.ts

This file was deleted.

60 changes: 60 additions & 0 deletions src/components/ha-label.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
import { customElement } from "lit/decorators";

@customElement("ha-label")
class HaLabel extends LitElement {
protected render(): TemplateResult {
return html`
<span class="label">
<slot name="icon"></slot>
<slot></slot>
</div>
`;
}

static get styles(): CSSResultGroup {
return [
css`
:host {
--ha-label-text-color: var(--primary-text-color);
--ha-label-icon-color: var(--primary-text-color);
--ha-label-background-color: rgba(
var(--rgb-primary-text-color),
0.15
);
}
.label {
display: inline-flex;
flex-direction: row;
align-items: center;
font-size: 12px;
font-weight: 500;
line-height: 16px;
letter-spacing: 0.1px;
vertical-align: middle;
height: 32px;
padding: 0 16px;
border-radius: 18px;
background-color: var(--ha-label-background-color);
color: var(--ha-label-text-color);
--mdc-icon-size: 18px;
}
::slotted([slot="icon"]) {
margin-right: 8px;
margin-left: -8px;
display: flex;
color: var(--ha-label-icon-color);
}
span {
display: inline-flex;
}
`,
];
}
}

declare global {
interface HTMLElementTagNameMap {
"ha-label": HaLabel;
}
}
28 changes: 13 additions & 15 deletions src/dialogs/quick-bar/ha-quick-bar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import {
fuzzyFilterSort,
} from "../../common/string/filter/sequence-matching";
import { debounce } from "../../common/util/debounce";
import "../../components/ha-chip";
import "../../components/ha-label";
import "../../components/ha-circular-progress";
import "../../components/ha-icon-button";
import "../../components/ha-list-item";
Expand Down Expand Up @@ -326,19 +326,17 @@ export class QuickBar extends LitElement {
hasMeta
>
<span>
<ha-chip
<ha-label
.label=${item.categoryText}
hasIcon
class="command-category ${item.categoryKey}"
>
${item.iconPath
? html`<ha-svg-icon
.path=${item.iconPath}
slot="icon"
></ha-svg-icon>`
: ""}
${item.categoryText}</ha-chip
>
? html`
<ha-svg-icon .path=${item.iconPath} slot="icon"></ha-svg-icon>
`
: nothing}
${item.categoryText}
</ha-label>
</span>
<span class="command-text">${item.primaryText}</span>
Expand Down Expand Up @@ -815,20 +813,20 @@ export class QuickBar extends LitElement {
}
.command-category {
--ha-chip-icon-color: #585858;
--ha-chip-text-color: #212121;
--ha-label-icon-color: #585858;
--ha-label-text-color: #212121;
}
.command-category.reload {
--ha-chip-background-color: #cddc39;
--ha-label-background-color: #cddc39;
}
.command-category.navigation {
--ha-chip-background-color: var(--light-primary-color);
--ha-label-background-color: var(--light-primary-color);
}
.command-category.server_control {
--ha-chip-background-color: var(--warning-color);
--ha-label-background-color: var(--warning-color);
}
span.command-text {
Expand Down
5 changes: 0 additions & 5 deletions src/panels/calendar/ha-recurrence-rule-editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -513,11 +513,6 @@ export class RecurrenceRuleEditor extends LitElement {
.weekdays:last-child {
margin-bottom: 0;
}
.active {
--ha-chip-background-color: var(--primary-color);
--ha-chip-text-color: var(--text-primary-color);
}
`;
}

Expand Down
6 changes: 3 additions & 3 deletions src/panels/config/automation/ha-automation-picker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import type {
RowClickedEvent,
} from "../../../components/data-table/ha-data-table";
import "../../../components/ha-button-related-filter-menu";
import "../../../components/ha-chip";
import "../../../components/ha-label";
import "../../../components/ha-fab";
import "../../../components/ha-icon-button";
import "../../../components/ha-icon-overflow-menu";
Expand Down Expand Up @@ -202,11 +202,11 @@ class HaAutomationPicker extends LitElement {
template: (automation) =>
automation.disabled
? html`
<ha-chip>
<ha-label>
${this.hass.localize(
"ui.panel.config.automation.picker.disabled"
)}
</ha-chip>
</ha-label>
`
: "",
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,10 @@ export abstract class HaDeviceAutomationCard<
color: var(--primary-text-color);
}
.secondary {
--ha-chip-background-color: rgba(var(--rgb-primary-text-color), 0.07);
--ha-assist-chip-filled-container-color: rgba(
var(--rgb-primary-text-color),
0.07
);
}
button.link {
color: var(--primary-color);
Expand Down
8 changes: 4 additions & 4 deletions src/panels/config/users/dialog-user-detail.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import "@material/mwc-button";
import "@lrnwebcomponents/simple-tooltip/simple-tooltip";
import "@material/mwc-button";
import { css, CSSResultGroup, html, LitElement, nothing } from "lit";
import { customElement, property, state } from "lit/decorators";

import { computeRTLDirection } from "../../../common/util/compute_rtl";
import "../../../components/ha-chip";
import { createCloseHeading } from "../../../components/ha-dialog";
import "../../../components/ha-formfield";
import "../../../components/ha-help-tooltip";
import "../../../components/ha-label";
import "../../../components/ha-svg-icon";
import "../../../components/ha-switch";
import "../../../components/ha-textfield";
Expand Down Expand Up @@ -78,10 +78,10 @@ class DialogUserDetail extends LitElement {
<div class="badge-container">
${badges.map(
([icon, label]) => html`
<ha-chip hasIcon>
<ha-label>
<ha-svg-icon slot="icon" .path=${icon}></ha-svg-icon>
${label}
</ha-chip>
</ha-label>
`
)}
</div>
Expand Down
1 change: 0 additions & 1 deletion src/panels/lovelace/components/hui-buttons-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import { handleAction } from "../common/handle-action";
import { hasAction } from "../common/has-action";
import "../../../components/chips/ha-assist-chip";
import "../../../components/chips/ha-chip-set";
import "../../../components/ha-chip";
import { haStyleScrollbar } from "../../../resources/styles";

@customElement("hui-buttons-base")
Expand Down

0 comments on commit 8eb8111

Please sign in to comment.