@engie-group/fluid-design-system-angular
Version:
Fluid Design System Angular
70 lines (58 loc) • 1.49 kB
text/typescript
import {CommonModule} from '@angular/common';
import {
ChangeDetectionStrategy,
ChangeDetectorRef,
Component,
ElementRef,
EventEmitter,
Input,
Output
} from '@angular/core';
import {IconComponent} from '../icon/icon.component';
({
selector: 'nj-segmented-control-button',
templateUrl: './segmented-control-button.component.html',
styleUrls: ['./segmented-control-button.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush,
standalone: true,
imports: [IconComponent, CommonModule]
})
export class SegmentedControlButtonComponent {
/**
* Segmented control button value
*/
() value: string;
/**
* Whether button is selected or notre
*/
() isSelected = false;
/**
* Whether toggle is disabled or no
*/
() isDisabled: boolean;
/**
* Whether toggle has custom icon
*/
() hasCustomIcon: boolean;
/**
* Toggle material icon name
*/
() iconName: string;
/**
* Button click output. Emits a MouseEvent
*/
() buttonClick = new EventEmitter<MouseEvent>();
constructor(private el: ElementRef, private cdr: ChangeDetectorRef) {
}
getClientBoundingRect(): DOMRect {
return this.el?.nativeElement?.getBoundingClientRect();
}
setIsSelected(isSelected: boolean) {
this.isSelected = isSelected;
this.cdr.markForCheck();
}
setIsDisabled(isDisabled: boolean) {
this.isDisabled = isDisabled;
this.cdr.markForCheck();
}
}