Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: cleaned up badge/label component (#946)
* Cleaned up badge/label component * fixed broken test * refactor badge and label component into directives
- Loading branch information
Showing
19 changed files
with
185 additions
and
149 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
8 changes: 4 additions & 4 deletions
8
...pp/documentation/component-docs/badge-label/examples/badge-default-example.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,4 +1,4 @@ | ||
<fd-badge>Default</fd-badge> | ||
<fd-badge [status]="'success'">Default</fd-badge> | ||
<fd-badge [status]="'warning'">Default</fd-badge> | ||
<fd-badge [status]="'error'">Default</fd-badge> | ||
<span fd-badge>Default</span> | ||
<span fd-badge [status]="'success'">Default</span> | ||
<span fd-badge [status]="'warning'">Default</span> | ||
<span fd-badge [status]="'error'">Default</span> |
8 changes: 4 additions & 4 deletions
8
...app/documentation/component-docs/badge-label/examples/badge-filled-example.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,4 +1,4 @@ | ||
<fd-badge [modifier]="'filled'">Default</fd-badge> | ||
<fd-badge [status]="'success'" [modifier]="'filled'">Default</fd-badge> | ||
<fd-badge [status]="'warning'" [modifier]="'filled'">Default</fd-badge> | ||
<fd-badge [status]="'error'" [modifier]="'filled'">Default</fd-badge> | ||
<span fd-badge [modifier]="'filled'">Default</span> | ||
<span fd-badge [status]="'success'" [modifier]="'filled'">Default</span> | ||
<span fd-badge [status]="'warning'" [modifier]="'filled'">Default</span> | ||
<span fd-badge [status]="'error'" [modifier]="'filled'">Default</span> |
8 changes: 4 additions & 4 deletions
8
docs/app/documentation/component-docs/badge-label/examples/badge-pill-example.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,4 +1,4 @@ | ||
<fd-badge [modifier]="'pill'">Default</fd-badge> | ||
<fd-badge [status]="'success'" [modifier]="'pill'">Default</fd-badge> | ||
<fd-badge [status]="'warning'" [modifier]="'pill'">Default</fd-badge> | ||
<fd-badge [status]="'error'" [modifier]="'pill'">Default</fd-badge> | ||
<span fd-badge [modifier]="'pill'">Default</span> | ||
<span fd-badge [status]="'success'" [modifier]="'pill'">Default</span> | ||
<span fd-badge [status]="'warning'" [modifier]="'pill'">Default</span> | ||
<span fd-badge [status]="'error'" [modifier]="'pill'">Default</span> |
8 changes: 4 additions & 4 deletions
8
...cumentation/component-docs/badge-label/examples/label-build-status-example.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,4 +1,4 @@ | ||
<fd-label [isStatusLabel]="true" [statusIcon]="'available'">Available</fd-label> | ||
<fd-label [isStatusLabel]="true" [statusIcon]="'away'">Away</fd-label> | ||
<fd-label [isStatusLabel]="true" [statusIcon]="'busy'">Busy</fd-label> | ||
<fd-label [isStatusLabel]="true" [statusIcon]="'offline'">Appear Offline</fd-label> | ||
<span fd-label [isStatusLabel]="true" [statusIcon]="'available'">Available</span> | ||
<span fd-label [isStatusLabel]="true" [statusIcon]="'away'">Away</span> | ||
<span fd-label [isStatusLabel]="true" [statusIcon]="'busy'">Busy</span> | ||
<span fd-label [isStatusLabel]="true" [statusIcon]="'offline'">Appear Offline</span> |
8 changes: 4 additions & 4 deletions
8
...pp/documentation/component-docs/badge-label/examples/label-default-example.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,4 +1,4 @@ | ||
<fd-label>Default</fd-label> | ||
<fd-label [status]="'success'">Success</fd-label> | ||
<fd-label [status]="'warning'">Warning</fd-label> | ||
<fd-label [status]="'error'">Error</fd-label> | ||
<span fd-label>Default</span> | ||
<span fd-label [status]="'success'">Success</span> | ||
<span fd-label [status]="'warning'">Warning</span> | ||
<span fd-label [status]="'error'">Error</span> |
8 changes: 4 additions & 4 deletions
8
...ocumentation/component-docs/badge-label/examples/label-icon-status-example.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,4 +1,4 @@ | ||
<fd-label [isStatusLabel]="true" [icon]="'history'">Custom Icon</fd-label> | ||
<fd-label [isStatusLabel]="true" [icon]="'message-success'">Success</fd-label> | ||
<fd-label [isStatusLabel]="true" [icon]="'message-warning'">Warning</fd-label> | ||
<fd-label [isStatusLabel]="true" [icon]="'message-error'">Error</fd-label> | ||
<span fd-label [isStatusLabel]="true" [icon]="'history'">Custom Icon</span> | ||
<span fd-label [isStatusLabel]="true" [icon]="'message-success'">Success</span> | ||
<span fd-label [isStatusLabel]="true" [icon]="'message-warning'">Warning</span> | ||
<span fd-label [isStatusLabel]="true" [icon]="'message-error'">Error</span> |
8 changes: 4 additions & 4 deletions
8
...umentation/component-docs/badge-label/examples/label-status-colors-example.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,4 +1,4 @@ | ||
<fd-label [isStatusLabel]="true">Default</fd-label> | ||
<fd-label [isStatusLabel]="true" [status]="'success'">Success</fd-label> | ||
<fd-label [isStatusLabel]="true" [status]="'warning'">Warning</fd-label> | ||
<fd-label [isStatusLabel]="true" [status]="'error'">Error</fd-label> | ||
<span fd-label [isStatusLabel]="true">Default</span> | ||
<span fd-label [isStatusLabel]="true" [status]="'success'">Success</span> | ||
<span fd-label [isStatusLabel]="true" [status]="'warning'">Warning</span> | ||
<span fd-label [isStatusLabel]="true" [status]="'error'">Error</span> |
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.
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,12 +1,12 @@ | ||
import { NgModule } from '@angular/core'; | ||
import { CommonModule } from '@angular/common'; | ||
|
||
import { BadgeComponent } from './badge.component'; | ||
import { LabelComponent } from './label.component'; | ||
import { BadgeDirective } from './badge.directive'; | ||
import { LabelDirective } from './label.directive'; | ||
|
||
@NgModule({ | ||
imports: [CommonModule], | ||
exports: [BadgeComponent, LabelComponent], | ||
declarations: [BadgeComponent, LabelComponent] | ||
exports: [BadgeDirective, LabelDirective], | ||
declarations: [BadgeDirective, LabelDirective] | ||
}) | ||
export class BadgeLabelModule {} | ||
export class BadgeLabelModule { } |
This file was deleted.
Oops, something went wrong.
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,53 @@ | ||
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; | ||
import { Component, DebugElement } from '@angular/core'; | ||
import { By } from '@angular/platform-browser'; | ||
import { BadgeDirective } from './badge.directive'; | ||
|
||
@Component({ | ||
template: ` | ||
<span fd-badge>Fd-badge test</span> | ||
` | ||
}) | ||
export class TestComponent { } | ||
|
||
describe('BadgeDirective', () => { | ||
let component: TestComponent, | ||
fixture: ComponentFixture<TestComponent>, | ||
debugElement: DebugElement, | ||
element: HTMLElement; | ||
|
||
let directive, directiveInstance; | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [BadgeDirective, TestComponent] | ||
}); | ||
})); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(TestComponent); | ||
component = fixture.componentInstance; | ||
debugElement = fixture.debugElement; | ||
element = debugElement.nativeElement; | ||
|
||
fixture.detectChanges(); | ||
directive = debugElement.query(By.directive(BadgeDirective)); | ||
directiveInstance = directive.injector.get(BadgeDirective); | ||
fixture = TestBed.createComponent(TestComponent); | ||
|
||
spyOn(directiveInstance, '_setProperties').and.callThrough(); | ||
spyOn(directiveInstance, '_addClassToElement'); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(directive).toBeTruthy(); | ||
|
||
directiveInstance.status = 'someStatus'; | ||
directiveInstance.modifier = 'someModifier'; | ||
|
||
directiveInstance.ngOnInit(); | ||
expect(directiveInstance._setProperties).toHaveBeenCalled(); | ||
expect(directiveInstance._addClassToElement).toHaveBeenCalledWith('fd-badge--someStatus'); | ||
expect(directiveInstance._addClassToElement).toHaveBeenCalledWith('fd-badge--someModifier'); | ||
}); | ||
}); |
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.
Oops, something went wrong.