diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/rpc/single-switch-widget.component.ts b/ui-ngx/src/app/modules/home/components/widget/lib/rpc/single-switch-widget.component.ts
index 2c15634893..5bfede43f2 100644
--- a/ui-ngx/src/app/modules/home/components/widget/lib/rpc/single-switch-widget.component.ts
+++ b/ui-ngx/src/app/modules/home/components/widget/lib/rpc/single-switch-widget.component.ts
@@ -35,7 +35,7 @@ import {
backgroundStyle,
ComponentStyle,
iconStyle,
- overlayStyle,
+ overlayStyle, resolveCssSize,
textStyle
} from '@shared/models/widget-settings.models';
import { Observable } from 'rxjs';
@@ -74,6 +74,7 @@ export class SingleSwitchWidgetComponent extends
backgroundStyle$: Observable;
overlayStyle: ComponentStyle = {};
+ padding: string;
overlayInset = '12px';
value = false;
@@ -123,6 +124,7 @@ export class SingleSwitchWidgetComponent extends
this.backgroundStyle$ = backgroundStyle(this.settings.background, this.imagePipe, this.sanitizer);
this.overlayStyle = overlayStyle(this.settings.background.overlay);
+ this.padding = this.settings.background.overlay.enabled ? undefined : this.settings.padding;
this.layout = this.settings.layout;
@@ -234,8 +236,16 @@ export class SingleSwitchWidgetComponent extends
const height = this.singleSwitchPanel.nativeElement.getBoundingClientRect().height;
const switchScale = height / initialSwitchHeight;
const paddingScale = Math.min(switchScale, 1);
- const panelWidth = this.singleSwitchPanel.nativeElement.getBoundingClientRect().width - (horizontalLayoutPadding * paddingScale);
- const panelHeight = this.singleSwitchPanel.nativeElement.getBoundingClientRect().height - (verticalLayoutPadding * paddingScale);
+ const paddingLeft = getComputedStyle(this.singleSwitchPanel.nativeElement).paddingLeft;
+ const paddingRight = getComputedStyle(this.singleSwitchPanel.nativeElement).paddingRight;
+ const paddingTop = getComputedStyle(this.singleSwitchPanel.nativeElement).paddingTop;
+ const paddingBottom = getComputedStyle(this.singleSwitchPanel.nativeElement).paddingBottom;
+ const pLeft = resolveCssSize(paddingLeft)[0];
+ const pRight = resolveCssSize(paddingRight)[0];
+ const pTop = resolveCssSize(paddingTop)[0];
+ const pBottom = resolveCssSize(paddingBottom)[0];
+ const panelWidth = this.singleSwitchPanel.nativeElement.getBoundingClientRect().width - (pLeft + pRight);
+ const panelHeight = this.singleSwitchPanel.nativeElement.getBoundingClientRect().height - (pTop + pBottom);
this.renderer.setStyle(this.singleSwitchContent.nativeElement, 'transform', `scale(1)`);
this.renderer.setStyle(this.singleSwitchContent.nativeElement, 'width', 'auto');
let contentWidth = this.singleSwitchToggleRow.nativeElement.getBoundingClientRect().width;
diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/rpc/single-switch-widget.models.ts b/ui-ngx/src/app/modules/home/components/widget/lib/rpc/single-switch-widget.models.ts
index 94586c31de..2fe9ab0d96 100644
--- a/ui-ngx/src/app/modules/home/components/widget/lib/rpc/single-switch-widget.models.ts
+++ b/ui-ngx/src/app/modules/home/components/widget/lib/rpc/single-switch-widget.models.ts
@@ -80,6 +80,7 @@ export interface SingleSwitchWidgetSettings {
offLabelFont: Font;
offLabelColor: string;
background: BackgroundSettings;
+ padding: string;
}
export const singleSwitchDefaultSettings: SingleSwitchWidgetSettings = {
@@ -217,5 +218,6 @@ export const singleSwitchDefaultSettings: SingleSwitchWidgetSettings = {
color: 'rgba(255,255,255,0.72)',
blur: 3
}
- }
+ },
+ padding: '12px'
};
diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/settings/cards/value-card-widget-settings.component.html b/ui-ngx/src/app/modules/home/components/widget/lib/settings/cards/value-card-widget-settings.component.html
index 76f46862a6..5077c93d8e 100644
--- a/ui-ngx/src/app/modules/home/components/widget/lib/settings/cards/value-card-widget-settings.component.html
+++ b/ui-ngx/src/app/modules/home/components/widget/lib/settings/cards/value-card-widget-settings.component.html
@@ -93,5 +93,11 @@
+
diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/settings/cards/value-card-widget-settings.component.ts b/ui-ngx/src/app/modules/home/components/widget/lib/settings/cards/value-card-widget-settings.component.ts
index 9693ca22d4..be7794802c 100644
--- a/ui-ngx/src/app/modules/home/components/widget/lib/settings/cards/value-card-widget-settings.component.ts
+++ b/ui-ngx/src/app/modules/home/components/widget/lib/settings/cards/value-card-widget-settings.component.ts
@@ -110,7 +110,8 @@ export class ValueCardWidgetSettingsComponent extends WidgetSettingsComponent {
dateFont: [settings.dateFont, []],
dateColor: [settings.dateColor, []],
- background: [settings.background, []]
+ background: [settings.background, []],
+ padding: [settings.padding, []]
});
}
diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/settings/control/single-switch-widget-settings.component.html b/ui-ngx/src/app/modules/home/components/widget/lib/settings/control/single-switch-widget-settings.component.html
index db6d0371f9..2709266f2f 100644
--- a/ui-ngx/src/app/modules/home/components/widget/lib/settings/control/single-switch-widget-settings.component.html
+++ b/ui-ngx/src/app/modules/home/components/widget/lib/settings/control/single-switch-widget-settings.component.html
@@ -123,6 +123,12 @@