mirror of
https://github.com/home-assistant/frontend.git
synced 2026-11-30 16:49:04 +00:00
Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
22969613f3 | ||
|
|
889f826009 |
No files matched your search
@@ -1939,6 +1939,10 @@ export class HaCodeEditor extends ReactiveElement {
|
||||
padding-top: var(--code-editor-toolbar-height);
|
||||
}
|
||||
|
||||
:host(.fullscreen) {
|
||||
--code-mirror-min-height: 100%;
|
||||
}
|
||||
|
||||
:host(.fullscreen) .cm-editor {
|
||||
height: 100% !important;
|
||||
max-height: 100% !important;
|
||||
|
||||
@@ -8,6 +8,7 @@ import deepFreeze from "deep-freeze";
|
||||
import type { CSSResultGroup, PropertyValues } from "lit";
|
||||
import { css, html, LitElement, nothing } from "lit";
|
||||
import { customElement, property, query, state } from "lit/decorators";
|
||||
import { classMap } from "lit/directives/class-map";
|
||||
import type { HASSDomEvent } from "../../../../common/dom/fire_event";
|
||||
import { fireEvent } from "../../../../common/dom/fire_event";
|
||||
import { ctrlOrCmdLabel } from "../../../../common/keyboard/ctrl-or-cmd";
|
||||
@@ -75,6 +76,8 @@ export class HuiDialogEditBadge
|
||||
|
||||
@state() private _animateWidth = false;
|
||||
|
||||
private _largeBeforeCodeEditor = false;
|
||||
|
||||
@state() private _badgeConfig?: LovelaceBadgeConfig;
|
||||
|
||||
@state() private _saving = false;
|
||||
@@ -99,6 +102,7 @@ export class HuiDialogEditBadge
|
||||
this._badgeConfig = params.badgeConfig;
|
||||
|
||||
this.large = false;
|
||||
this._animateWidth = false;
|
||||
if (this._badgeConfig && !Object.isFrozen(this._badgeConfig)) {
|
||||
this._badgeConfig = deepFreeze(this._badgeConfig);
|
||||
}
|
||||
@@ -202,7 +206,10 @@ export class HuiDialogEditBadge
|
||||
.open=${this._open}
|
||||
.accessibleLabel=${heading}
|
||||
.width=${this.large ? "full" : "large"}
|
||||
class=${this._animateWidth ? "animate-width" : ""}
|
||||
class=${classMap({
|
||||
"animate-width": this._animateWidth,
|
||||
"yaml-mode": !this._GUImode,
|
||||
})}
|
||||
@dialog-set-fullscreen=${this._stopWidthAnimation}
|
||||
.preventScrimClose=${this.isEffectiveDirtyState}
|
||||
@keydown=${this._ignoreKeydown}
|
||||
@@ -345,11 +352,21 @@ export class HuiDialogEditBadge
|
||||
|
||||
private _handleGUIModeChanged(ev: HASSDomEvent<GUIModeChangedEvent>): void {
|
||||
ev.stopPropagation();
|
||||
// Fired again on every error while staying in the same mode
|
||||
if (ev.detail.guiMode !== this._GUImode) {
|
||||
if (ev.detail.guiMode) {
|
||||
this.large = this._largeBeforeCodeEditor;
|
||||
} else {
|
||||
this._largeBeforeCodeEditor = this.large;
|
||||
this.large = true;
|
||||
}
|
||||
}
|
||||
this._GUImode = ev.detail.guiMode;
|
||||
this._guiModeAvailable = ev.detail.guiModeAvailable;
|
||||
}
|
||||
|
||||
private _toggleMode(): void {
|
||||
this._animateWidth = true;
|
||||
withViewTransition(() => {
|
||||
this._badgeEditorEl?.toggleMode();
|
||||
});
|
||||
@@ -513,6 +530,17 @@ export class HuiDialogEditBadge
|
||||
ha-dialog ha-icon-button[slot="headerActionItems"] {
|
||||
color: var(--secondary-text-color);
|
||||
}
|
||||
@supports (min-height: min(1px, 2px)) {
|
||||
@media (min-width: 1000px) {
|
||||
ha-dialog.yaml-mode {
|
||||
/* Minus the toolbar of the code editor */
|
||||
--code-mirror-min-height: min(
|
||||
500px,
|
||||
var(--code-mirror-max-height, 100vh) - 28px
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
ha-dialog.animate-width {
|
||||
--ha-dialog-width-transition:
|
||||
min-width var(--ha-animation-duration-normal) ease-out,
|
||||
|
||||
@@ -8,6 +8,7 @@ import deepFreeze from "deep-freeze";
|
||||
import type { CSSResultGroup, PropertyValues } from "lit";
|
||||
import { LitElement, css, html, nothing } from "lit";
|
||||
import { customElement, property, query, state } from "lit/decorators";
|
||||
import { classMap } from "lit/directives/class-map";
|
||||
import memoizeOne from "memoize-one";
|
||||
import type { HASSDomEvent } from "../../../../common/dom/fire_event";
|
||||
import { fireEvent } from "../../../../common/dom/fire_event";
|
||||
@@ -83,6 +84,8 @@ export class HuiDialogEditCard
|
||||
|
||||
@state() private _animateWidth = false;
|
||||
|
||||
private _largeBeforeCodeEditor = false;
|
||||
|
||||
@state() private _cardConfig?: LovelaceCardConfig;
|
||||
|
||||
@state() private _sectionConfig?: LovelaceSectionConfig;
|
||||
@@ -111,6 +114,7 @@ export class HuiDialogEditCard
|
||||
this._cardConfig = params.cardConfig;
|
||||
|
||||
this.large = false;
|
||||
this._animateWidth = false;
|
||||
if (this._cardConfig && !Object.isFrozen(this._cardConfig)) {
|
||||
this._cardConfig = deepFreeze(this._cardConfig);
|
||||
}
|
||||
@@ -214,7 +218,10 @@ export class HuiDialogEditCard
|
||||
.open=${this._open}
|
||||
.accessibleLabel=${heading}
|
||||
.width=${this.large ? "full" : "large"}
|
||||
class=${this._animateWidth ? "animate-width" : ""}
|
||||
class=${classMap({
|
||||
"animate-width": this._animateWidth,
|
||||
"yaml-mode": !this._GUImode,
|
||||
})}
|
||||
@dialog-set-fullscreen=${this._stopWidthAnimation}
|
||||
.preventScrimClose=${this.isEffectiveDirtyState}
|
||||
@keydown=${this._ignoreKeydown}
|
||||
@@ -371,11 +378,21 @@ export class HuiDialogEditCard
|
||||
|
||||
private _handleGUIModeChanged(ev: HASSDomEvent<GUIModeChangedEvent>): void {
|
||||
ev.stopPropagation();
|
||||
// Fired again on every error while staying in the same mode
|
||||
if (ev.detail.guiMode !== this._GUImode) {
|
||||
if (ev.detail.guiMode) {
|
||||
this.large = this._largeBeforeCodeEditor;
|
||||
} else {
|
||||
this._largeBeforeCodeEditor = this.large;
|
||||
this.large = true;
|
||||
}
|
||||
}
|
||||
this._GUImode = ev.detail.guiMode;
|
||||
this._guiModeAvailable = ev.detail.guiModeAvailable;
|
||||
}
|
||||
|
||||
private _toggleMode(): void {
|
||||
this._animateWidth = true;
|
||||
withViewTransition(() => {
|
||||
this._cardEditorEl?.toggleMode();
|
||||
});
|
||||
@@ -595,6 +612,17 @@ export class HuiDialogEditCard
|
||||
ha-dialog ha-icon-button[slot="headerActionItems"] {
|
||||
color: var(--secondary-text-color);
|
||||
}
|
||||
@supports (min-height: min(1px, 2px)) {
|
||||
@media (min-width: 1000px) {
|
||||
ha-dialog.yaml-mode {
|
||||
/* Minus the toolbar of the code editor */
|
||||
--code-mirror-min-height: min(
|
||||
500px,
|
||||
var(--code-mirror-max-height, 100vh) - 28px
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
ha-dialog.animate-width {
|
||||
--ha-dialog-width-transition:
|
||||
min-width var(--ha-animation-duration-normal) ease-out,
|
||||
|
||||
@@ -264,8 +264,11 @@ export class HuiDialogEditSection
|
||||
<ha-dialog
|
||||
.open=${this._open}
|
||||
.accessibleLabel=${heading}
|
||||
width="large"
|
||||
class=${this._animateWidth ? "animate-width" : ""}
|
||||
.width=${this._yamlMode ? "full" : "large"}
|
||||
class=${classMap({
|
||||
"animate-width": this._animateWidth,
|
||||
"yaml-mode": this._yamlMode,
|
||||
})}
|
||||
style=${styleMap({ "--preview-column-span": previewColumnSpan })}
|
||||
@dialog-set-fullscreen=${this._stopWidthAnimation}
|
||||
.preventScrimClose=${this.isDirtyState}
|
||||
@@ -529,6 +532,7 @@ export class HuiDialogEditSection
|
||||
|
||||
private async _toggleMode(): Promise<void> {
|
||||
if (this._yamlMode && this._yamlError) return;
|
||||
this._animateWidth = true;
|
||||
await withViewTransition(() => {
|
||||
this._yamlMode = !this._yamlMode;
|
||||
});
|
||||
@@ -750,6 +754,17 @@ export class HuiDialogEditSection
|
||||
);
|
||||
}
|
||||
|
||||
@supports (min-height: min(1px, 2px)) {
|
||||
@media (min-width: 1000px) {
|
||||
ha-dialog.yaml-mode {
|
||||
/* Minus the toolbar of the code editor */
|
||||
--code-mirror-min-height: min(
|
||||
500px,
|
||||
var(--code-mirror-max-height, 100vh) - 28px
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
ha-dialog.animate-width {
|
||||
--ha-dialog-width-transition:
|
||||
min-width var(--ha-animation-duration-normal) ease-out,
|
||||
@@ -836,10 +851,11 @@ export class HuiDialogEditSection
|
||||
@media (min-width: 1000px) {
|
||||
ha-dialog {
|
||||
--editor-column-width: 520px;
|
||||
/* Plus the paddings of the preview and the dialog */
|
||||
/* Plus the paddings of the preview */
|
||||
--preview-column-total-width: calc(var(--preview-width) + 28px);
|
||||
--ha-dialog-width-lg: calc(
|
||||
var(--editor-column-width) + var(--preview-width) + 28px + 2 *
|
||||
var(--dialog-content-padding)
|
||||
var(--editor-column-width) + var(--preview-column-total-width) +
|
||||
2 * var(--dialog-content-padding)
|
||||
);
|
||||
}
|
||||
.content {
|
||||
@@ -854,6 +870,13 @@ export class HuiDialogEditSection
|
||||
.content > .element-preview {
|
||||
flex: 1 1 0;
|
||||
}
|
||||
ha-dialog.yaml-mode .content > .element-editor {
|
||||
flex: 1 0 var(--editor-column-width);
|
||||
}
|
||||
ha-dialog.yaml-mode .content > .element-preview {
|
||||
box-sizing: border-box;
|
||||
flex: 0 1 var(--preview-column-total-width);
|
||||
}
|
||||
.content > .element-editor,
|
||||
.content > .element-preview {
|
||||
min-width: 0;
|
||||
|
||||
@@ -90,6 +90,8 @@ export class HuiDialogEditView extends DirtyStateProviderMixin<LovelaceViewConfi
|
||||
|
||||
@state() private _open = false;
|
||||
|
||||
@state() private _animateWidth = false;
|
||||
|
||||
get _type(): string {
|
||||
return getViewType(this._config);
|
||||
}
|
||||
@@ -136,6 +138,7 @@ export class HuiDialogEditView extends DirtyStateProviderMixin<LovelaceViewConfi
|
||||
this._params = undefined;
|
||||
this._config = {};
|
||||
this._yamlMode = false;
|
||||
this._animateWidth = false;
|
||||
this._currTab = TABS[0];
|
||||
fireEvent(this, "dialog-closed", { dialog: this.localName });
|
||||
}
|
||||
@@ -210,10 +213,12 @@ export class HuiDialogEditView extends DirtyStateProviderMixin<LovelaceViewConfi
|
||||
<ha-dialog
|
||||
.open=${this._open}
|
||||
.accessibleLabel=${this._viewConfigTitle}
|
||||
width="large"
|
||||
.width=${this._yamlMode ? "full" : "large"}
|
||||
.preventScrimClose=${this.isDirtyState}
|
||||
@closed=${this._dialogClosed}
|
||||
@dialog-set-fullscreen=${this._stopWidthAnimation}
|
||||
class=${classMap({
|
||||
"animate-width": this._animateWidth,
|
||||
"yaml-mode": this._yamlMode,
|
||||
})}
|
||||
>
|
||||
@@ -365,7 +370,13 @@ export class HuiDialogEditView extends DirtyStateProviderMixin<LovelaceViewConfi
|
||||
}
|
||||
}
|
||||
|
||||
// The code editor's fullscreen changes the height at once, so the width must not lag behind
|
||||
private _stopWidthAnimation() {
|
||||
this._animateWidth = false;
|
||||
}
|
||||
|
||||
private async _toggleMode() {
|
||||
this._animateWidth = true;
|
||||
this._yamlMode = !this._yamlMode;
|
||||
if (this._yamlMode) {
|
||||
await this.updateComplete;
|
||||
@@ -680,6 +691,29 @@ export class HuiDialogEditView extends DirtyStateProviderMixin<LovelaceViewConfi
|
||||
ha-dialog.yaml-mode {
|
||||
--dialog-content-padding: 0;
|
||||
}
|
||||
@media (min-width: 1000px) {
|
||||
ha-dialog.yaml-mode {
|
||||
/* 80px - margin of the dialog
|
||||
137px - header and footer */
|
||||
--code-mirror-max-height: calc(100vh - 217px);
|
||||
}
|
||||
}
|
||||
@supports (min-height: min(1px, 2px)) {
|
||||
@media (min-width: 1000px) {
|
||||
ha-dialog.yaml-mode {
|
||||
/* Minus the toolbar of the code editor */
|
||||
--code-mirror-min-height: min(
|
||||
500px,
|
||||
var(--code-mirror-max-height, 100vh) - 28px
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
ha-dialog.animate-width {
|
||||
--ha-dialog-width-transition:
|
||||
min-width var(--ha-animation-duration-normal) ease-out,
|
||||
max-width var(--ha-animation-duration-normal) ease-out;
|
||||
}
|
||||
h2 {
|
||||
margin: 0;
|
||||
font-size: inherit;
|
||||
|
||||
@@ -305,6 +305,11 @@ export const haTheme = EditorView.theme({
|
||||
|
||||
".cm-scroller": { outline: "none" },
|
||||
|
||||
// On these instead of the editor, so that the gutter grows along
|
||||
".cm-content, .cm-gutter": {
|
||||
minHeight: "var(--code-mirror-min-height, 100%)",
|
||||
},
|
||||
|
||||
".cm-content": {
|
||||
caretColor: "var(--secondary-text-color)",
|
||||
paddingTop: "16px",
|
||||
|
||||
Reference in new issue
Block a user