diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/button/action-button-widget.component.html b/ui-ngx/src/app/modules/home/components/widget/lib/button/action-button-widget.component.html index f667e63356..02e2406859 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/button/action-button-widget.component.html +++ b/ui-ngx/src/app/modules/home/components/widget/lib/button/action-button-widget.component.html @@ -24,6 +24,7 @@ [borderRadius]="borderRadius" [disabled]="disabled" [activated]="activated" + [ctx]="ctx" (clicked)="onClick($event)">
diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/button/command-button-widget.component.html b/ui-ngx/src/app/modules/home/components/widget/lib/button/command-button-widget.component.html index eaf93c2498..a6f01edb67 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/button/command-button-widget.component.html +++ b/ui-ngx/src/app/modules/home/components/widget/lib/button/command-button-widget.component.html @@ -23,6 +23,7 @@ [appearance]="appearance" [borderRadius]="borderRadius" [disabled]="disabled" + [ctx]="ctx" (clicked)="onClick($event)">
diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/settings/common/button/widget-button-custom-style-panel.component.html b/ui-ngx/src/app/modules/home/components/widget/lib/settings/common/button/widget-button-custom-style-panel.component.html index 7e4a316eef..e5750fd4bb 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/settings/common/button/widget-button-custom-style-panel.component.html +++ b/ui-ngx/src/app/modules/home/components/widget/lib/settings/common/button/widget-button-custom-style-panel.component.html @@ -48,6 +48,7 @@ widgets.button.preview
; + @Input() - popover: TbPopoverComponent; + set popover(popover: TbPopoverComponent) { + this.popoverValue = popover; + popover.tbAnimationDone.subscribe(() => { + this.widgetButtonPreview?.validateSize(); + }); + } + + get popover(): TbPopoverComponent { + return this.popoverValue; + } @Output() customStyleApplied = new EventEmitter(); @@ -125,7 +149,7 @@ export class WidgetButtonCustomStylePanelComponent extends PageComponent impleme if (customStyle?.overrideBackgroundColor) { backgroundColor = customStyle?.backgroundColor; } - let dropShadow = this.appearance.type === WidgetButtonType.basic ? false : true; + let dropShadow = this.appearance.type !== WidgetButtonType.basic; if (customStyle?.overrideDropShadow) { dropShadow = customStyle?.dropShadow; } diff --git a/ui-ngx/src/app/shared/components/button/widget-button.component.html b/ui-ngx/src/app/shared/components/button/widget-button.component.html index 9b239db068..03b5dfb75a 100644 --- a/ui-ngx/src/app/shared/components/button/widget-button.component.html +++ b/ui-ngx/src/app/shared/components/button/widget-button.component.html @@ -34,6 +34,6 @@ [style.pointer-events]="disableEvents ? 'none' : ''">
{{ appearance.icon }} - {{ appearance.label }} + {{ label$ | async }}
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 d8fe88b48e..059f263196 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 @@ -25,7 +25,8 @@ import { OnInit, Output, Renderer2, - SimpleChanges, ViewChild, + SimpleChanges, + ViewChild, ViewEncapsulation } from '@angular/core'; import { @@ -36,6 +37,8 @@ import { coerceBoolean } from '@shared/decorators/coercion'; import { ComponentStyle, iconStyle } 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'; const initialButtonHeight = 60; const horizontalLayoutPadding = 24; @@ -81,9 +84,14 @@ export class WidgetButtonComponent implements OnInit, AfterViewInit, OnDestroy, @coerceBoolean() disableEvents = false; + @Input() + ctx: WidgetContext; + @Output() clicked = new EventEmitter(); + label$: Observable; + iconStyle: ComponentStyle = {}; mousePressed = false; @@ -122,11 +130,20 @@ export class WidgetButtonComponent implements OnInit, AfterViewInit, OnDestroy, this.clearAppearanceCss(); } + public validateSize() { + if (this.appearance.autoScale && this.widgetButton.nativeElement) { + this.onResize(); + } + } + private updateAppearance(): void { this.clearAppearanceCss(); if (this.appearance.showIcon) { this.iconStyle = iconStyle(this.appearance.iconSize, this.appearance.iconSizeUnit); } + if (this.appearance.showLabel) { + this.label$ = this.ctx ? this.ctx.registerLabelPattern(this.appearance.label, this.label$) : of(this.appearance.label); + } const appearanceCss = generateWidgetButtonAppearanceCss(this.appearance); this.appearanceCssClass = this.utils.applyCssToElement(this.renderer, this.elementRef.nativeElement, 'tb-widget-button', appearanceCss);