mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-26 10:46:35 +00:00
Fix some styling of ha-switch (#3842)
If content is slotted it will get some margin to the toggle like the old switch.
This commit is contained in:
parent
3cf4b890b6
commit
ea50d486da
@ -153,7 +153,6 @@ class HaEntityToggle extends LitElement {
|
||||
}
|
||||
ha-switch {
|
||||
padding: 13px 5px;
|
||||
margin: -4px -5px;
|
||||
}
|
||||
`;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Constructor, customElement, CSSResult, css } from "lit-element";
|
||||
import { Constructor, customElement, CSSResult, css, query } from "lit-element";
|
||||
import "@material/mwc-switch";
|
||||
import { style } from "@material/mwc-switch/mwc-switch-css";
|
||||
// tslint:disable-next-line
|
||||
@ -8,23 +8,37 @@ const MwcSwitch = customElements.get("mwc-switch") as Constructor<Switch>;
|
||||
|
||||
@customElement("ha-switch")
|
||||
export class HaSwitch extends MwcSwitch {
|
||||
@query("slot") private _slot!: HTMLSlotElement;
|
||||
|
||||
protected firstUpdated() {
|
||||
super.firstUpdated();
|
||||
this.style.setProperty("--mdc-theme-secondary", "var(--primary-color)");
|
||||
this.classList.toggle(
|
||||
"slotted",
|
||||
Boolean(this._slot.assignedNodes().length)
|
||||
);
|
||||
}
|
||||
|
||||
protected static get styles(): CSSResult[] {
|
||||
return [
|
||||
style,
|
||||
css`
|
||||
:host {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
}
|
||||
.mdc-switch:not(.mdc-switch--checked) .mdc-switch__thumb {
|
||||
background-color: var(--paper-toggle-button-unchecked-button-color);
|
||||
border-color: var(--paper-toggle-button-unchecked-button-color);
|
||||
}
|
||||
.mdc-switch:not(.mdc-switch--checked) .mdc-switch__track {
|
||||
background-color: var(--paper-toggle-button-unchecked-bar-color;
|
||||
background-color: var(--paper-toggle-button-unchecked-bar-color);
|
||||
border-color: var(--paper-toggle-button-unchecked-bar-color);
|
||||
}
|
||||
:host(.slotted) .mdc-switch {
|
||||
margin-right: 24px;
|
||||
}
|
||||
`,
|
||||
];
|
||||
}
|
||||
|
@ -136,9 +136,8 @@ export class CloudAlexaPref extends LitElement {
|
||||
color: var(--primary-color);
|
||||
}
|
||||
.switch {
|
||||
margin: -4px 0;
|
||||
position: absolute;
|
||||
right: 8px;
|
||||
right: 24px;
|
||||
top: 32px;
|
||||
}
|
||||
.card-actions {
|
||||
|
@ -141,9 +141,8 @@ export class CloudGooglePref extends LitElement {
|
||||
color: var(--primary-color);
|
||||
}
|
||||
.switch {
|
||||
margin: -4px 0;
|
||||
position: absolute;
|
||||
right: 8px;
|
||||
right: 24px;
|
||||
top: 32px;
|
||||
}
|
||||
ha-call-api-button {
|
||||
|
@ -121,9 +121,8 @@ export class CloudRemotePref extends LitElement {
|
||||
color: var(--primary-color);
|
||||
}
|
||||
.switch {
|
||||
margin: -4px 0;
|
||||
position: absolute;
|
||||
right: 8px;
|
||||
right: 24px;
|
||||
top: 32px;
|
||||
}
|
||||
.card-actions {
|
||||
|
@ -3,7 +3,7 @@ import { html } from "lit-element";
|
||||
export const configElementStyle = html`
|
||||
<style>
|
||||
ha-switch {
|
||||
padding-top: 16px;
|
||||
padding: 16px 0;
|
||||
}
|
||||
.side-by-side {
|
||||
display: flex;
|
||||
|
Loading…
x
Reference in New Issue
Block a user