Skip to content
Snippets Groups Projects
Commit c8d87ff9 authored by rhenck's avatar rhenck
Browse files

Refactor button component structure and re-enable event propagation

parent 3df55f54
No related branches found
No related tags found
No related merge requests found
import { Component, EventEmitter, Output } from '@angular/core';
import { Component, EventEmitter, Input, Output } from '@angular/core';
import { ElementComponent } from '../element-component.directive';
import { ButtonElement } from '../models/button-element';
@Component({
selector: 'app-button',
template: `
<div [style.display]="'flex'"
[style.width.%]="100"
[style.height.%]="100">
<button *ngIf="!elementModel.imageSrc" mat-button
[style.width.%]="100"
[style.height.%]="100"
[style.background-color]="elementModel.backgroundColor"
[style.color]="elementModel.fontColor"
[style.font-family]="elementModel.font"
[style.font-size.px]="elementModel.fontSize"
[style.font-weight]="elementModel.bold ? 'bold' : ''"
[style.font-style]="elementModel.italic ? 'italic' : ''"
[style.text-decoration]="elementModel.underline ? 'underline' : ''"
[style.border-radius.px]="elementModel.borderRadius"
(click)="onClick($event, elementModel.action)">
{{elementModel.label}}
</button>
<input *ngIf="elementModel.imageSrc" type="image"
[src]="elementModel.imageSrc | safeResourceUrl"
[class]="elementModel.dynamicPositioning? 'dynamic-image' : 'static-image'"
[alt]="'imageNotFound' | translate"
(click)="onClick($event, elementModel.action)">
</div>
<button *ngIf="!elementModel.imageSrc" mat-button
[style.width.%]="100"
[style.height.%]="100"
[style.background-color]="elementModel.backgroundColor"
[style.color]="elementModel.fontColor"
[style.font-family]="elementModel.font"
[style.font-size.px]="elementModel.fontSize"
[style.font-weight]="elementModel.bold ? 'bold' : ''"
[style.font-style]="elementModel.italic ? 'italic' : ''"
[style.text-decoration]="elementModel.underline ? 'underline' : ''"
[style.border-radius.px]="elementModel.borderRadius"
(click)="onClick($event, elementModel.action)">
{{elementModel.label}}
</button>
<input *ngIf="elementModel.imageSrc" type="image"
[src]="elementModel.imageSrc | safeResourceUrl"
[class]="elementModel.dynamicPositioning? 'dynamic-image' : 'static-image'"
[alt]="'imageNotFound' | translate"
(click)="onClick($event, elementModel.action)">
`,
styles: [
'.dynamic-image{width: 100%; height: fit-content}',
'.static-image{ width: 100%; height: 100%; object-fit: contain}'
'.dynamic-image {width: 100%; height: fit-content}',
'.static-image {width: 100%; height: 100%; object-fit: contain}'
]
})
export class ButtonComponent extends ElementComponent {
......@@ -42,7 +38,7 @@ export class ButtonComponent extends ElementComponent {
if (action) {
this.navigationRequested.emit(action);
}
event.stopPropagation();
event.preventDefault();
// event.stopPropagation();
// event.preventDefault(); TODO
};
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment