Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create ha-divider and use it inside color picker #22074

Merged
merged 2 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 4 additions & 0 deletions src/components/ha-color-picker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { LocalizeKeys } from "../common/translations/localize";
import { HomeAssistant } from "../types";
import "./ha-list-item";
import "./ha-select";
import "./ha-divider";

@customElement("ha-color-picker")
export class HaColorPicker extends LitElement {
Expand Down Expand Up @@ -93,6 +94,9 @@ export class HaColorPicker extends LitElement {
</ha-list-item>
`
: nothing}
${this.includeState || this.includeNone
? html`<ha-divider role="separator" tabindex="-1"></ha-divider>`
: nothing}
${Array.from(THEME_COLORS).map(
(color) => html`
<ha-list-item .value=${color} graphic="icon">
Expand Down
21 changes: 21 additions & 0 deletions src/components/ha-divider.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { MdDivider } from "@material/web/divider/divider";
import { css } from "lit";
import { customElement } from "lit/decorators";

@customElement("ha-divider")
export class HaDivider extends MdDivider {
static override styles = [
...super.styles,
css`
:host {
--md-divider-color: var(--divider-color);
}
`,
];
}

declare global {
interface HTMLElementTagNameMap {
"ha-divider": HaDivider;
}
}
6 changes: 3 additions & 3 deletions src/layouts/hass-tabs-subpage-data-table.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { ResizeController } from "@lit-labs/observers/resize-controller";
import "@lrnwebcomponents/simple-tooltip/simple-tooltip";
import "@material/mwc-button/mwc-button";
import "@material/web/divider/divider";
import {
mdiArrowDown,
mdiArrowUp,
Expand Down Expand Up @@ -37,6 +36,7 @@ import type {
} from "../components/data-table/ha-data-table";
import "../components/ha-md-button-menu";
import "../components/ha-dialog";
import "../components/ha-divider";
import { HaMenu } from "../components/ha-menu";
import "../components/ha-md-menu-item";
import "../components/search-input-outlined";
Expand Down Expand Up @@ -364,7 +364,7 @@ export class HaTabsSubpageDataTable extends LitElement {
)}
</div>
</ha-md-menu-item>
<md-divider role="separator" tabindex="-1"></md-divider>
<ha-divider role="separator" tabindex="-1"></ha-divider>
<ha-md-menu-item
.value=${undefined}
@click=${this._disableSelectMode}
Expand Down Expand Up @@ -501,7 +501,7 @@ export class HaTabsSubpageDataTable extends LitElement {
>
${localize("ui.components.subpage-data-table.dont_group_by")}
</ha-md-menu-item>
<md-divider role="separator" tabindex="-1"></md-divider>
<ha-divider role="separator" tabindex="-1"></ha-divider>
<ha-md-menu-item
@click=${this._collapseAllGroups}
.disabled=${this._groupColumn === undefined}
Expand Down
6 changes: 3 additions & 3 deletions src/panels/config/automation/add-automation-element-dialog.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import "@material/web/divider/divider";
import { mdiClose, mdiContentPaste, mdiPlus } from "@mdi/js";
import Fuse, { IFuseOptions } from "fuse.js";
import {
Expand All @@ -24,12 +23,13 @@ import { deepEqual } from "../../../common/util/deep-equal";
import "../../../components/ha-dialog";
import type { HaDialog } from "../../../components/ha-dialog";
import "../../../components/ha-dialog-header";
import "../../../components/ha-divider";
import "../../../components/ha-domain-icon";
import "../../../components/ha-icon-button";
import "../../../components/ha-icon-button-prev";
import "../../../components/ha-icon-next";
import "../../../components/ha-md-list-item";
import "../../../components/ha-md-list";
import "../../../components/ha-md-list-item";
import "../../../components/ha-service-icon";
import "../../../components/search-input";
import {
Expand Down Expand Up @@ -559,7 +559,7 @@ class DialogAddAutomationElement extends LitElement implements HassDialog {
></ha-svg-icon
><ha-svg-icon slot="end" .path=${mdiPlus}></ha-svg-icon>
</ha-md-list-item>
<md-divider role="separator" tabindex="-1"></md-divider>`
<ha-divider role="separator" tabindex="-1"></ha-divider>`
: ""}
${repeat(
items,
Expand Down
24 changes: 12 additions & 12 deletions src/panels/config/automation/ha-automation-picker.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { consume } from "@lit-labs/context";
import { ResizeController } from "@lit-labs/observers/resize-controller";
import "@lrnwebcomponents/simple-tooltip/simple-tooltip";
import "@material/web/divider/divider";
import {
mdiChevronRight,
mdiCog,
Expand Down Expand Up @@ -56,6 +55,7 @@ import type {
} from "../../../components/data-table/ha-data-table";
import "../../../components/data-table/ha-data-table-labels";
import "../../../components/entity/ha-entity-toggle";
import "../../../components/ha-divider";
import "../../../components/ha-fab";
import "../../../components/ha-filter-blueprints";
import "../../../components/ha-filter-categories";
Expand All @@ -65,10 +65,10 @@ import "../../../components/ha-filter-floor-areas";
import "../../../components/ha-filter-labels";
import "../../../components/ha-icon-button";
import "../../../components/ha-icon-overflow-menu";
import "../../../components/ha-menu";
import type { HaMenu } from "../../../components/ha-menu";
import "../../../components/ha-md-menu-item";
import type { HaMdMenuItem } from "../../../components/ha-md-menu-item";
import "../../../components/ha-menu";
import type { HaMenu } from "../../../components/ha-menu";
import "../../../components/ha-sub-menu";
import "../../../components/ha-svg-icon";
import { createAreaRegistryEntry } from "../../../data/area_registry";
Expand All @@ -87,6 +87,11 @@ import {
subscribeCategoryRegistry,
} from "../../../data/category_registry";
import { fullEntitiesContext } from "../../../data/context";
import {
DataTableFilters,
deserializeFilters,
serializeFilters,
} from "../../../data/data_table_filters";
import { UNAVAILABLE } from "../../../data/entity";
import {
EntityRegistryEntry,
Expand Down Expand Up @@ -115,11 +120,6 @@ import { showCategoryRegistryDetailDialog } from "../category/show-dialog-catego
import { configSections } from "../ha-panel-config";
import { showLabelDetailDialog } from "../labels/show-dialog-label-detail";
import { showNewAutomationDialog } from "./show-dialog-new-automation";
import {
DataTableFilters,
deserializeFilters,
serializeFilters,
} from "../../../data/data_table_filters";

type AutomationItem = AutomationEntity & {
name: string;
Expand Down Expand Up @@ -420,7 +420,7 @@ class HaAutomationPicker extends SubscribeMixin(LitElement) {
)}
</div>
</ha-md-menu-item>
<md-divider role="separator" tabindex="-1"></md-divider>
<ha-divider role="separator" tabindex="-1"></ha-divider>
<ha-md-menu-item @click=${this._bulkCreateCategory}>
<div slot="headline">
${this.hass.localize("ui.panel.config.category.editor.add")}
Expand Down Expand Up @@ -457,7 +457,7 @@ class HaAutomationPicker extends SubscribeMixin(LitElement) {
</ha-label>
</ha-md-menu-item>`;
})}
<md-divider role="separator" tabindex="-1"></md-divider>
<ha-divider role="separator" tabindex="-1"></ha-divider>
<ha-md-menu-item @click=${this._bulkCreateLabel}>
<div slot="headline">
${this.hass.localize("ui.panel.config.labels.add_label")}
Expand Down Expand Up @@ -486,7 +486,7 @@ class HaAutomationPicker extends SubscribeMixin(LitElement) {
)}
</div>
</ha-md-menu-item>
<md-divider role="separator" tabindex="-1"></md-divider>
<ha-divider role="separator" tabindex="-1"></ha-divider>
<ha-md-menu-item @click=${this._bulkCreateArea}>
<div slot="headline">
${this.hass.localize(
Expand Down Expand Up @@ -867,7 +867,7 @@ class HaAutomationPicker extends SubscribeMixin(LitElement) {
)}
</div>
</ha-md-menu-item>
<md-divider role="separator" tabindex="-1"></md-divider>
<ha-divider role="separator" tabindex="-1"></ha-divider>
<ha-md-menu-item .clickAction=${this._duplicate}>
<ha-svg-icon .path=${mdiContentDuplicate} slot="start"></ha-svg-icon>
<div slot="headline">
Expand Down
5 changes: 3 additions & 2 deletions src/panels/config/devices/ha-config-devices-dashboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ import "../../../components/entity/ha-battery-icon";
import "../../../components/ha-alert";
import "../../../components/ha-button-menu";
import "../../../components/ha-check-list-item";
import "../../../components/ha-divider";
import "../../../components/ha-fab";
import "../../../components/ha-filter-devices";
import "../../../components/ha-filter-floor-areas";
Expand Down Expand Up @@ -649,7 +650,7 @@ export class HaConfigDeviceDashboard extends SubscribeMixin(LitElement) {
)}
</div>
</ha-md-menu-item>
<md-divider role="separator" tabindex="-1"></md-divider>
<ha-divider role="separator" tabindex="-1"></ha-divider>
<ha-md-menu-item @click=${this._bulkCreateArea}>
<div slot="headline">
${this.hass.localize(
Expand Down Expand Up @@ -688,7 +689,7 @@ export class HaConfigDeviceDashboard extends SubscribeMixin(LitElement) {
</ha-label>
</ha-md-menu-item>`;
})}
<md-divider role="separator" tabindex="-1"></md-divider>
<ha-divider role="separator" tabindex="-1"></ha-divider>
<ha-md-menu-item @click=${this._bulkCreateLabel}>
<div slot="headline">
${this.hass.localize("ui.panel.config.labels.add_label")}
Expand Down
19 changes: 10 additions & 9 deletions src/panels/config/entities/ha-config-entities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import { ifDefined } from "lit/directives/if-defined";
import { styleMap } from "lit/directives/style-map";
import memoize from "memoize-one";
import { computeCssColor } from "../../../common/color/compute-color";
import { formatShortDateTime } from "../../../common/datetime/format_date_time";
import { storage } from "../../../common/decorators/storage";
import type { HASSDomEvent } from "../../../common/dom/fire_event";
import { computeDomain } from "../../../common/entity/compute_domain";
Expand All @@ -52,6 +53,7 @@ import "../../../components/data-table/ha-data-table-labels";
import "../../../components/ha-alert";
import "../../../components/ha-button-menu";
import "../../../components/ha-check-list-item";
import "../../../components/ha-divider";
import "../../../components/ha-filter-devices";
import "../../../components/ha-filter-domains";
import "../../../components/ha-filter-floor-areas";
Expand All @@ -65,6 +67,10 @@ import "../../../components/ha-sub-menu";
import "../../../components/ha-svg-icon";
import { ConfigEntry, getConfigEntries } from "../../../data/config_entries";
import { fullEntitiesContext } from "../../../data/context";
import {
DataTableFiltersItems,
DataTableFiltersValues,
} from "../../../data/data_table_filters";
import { UNAVAILABLE } from "../../../data/entity";
import {
EntityRegistryEntry,
Expand Down Expand Up @@ -98,11 +104,6 @@ import { configSections } from "../ha-panel-config";
import "../integrations/ha-integration-overflow-menu";
import { showAddIntegrationDialog } from "../integrations/show-add-integration-dialog";
import { showLabelDetailDialog } from "../labels/show-dialog-label-detail";
import {
DataTableFiltersValues,
DataTableFiltersItems,
} from "../../../data/data_table_filters";
import { formatShortDateTime } from "../../../common/datetime/format_date_time";

export interface StateEntity
extends Omit<EntityRegistryEntry, "id" | "unique_id"> {
Expand Down Expand Up @@ -720,7 +721,7 @@ export class HaConfigEntities extends SubscribeMixin(LitElement) {
</ha-label>
</ha-md-menu-item>`;
})}
<md-divider role="separator" tabindex="-1"></md-divider>
<ha-divider role="separator" tabindex="-1"></ha-divider>
<ha-md-menu-item @click=${this._bulkCreateLabel}>
<div slot="headline">
${this.hass.localize("ui.panel.config.labels.add_label")}
Expand Down Expand Up @@ -830,7 +831,7 @@ ${
</ha-md-menu-item>
<ha-menu slot="menu">${labelItems}</ha-menu>
</ha-sub-menu>
<md-divider role="separator" tabindex="-1"></md-divider>`
<ha-divider role="separator" tabindex="-1"></ha-divider>`
: nothing
}

Expand All @@ -853,7 +854,7 @@ ${
)}
</div>
</ha-md-menu-item>
<md-divider role="separator" tabindex="-1"></md-divider>
<ha-divider role="separator" tabindex="-1"></ha-divider>

<ha-md-menu-item @click=${this._unhideSelected}>
<ha-svg-icon
Expand All @@ -877,7 +878,7 @@ ${
)}
</div>
</ha-md-menu-item>
<md-divider role="separator" tabindex="-1"></md-divider>
<ha-divider role="separator" tabindex="-1"></ha-divider>

<ha-md-menu-item @click=${this._removeSelected} class="warning">
<ha-svg-icon
Expand Down
17 changes: 9 additions & 8 deletions src/panels/config/helpers/ha-config-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import {
SortingChangedEvent,
} from "../../../components/data-table/ha-data-table";
import "../../../components/data-table/ha-data-table-labels";
import "../../../components/ha-divider";
import "../../../components/ha-fab";
import "../../../components/ha-filter-categories";
import "../../../components/ha-filter-devices";
Expand All @@ -65,12 +66,18 @@ import {
} from "../../../data/config_entries";
import { getConfigFlowHandlers } from "../../../data/config_flow";
import { fullEntitiesContext } from "../../../data/context";
import {
DataTableFilters,
deserializeFilters,
serializeFilters,
} from "../../../data/data_table_filters";
import {
EntityRegistryEntry,
UpdateEntityRegistryEntryResult,
subscribeEntityRegistry,
updateEntityRegistryEntry,
} from "../../../data/entity_registry";
import { fetchEntitySourcesWithCache } from "../../../data/entity_sources";
import {
IntegrationManifest,
domainToName,
Expand Down Expand Up @@ -101,12 +108,6 @@ import "../integrations/ha-integration-overflow-menu";
import { showLabelDetailDialog } from "../labels/show-dialog-label-detail";
import { isHelperDomain } from "./const";
import { showHelperDetailDialog } from "./show-dialog-helper-detail";
import {
serializeFilters,
deserializeFilters,
DataTableFilters,
} from "../../../data/data_table_filters";
import { fetchEntitySourcesWithCache } from "../../../data/entity_sources";

type HelperItem = {
id: string;
Expand Down Expand Up @@ -496,7 +497,7 @@ export class HaConfigHelpers extends SubscribeMixin(LitElement) {
)}
</div>
</ha-md-menu-item>
<md-divider role="separator" tabindex="-1"></md-divider>
<ha-divider role="separator" tabindex="-1"></ha-divider>
<ha-md-menu-item @click=${this._bulkCreateCategory}>
<div slot="headline">
${this.hass.localize("ui.panel.config.category.editor.add")}
Expand Down Expand Up @@ -531,7 +532,7 @@ export class HaConfigHelpers extends SubscribeMixin(LitElement) {
${label.name}
</ha-label>
</ha-md-menu-item> `;
})}<md-divider role="separator" tabindex="-1"></md-divider>
})}<ha-divider role="separator" tabindex="-1"></ha-divider>
<ha-md-menu-item @click=${this._bulkCreateLabel}>
<div slot="headline">
${this.hass.localize("ui.panel.config.labels.add_label")}
Expand Down
Loading
Loading