-
-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(design): change daffStatusMixin to a directive
- Loading branch information
1 parent
d39a0fb
commit 87c377e
Showing
13 changed files
with
171 additions
and
259 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
libs/design/notification/examples/src/notification-status/notification-status.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
<daff-notification [status]="statusControl.value"> | ||
<fa-icon *ngIf="statusControl.value === 'success'" daffPrefix [icon]="faCheck" [fixedWidth]="true"></fa-icon> | ||
<fa-icon *ngIf="statusControl.value === 'warn'" daffPrefix [icon]="faExclamation" [fixedWidth]="true"></fa-icon> | ||
<fa-icon *ngIf="statusControl.value === 'error'" daffPrefix [icon]="faExclamation" [fixedWidth]="true"></fa-icon> | ||
<fa-icon *ngIf="statusControl.value === 'danger'" daffPrefix [icon]="faExclamation" [fixedWidth]="true"></fa-icon> | ||
<div daffNotificationTitle>Title</div> | ||
<div daffNotificationSubtitle>This is the subtitle with information</div> | ||
</daff-notification> | ||
|
||
<select [formControl]="statusControl"> | ||
<option value="success">Success</option> | ||
<option value="warn">Warn</option> | ||
<option value="error">Error</option> | ||
<option value="danger">Danger</option> | ||
</select> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
86 changes: 86 additions & 0 deletions
86
libs/design/src/core/statusable/statusable.directive.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
import { | ||
Component, | ||
DebugElement, | ||
} from '@angular/core'; | ||
import { | ||
waitForAsync, | ||
ComponentFixture, | ||
TestBed, | ||
} from '@angular/core/testing'; | ||
import { By } from '@angular/platform-browser'; | ||
|
||
import { DaffStatus } from './statusable'; | ||
import { DaffStatusableDirective } from './statusable.directive'; | ||
|
||
@Component({ | ||
template: ` | ||
<div daffStatusable [status]="status"></div>`, | ||
}) | ||
|
||
class WrapperComponent { | ||
status: DaffStatus; | ||
} | ||
|
||
describe('@daffodil/design | DaffStatusableDirective', () => { | ||
let wrapper: WrapperComponent; | ||
let de: DebugElement; | ||
let fixture: ComponentFixture<WrapperComponent>; | ||
let directive: DaffStatusableDirective; | ||
|
||
beforeEach(waitForAsync(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [ | ||
WrapperComponent, | ||
], | ||
imports: [ | ||
DaffStatusableDirective, | ||
], | ||
}) | ||
.compileComponents(); | ||
})); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(WrapperComponent); | ||
wrapper = fixture.componentInstance; | ||
de = fixture.debugElement.query(By.css('[daffStatusable]')); | ||
|
||
directive = de.injector.get(DaffStatusableDirective); | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(wrapper).toBeTruthy(); | ||
expect(directive).toBeTruthy(); | ||
}); | ||
|
||
it('should take status as an input', () => { | ||
expect(directive.status).toEqual(wrapper.status); | ||
}); | ||
|
||
it('should add a class of .daff-warn to the host element if status is set to warn', () => { | ||
wrapper.status = 'warn'; | ||
fixture.detectChanges(); | ||
|
||
expect(directive.class).toEqual(jasmine.objectContaining({ | ||
'daff-warn': true, | ||
})); | ||
}); | ||
|
||
it('should add a class of .daff-danger to the host element if status is set to danger', () => { | ||
wrapper.status = 'danger'; | ||
fixture.detectChanges(); | ||
|
||
expect(directive.class).toEqual(jasmine.objectContaining({ | ||
'daff-danger': true, | ||
})); | ||
}); | ||
|
||
it('should add a class of .daff-success to the host element if status is set to success', () => { | ||
wrapper.status = 'success'; | ||
fixture.detectChanges(); | ||
|
||
expect(directive.class).toEqual(jasmine.objectContaining({ | ||
'daff-success': true, | ||
})); | ||
}); | ||
}); |
Oops, something went wrong.