Skip to content

Commit c9071d8

Browse files
authored
feat(design): convert @daffodil/design/button to use signals (#4542)
1 parent f0f9d99 commit c9071d8

6 files changed

Lines changed: 12 additions & 16 deletions

File tree

libs/design/button/src/button/basic/button.component.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ describe('@daffodil/design/button | DaffButtonComponent', () => {
7373

7474
describe('the elevated property', () => {
7575
it('should be able to take `elevated` as an input', () => {
76-
expect(component.elevated).toEqual(wrapper.elevated());
76+
expect(component.elevated()).toEqual(wrapper.elevated());
7777
});
7878

7979
it('should add a class of `.elevated` to the host element if elevated is true', () => {

libs/design/button/src/button/basic/button.component.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import {
22
Component,
33
ViewEncapsulation,
44
ChangeDetectionStrategy,
5-
Input,
5+
input,
66
} from '@angular/core';
77

88
import { DaffSpinnerComponent } from '@daffodil/design/spinner';
@@ -34,7 +34,7 @@ import { DaffButtonBaseDirective } from '../button-base.directive';
3434
styleUrl: './button.component.scss',
3535
host: {
3636
'class': 'daff-button',
37-
'[class.elevated]': 'elevated',
37+
'[class.elevated]': 'elevated()',
3838
},
3939
encapsulation: ViewEncapsulation.None,
4040
changeDetection: ChangeDetectionStrategy.OnPush,
@@ -46,5 +46,5 @@ export class DaffButtonComponent extends DaffButtonBaseDirective {
4646
/**
4747
* Whether or not the button displays a shadow.
4848
*/
49-
@Input() elevated = false;
49+
elevated = input(false);
5050
}

libs/design/button/src/button/button-base.directive.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ describe('@daffodil/design/button | DaffButtonBaseDirective', () => {
102102

103103
describe('using the tabindex property of a button', () => {
104104
it('should be able to take `tabindex` as an input', () => {
105-
expect(directive.tabindex).toEqual(wrapper.tabindex);
105+
expect(directive.tabindex()).toEqual(wrapper.tabindex);
106106
});
107107
});
108108

libs/design/button/src/button/button-base.directive.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
import { coerceBooleanProperty } from '@angular/cdk/coercion';
21
import {
3-
Input,
42
Directive,
53
ContentChild,
4+
input,
65
} from '@angular/core';
76

87
import {
@@ -46,7 +45,7 @@ import { DaffButtonSizableDirective } from './button-sizable.directive';
4645
host: {
4746
'[attr.disabled]': 'disabled ? true : null',
4847
'[attr.aria-disabled]': 'disabled ? true : null',
49-
'[attr.tabindex]': 'disabled ? -1 : this.tabindex',
48+
'[attr.tabindex]': 'disabled ? -1 : tabindex()',
5049
},
5150
})
5251
export class DaffButtonBaseDirective implements DaffDisableable {
@@ -75,17 +74,14 @@ export class DaffButtonBaseDirective implements DaffDisableable {
7574
/**
7675
* Sets the tabindex.
7776
*/
78-
@Input() tabindex = 0;
77+
tabindex = input(0);
7978

8079
/**
8180
* The disabled state of the button.
8281
*/
83-
@Input() get disabled() {
82+
get disabled() {
8483
return this.disabledDirective.disabled;
8584
}
86-
set disabled(value: any) {
87-
this.disabledDirective.disabled = coerceBooleanProperty(value);
88-
}
8985

9086
/**
9187
* @docs-private

libs/design/button/src/button/stroked/stroked.component.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ describe('@daffodil/design/button | DaffStrokedButtonComponent', () => {
7474

7575
describe('the elevated property', () => {
7676
it('should be able to take `elevated` as an input', () => {
77-
expect(component.elevated).toEqual(wrapper.elevated());
77+
expect(component.elevated()).toEqual(wrapper.elevated());
7878
});
7979

8080
it('should add a class of `.elevated` to the host element if elevated is true', () => {

libs/design/button/src/button/stroked/stroked.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import {
22
Component,
33
ViewEncapsulation,
44
ChangeDetectionStrategy,
5-
Input,
5+
input,
66
} from '@angular/core';
77

88
import { DaffSpinnerComponent } from '@daffodil/design/spinner';
@@ -47,5 +47,5 @@ export class DaffStrokedButtonComponent extends DaffButtonBaseDirective {
4747
/**
4848
* Whether or not the button displays a shadow.
4949
*/
50-
@Input() elevated = false;
50+
elevated = input(false);
5151
}

0 commit comments

Comments
 (0)