-
Notifications
You must be signed in to change notification settings - Fork 125
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(core) Change Info Label into component | Improve tests (#3399)
BREAKING CHANGE: made Info Label component
- Loading branch information
Showing
7 changed files
with
91 additions
and
64 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
...src/app/core/component-docs/info-label/examples/info-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 +1 @@ | ||
<span fd-info-label>default label</span> | ||
<fd-info-label label="Default label"></fd-info-label> |
7 changes: 3 additions & 4 deletions
7
...pp/core/component-docs/info-label/examples/info-label-icon-numeric-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,3 @@ | ||
<span fd-info-label [type]="'numeric'" [color]="'2'" style="margin-right: 20px;">6</span> | ||
<span fd-info-label [type]="'numeric'" [color]="'3'" style="margin-right: 20px;">42k</span> | ||
<span fd-info-label [type]="'numeric'" [color]="'3'" style="margin-right: 20px;">14.7</span> | ||
<span fd-info-label [type]="'icon'" [color]="'5'" [glyph]="'hide'" style="margin-right: 20px;"></span> | ||
<fd-info-label type="numeric" color="1" label="6" style="margin-right: 20px;"></fd-info-label> | ||
<fd-info-label type="numeric" color="2" label="42k" style="margin-right: 20px;"></fd-info-label> | ||
<fd-info-label type="numeric" color="3" label="14.7" style="margin-right: 20px;"></fd-info-label> |
4 changes: 2 additions & 2 deletions
4
...cs/src/app/core/component-docs/info-label/examples/info-label-text-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,3 +1,3 @@ | ||
<div style="margin-top: 10px;" *ngFor="let item of [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]"> | ||
<span fd-info-label [color]="item">Info Label</span> | ||
<div style="margin-top: 10px;" *ngFor="let item of ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']"> | ||
<fd-info-label label="Info Label" [color]="item"></fd-info-label> | ||
</div> |
4 changes: 2 additions & 2 deletions
4
...c/app/core/component-docs/info-label/examples/info-label-text-icon-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,3 +1,3 @@ | ||
<div style="margin-top: 10px;" *ngFor="let item of [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]"> | ||
<span fd-info-label [type]="'icon'" [color]="item" [glyph]="'hide'">info label</span> | ||
<div style="margin-top: 10px;" *ngFor="let item of ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']"> | ||
<fd-info-label type="icon" glyph="hide" label="Info label" [color]="item"></fd-info-label> | ||
</div> |
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,9 @@ | ||
<i *ngIf="glyph" | ||
class="fd-info-label__icon" | ||
[ngClass]="glyph ? 'sap-icon--' + glyph : ''"> | ||
</i> | ||
|
||
<span *ngIf="label" class="fd-info-label__text">{{ label }}</span> | ||
|
||
<!-- TODO @salarenko: DEPRECATED - Remove in v0.23.0 --> | ||
<ng-content></ng-content> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,69 +1,75 @@ | ||
import { | ||
Component, | ||
ViewEncapsulation, | ||
ChangeDetectionStrategy, | ||
Component, | ||
ElementRef, | ||
Input, | ||
OnChanges, | ||
OnInit, | ||
ElementRef, | ||
OnChanges | ||
ViewEncapsulation | ||
} from '@angular/core'; | ||
import { CssClassBuilder, applyCssClass } from '../utils/public_api'; | ||
import { applyCssClass, CssClassBuilder } from '../utils/public_api'; | ||
|
||
export type LabelType = 'numeric' | 'icon'; | ||
|
||
@Component({ | ||
// tslint:disable-next-line:component-selector | ||
selector: '[fd-info-label]', | ||
template: `<ng-content></ng-content>`, | ||
// TODO @salarenko: DEPRECATED DIRECTIVE APPROACH - Remove in v0.23.0 | ||
selector: 'fd-info-label, [fd-info-label]', | ||
templateUrl: './info-label.component.html', | ||
styleUrls: ['./info-label.component.scss'], | ||
encapsulation: ViewEncapsulation.None, | ||
changeDetection: ChangeDetectionStrategy.OnPush | ||
}) | ||
export class InfoLabelComponent implements OnInit, OnChanges, CssClassBuilder { | ||
/** user's custom classes */ | ||
/** User's custom classes */ | ||
@Input() | ||
class = ''; | ||
|
||
/** | ||
* The LabelType represented by the info label . | ||
* Can be one of the following: 'numeric' | 'only-icon' | 'icon' | ||
* For default info label omit this property | ||
*/ | ||
@Input() | ||
type: LabelType; | ||
|
||
/** glyph define the icon of info label */ | ||
/** Glyph define the icon of info label */ | ||
@Input() | ||
glyph: string; | ||
|
||
/**define the colour of the info label starting form 1 to 10 */ | ||
/** Define the colour of the info label starting form 1 to 10 */ | ||
@Input() | ||
color: string; | ||
|
||
@applyCssClass | ||
buildComponentCssClass(): string[] { | ||
return [ | ||
'fd-info-label', | ||
this.type ? `fd-info-label--${this.type}` : '', | ||
this.glyph ? `sap-icon--${this.glyph}` : '', | ||
this.color ? `fd-info-label--accent-color-${this.color}` : '', | ||
this.class | ||
]; | ||
} | ||
/** Define the text content of the info label */ | ||
@Input() | ||
label: string; | ||
|
||
/** @hidden */ | ||
constructor(private _elementRef: ElementRef) {} | ||
|
||
/** @hidden */ | ||
ngOnInit(): void { | ||
this.buildComponentCssClass(); | ||
} | ||
|
||
/** @hidden */ | ||
ngOnChanges(): void { | ||
this.buildComponentCssClass(); | ||
} | ||
|
||
/** @hidden */ | ||
elementRef(): ElementRef<any> { | ||
elementRef(): ElementRef { | ||
return this._elementRef; | ||
} | ||
|
||
/** @hidden */ | ||
@applyCssClass | ||
buildComponentCssClass(): string[] { | ||
return [ | ||
'fd-info-label', | ||
this.type ? `fd-info-label--${this.type}` : '', | ||
this.color ? `fd-info-label--accent-color-${this.color}` : '', | ||
this.class | ||
]; | ||
} | ||
} |