@visual-framework/vf-button
Version:
vf-button component
51 lines (44 loc) • 1.49 kB
text/typescript
import { Component, Input, OnInit } from '@angular/core';
export class VfButtonAngularComponent implements OnInit {
/* Initialize values based on input values for button*/
theme = '';
id: string | undefined;
text = '';
style: Array<'primary' | 'secondary' | 'tertiary'> = [];
size: string | undefined;
override_class = '';
html = '';
content = '';
class = 'vf-button ';
ngOnInit(): void {
//Initialize something
}
ngOnChanges(): void {
this.setValues();
}
/* Set values as per input and updated changes */
setValues(): void {
/* Set values ass per the input */
this.content = this.html !== '' ? this.html : this.text;
this.class += this.theme !== '' ? 'vf-button--' + this.theme + ' ' : '';
/* Update class value if styles are received in input */
if(this.style.length > 0) {
this.style.forEach(style => {
this.class += 'vf-button--' + style + ' ';
});
}
/* Update class value if size is received in input */
if(this.size !== undefined) {
this.class += 'vf-button--' + this.size + ' ';
}
/* Update class value if override style received in input */
this.class += this.override_class !== '' ? '| ' + this.override_class : '';
}
}