Skip to content

Commit 07e9821

Browse files
authored
feat: styling for disabled input (#976)
* feat: styling for disabled input
1 parent 05b0dce commit 07e9821

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

projects/components/src/input/input.component.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33

44
:host {
55
::ng-deep {
6+
&.disabled {
7+
background-color: $gray-2;
8+
cursor: not-allowed;
9+
}
10+
611
.border {
712
&.mat-form-field {
813
height: inherit;

projects/components/src/input/input.component.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ describe('Input Component', () => {
1818

1919
spectator.tick();
2020
expect(spectator.query(MatInput)!.disabled).toBe(true);
21+
expect(spectator.query('mat-form-field')).toHaveClass('disabled');
2122
}));
2223

2324
test('should emit number values for inputs of type number', () => {

projects/components/src/input/input.component.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { InputAppearance } from './input-appearance';
77
styleUrls: ['./input.component.scss'],
88
changeDetection: ChangeDetectionStrategy.OnPush,
99
template: `
10-
<mat-form-field [ngClass]="this.appearance" floatLabel="never">
10+
<mat-form-field [ngClass]="this.getStyleClasses()" floatLabel="never">
1111
<input
1212
matInput
1313
[type]="this.type"
@@ -66,4 +66,8 @@ export class InputComponent<T extends string | number> implements OnChanges {
6666
return value as T | undefined;
6767
}
6868
}
69+
70+
public getStyleClasses(): string[] {
71+
return [this.appearance, this.disabled ? 'disabled' : ''];
72+
}
6973
}

0 commit comments

Comments
 (0)