Skip to content

Commit

Permalink
Fixed primefaces#15226 - Button | add new input properties for pButton
Browse files Browse the repository at this point in the history
cetincakiroglu committed Apr 8, 2024
1 parent f06b099 commit ede7876
Showing 1 changed file with 76 additions and 2 deletions.
78 changes: 76 additions & 2 deletions src/app/components/button/button.ts
Original file line number Diff line number Diff line change
@@ -16,7 +16,8 @@ import {
QueryList,
TemplateRef,
ViewEncapsulation,
booleanAttribute
booleanAttribute,
numberAttribute
} from '@angular/core';
import { PrimeTemplate, SharedModule } from 'primeng/api';
import { DomHandler } from 'primeng/dom';
@@ -101,6 +102,41 @@ export class ButtonDirective implements AfterViewInit, OnDestroy {
this.setStyleClass();
}
}
/**
* Defines the style of the button.
* @group Props
*/
@Input() severity: 'success' | 'info' | 'warning' | 'danger' | 'help' | 'primary' | 'secondary' | 'contrast' | null | undefined;
/**
* Add a shadow to indicate elevation.
* @group Props
*/
@Input({ transform: booleanAttribute }) raised: boolean = false;
/**
* Add a circular border radius to the button.
* @group Props
*/
@Input({ transform: booleanAttribute }) rounded: boolean = false;
/**
* Add a textual class to the button without a background initially.
* @group Props
*/
@Input({ transform: booleanAttribute }) text: boolean = false;
/**
* Add a border class without a background initially.
* @group Props
*/
@Input({ transform: booleanAttribute }) outlined: boolean = false;
/**
* Defines the size of the button.
* @group Props
*/
@Input() size: 'small' | 'large' | undefined | null = null;
/**
* Add a plain textual class to the button without a background initially.
* @group Props
*/
@Input({ transform: booleanAttribute }) plain: boolean = false;

public _label: string | undefined;

@@ -160,6 +196,42 @@ export class ButtonDirective implements AfterViewInit, OnDestroy {
}
}

if (this.text) {
styleClass.push('p-button-text');
}

if (this.severity) {
styleClass.push(`p-button-${this.severity}`);
}

if (this.plain) {
styleClass.push('p-button-plain');
}

if (this.raised) {
styleClass.push('p-button-raised');
}

if (this.size) {
styleClass.push(`p-button-${this.size}`);
}

if (this.outlined) {
styleClass.push('p-button-outlined');
}

if (this.rounded) {
styleClass.push('p-button-rounded');
}

if (this.size === 'small') {
styleClass.push('p-button-sm');
}

if (this.size === 'large') {
styleClass.push('p-button-lg');
}

return styleClass;
}

@@ -269,6 +341,7 @@ export class ButtonDirective implements AfterViewInit, OnDestroy {
pRipple
[attr.data-pc-name]="'button'"
[attr.data-pc-section]="'root'"
[attr.tabindex]="tabindex"
>
<ng-content></ng-content>
<ng-container *ngTemplateOutlet="contentTemplate"></ng-container>
@@ -363,7 +436,7 @@ export class Button implements AfterContentInit {
* Defines the style of the button.
* @group Props
*/
@Input() severity: 'secondary' | 'success' | 'info' | 'warning' | 'help' | 'danger' | string | undefined;
@Input() severity: 'secondary' | 'success' | 'info' | 'warning' | 'help' | 'danger' | 'contrast' | string | undefined;
/**
* Add a border class without a background initially.
* @group Props
@@ -374,6 +447,7 @@ export class Button implements AfterContentInit {
* @group Props
*/
@Input({ transform: booleanAttribute }) link: boolean = false;
@Input({ transform: numberAttribute }) tabindex: number | undefined;
/**
* Defines the size of the button.
* @group Props

0 comments on commit ede7876

Please sign in to comment.