{{ appearance.icon }}
diff --git a/ui-ngx/src/app/shared/components/button/widget-button.component.scss b/ui-ngx/src/app/shared/components/button/widget-button.component.scss
index a0abc95731..157f6b179a 100644
--- a/ui-ngx/src/app/shared/components/button/widget-button.component.scss
+++ b/ui-ngx/src/app/shared/components/button/widget-button.component.scss
@@ -70,7 +70,11 @@ $boxShadowColorDisabled: var(--tb-widget-button-box-shadow-color-disabled, $defa
.mat-mdc-button.mat-mdc-button-base.tb-widget-button {
width: 100%;
height: 100%;
+ min-width: 0;
padding: 8px 12px;
+ &.tb-icon-only {
+ padding: 8px;
+ }
.mdc-button__label {
width: 100%;
height: 100%;
diff --git a/ui-ngx/src/app/shared/components/button/widget-button.component.ts b/ui-ngx/src/app/shared/components/button/widget-button.component.ts
index 059f263196..db6584d96f 100644
--- a/ui-ngx/src/app/shared/components/button/widget-button.component.ts
+++ b/ui-ngx/src/app/shared/components/button/widget-button.component.ts
@@ -34,11 +34,12 @@ import {
widgetButtonDefaultAppearance
} from '@shared/components/button/widget-button.models';
import { coerceBoolean } from '@shared/decorators/coercion';
-import { ComponentStyle, iconStyle } from '@shared/models/widget-settings.models';
+import { ComponentStyle, iconStyle, validateCssSize } from '@shared/models/widget-settings.models';
import { UtilsService } from '@core/services/utils.service';
import { ResizeObserver } from '@juggle/resize-observer';
import { Observable, of } from 'rxjs';
import { WidgetContext } from '@home/models/widget-component.models';
+import { isDefinedAndNotNull, isNotEmptyStr } from '@core/utils';
const initialButtonHeight = 60;
const horizontalLayoutPadding = 24;
@@ -64,6 +65,9 @@ export class WidgetButtonComponent implements OnInit, AfterViewInit, OnDestroy,
@Input()
borderRadius = '4px';
+ @Input()
+ autoScale: boolean;
+
@Input()
@coerceBoolean()
disabled = false;
@@ -94,6 +98,8 @@ export class WidgetButtonComponent implements OnInit, AfterViewInit, OnDestroy,
iconStyle: ComponentStyle = {};
+ computedBorderRadius: string;
+
mousePressed = false;
private buttonResize$: ResizeObserver;
@@ -114,6 +120,10 @@ export class WidgetButtonComponent implements OnInit, AfterViewInit, OnDestroy,
if (!change.firstChange) {
if (propName === 'appearance') {
this.updateAppearance();
+ } else if (propName === 'borderRadius') {
+ this.updateBorderRadius();
+ } else if (propName === 'autoScale') {
+ this.updateAutoScale();
}
}
}
@@ -144,12 +154,22 @@ export class WidgetButtonComponent implements OnInit, AfterViewInit, OnDestroy,
if (this.appearance.showLabel) {
this.label$ = this.ctx ? this.ctx.registerLabelPattern(this.appearance.label, this.label$) : of(this.appearance.label);
}
+ this.updateBorderRadius();
const appearanceCss = generateWidgetButtonAppearanceCss(this.appearance);
this.appearanceCssClass = this.utils.applyCssToElement(this.renderer, this.elementRef.nativeElement,
'tb-widget-button', appearanceCss);
this.updateAutoScale();
}
+ private updateBorderRadius(): void {
+ const validatedBorderRadius = validateCssSize(this.appearance.borderRadius);
+ if (validatedBorderRadius) {
+ this.computedBorderRadius = validatedBorderRadius;
+ } else {
+ this.computedBorderRadius = this.borderRadius;
+ }
+ }
+
private clearAppearanceCss(): void {
if (this.appearanceCssClass) {
this.utils.clearCssElement(this.renderer, this.appearanceCssClass, this.elementRef?.nativeElement);
@@ -162,7 +182,8 @@ export class WidgetButtonComponent implements OnInit, AfterViewInit, OnDestroy,
this.buttonResize$.disconnect();
}
if (this.widgetButton && this.widgetButtonContent) {
- if (this.appearance.autoScale) {
+ const autoScale = isDefinedAndNotNull(this.autoScale) ? this.autoScale : this.appearance.autoScale;
+ if (autoScale) {
this.buttonResize$ = new ResizeObserver(() => {
this.onResize();
});
diff --git a/ui-ngx/src/app/shared/components/button/widget-button.models.ts b/ui-ngx/src/app/shared/components/button/widget-button.models.ts
index 34f13864a9..b81cd43f5d 100644
--- a/ui-ngx/src/app/shared/components/button/widget-button.models.ts
+++ b/ui-ngx/src/app/shared/components/button/widget-button.models.ts
@@ -98,6 +98,7 @@ export interface WidgetButtonAppearance {
icon: string;
iconSize: number;
iconSizeUnit: cssUnit;
+ borderRadius?: string;
mainColor: string;
backgroundColor: string;
customStyle: WidgetButtonCustomStyles;
diff --git a/ui-ngx/src/app/shared/models/widget-settings.models.ts b/ui-ngx/src/app/shared/models/widget-settings.models.ts
index 5bd9e26f13..8e60c0d9cb 100644
--- a/ui-ngx/src/app/shared/models/widget-settings.models.ts
+++ b/ui-ngx/src/app/shared/models/widget-settings.models.ts
@@ -21,7 +21,8 @@ import {
Datasource,
DatasourceData,
DatasourceType,
- TargetDevice, TargetDeviceType
+ TargetDevice,
+ TargetDeviceType
} from '@shared/models/widget.models';
import { Injector } from '@angular/core';
import { DatePipe } from '@angular/common';
@@ -232,6 +233,15 @@ export const resolveCssSize = (strSize?: string): [number, cssUnit] => {
return [numericSize, resolvedUnit];
};
+export const validateCssSize = (strSize?: string): string | undefined => {
+ const resolved = resolveCssSize(strSize);
+ if (!!resolved[0] && !!resolved[1]) {
+ return cssSizeToStrSize(resolved[0], resolved[1]);
+ } else {
+ return undefined;
+ }
+};
+
type ValueColorFunction = (value: any) => string;
export abstract class ColorProcessor {
diff --git a/ui-ngx/src/assets/locale/locale.constant-en_US.json b/ui-ngx/src/assets/locale/locale.constant-en_US.json
index c71f33fca7..0bc4565bf5 100644
--- a/ui-ngx/src/assets/locale/locale.constant-en_US.json
+++ b/ui-ngx/src/assets/locale/locale.constant-en_US.json
@@ -5231,6 +5231,19 @@
"disabled-colors": "Disabled colors",
"button": "Button"
},
+ "toggle-button": {
+ "behavior": "Behavior",
+ "checked": "Checked",
+ "unchecked": "Unchecked",
+ "check": "Check",
+ "check-hint": "Action performed to check the component.",
+ "uncheck": "Uncheck",
+ "uncheck-hint": "Action performed to uncheck the component.",
+ "auto-scale": "Auto scale",
+ "horizontal-fill": "Horizontal fill",
+ "vertical-fill": "Vertical fill",
+ "button-appearance": "Button appearance"
+ },
"button": {
"layout": "Layout",
"outlined": "Outlined",
@@ -5240,6 +5253,7 @@
"auto-scale": "Auto scale",
"label": "Label",
"icon": "Icon",
+ "border-radius": "Border radius",
"color-palette": "Color palette",
"main": "Main",
"background": "Background",
diff --git a/ui-ngx/src/form.scss b/ui-ngx/src/form.scss
index ab018a8bc6..524a4e86ac 100644
--- a/ui-ngx/src/form.scss
+++ b/ui-ngx/src/form.scss
@@ -651,7 +651,8 @@
&.mdc-evolution-chip--with-primary-graphic {
.mdc-evolution-chip__action--primary {
width: 100%;
- padding-right: 0;
+ padding-left: 12px;
+ padding-right: 12px;
gap: 0;
.mdc-evolution-chip__graphic {
padding: 0;