11import {
22 Directive ,
33 HostBinding ,
4- Input ,
5- OnInit
4+ Input
65} from "@angular/core" ;
76import { ButtonSize , ButtonType } from "./button.types" ;
87
@@ -23,7 +22,7 @@ import { ButtonSize, ButtonType } from "./button.types";
2322@Directive ( {
2423 selector : "[cdsButton], [ibmButton]"
2524} )
26- export class Button implements OnInit {
25+ export class Button {
2726 /**
2827 * @deprecated as of v5 - Use `cdsButton` input property instead
2928 */
@@ -32,7 +31,7 @@ export class Button implements OnInit {
3231 }
3332 /**
3433 * Sets the button type
35- * Accepts `ButtonType` or nothing (defaults to empty string in angular 16+ )
34+ * Accepts `ButtonType` or nothing (empty string which is equivalent to "primary" )
3635 */
3736 @Input ( ) cdsButton : ButtonType | "" = "primary" ;
3837 /**
@@ -58,7 +57,8 @@ export class Button implements OnInit {
5857 // a whole lot of HostBindings ... this way we don't have to touch the elementRef directly
5958 @HostBinding ( "class.cds--btn" ) baseClass = true ;
6059 @HostBinding ( "class.cds--btn--primary" ) get primaryButton ( ) {
61- return this . cdsButton === "primary" ;
60+ // We need to make sure cdsButton is not an empty string since input name matches selector name.
61+ return this . cdsButton === "primary" || ! this . cdsButton ;
6262 }
6363 @HostBinding ( "class.cds--btn--secondary" ) get secondaryButton ( ) {
6464 return this . cdsButton === "secondary" ;
@@ -93,14 +93,4 @@ export class Button implements OnInit {
9393 @HostBinding ( "class.cds--btn--2xl" ) get twoExtraLargeSize ( ) {
9494 return this . size === "2xl" ;
9595 }
96-
97- /**
98- * We need to make sure cdsButton is not an empty string since
99- * input name matches selector name.
100- */
101- ngOnInit ( ) {
102- if ( ! this . cdsButton ) {
103- this . cdsButton = "primary" ;
104- }
105- }
10696}
0 commit comments