100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps
Java asset-managementbuildingdashboarddataplatformdevice-managementedge-computingenergyenergy-managementenergy-monitorfleet-managementfleet-telematicsiotiot-applicationiot-platformmodbusmqttmqtt-brokerota-updaterules-enginesmartcity
/*
* Copyright 2026, OpenRemote Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
import { css, html, type TemplateResult } from "lit";
import { OrElement } from "@openremote/or-element";
import { customElement, property } from "lit/decorators.js";
import { until } from "lit/directives/until.js";
import { when } from "lit/directives/when.js";
import { classMap } from "lit/directives/class-map.js";
import { style } from "../style";
const styling = css`
:host {
height: auto !important;
}
#panel-wrapper {
border-bottom: 1px solid #e0e0e0;
}
#panel-header {
display: flex;
align-items: center;
cursor: pointer;
padding: 12px;
gap: 8px;
}
#panel-title {
line-height: 100%;
font-weight: 700;
}
.panel-content {
padding: 0 16px;
max-height: 0;
overflow: hidden;
transition:
max-height 0.2s cubic-bezier(0.4, 0, 0.2, 1) 0s,
visibility 0s 0.2s; /* expanded -> collapsed */
}
.panel-content--expanded {
max-height: 100vh;
overflow: visible;
transition: max-height 0.25s cubic-bezier(0.4, 0, 0.2, 1) 0s; /* collapsed -> expanded */
}
`;
@customElement("settings-panel")
export class SettingsPanel extends OrElement {
@property({ type: Boolean })
public expanded = false;
@property()
protected displayName?: string;
static get styles() {
return [styling, style];
}
protected render(): TemplateResult {
const contentClasses = {
"panel-content": true,
"panel-content--expanded": this.expanded,
};
return html`
<div id="panel-wrapper">
${until(this.generateHeader(this.expanded, this.displayName), html``)}
<div class="${classMap(contentClasses)}">
<div style="padding-bottom: 16px;">
<slot></slot>
</div>
</div>
</div>
`;
}
public toggle(state?: boolean) {
this.expanded = state || !this.expanded;
}
protected async generateHeader(expanded: boolean, title?: string): Promise<TemplateResult> {
return html`
<div id="panel-header" @click="${() => this.toggle()}">
<div id="panel-chevron">
<or-icon icon="${expanded ? "chevron-down" : "chevron-right"}"></or-icon>
</div>
${when(
title,
() => html`
<div id="panel-title">
<span><or-translate value="${this.displayName}"></or-translate></span>
</div>
`
)}
</div>
`;
}
}