Skip to content
This repository was archived by the owner on Nov 30, 2022. It is now read-only.

Commit dd502be

Browse files
committed
feat(icon): add dotVisible input
1 parent 8280262 commit dd502be

File tree

4 files changed

+32
-13
lines changed

4 files changed

+32
-13
lines changed

projects/core/src/lib/icon/icon.component.html

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<ion-icon [slot]="slot" [@rotateAnim]="state" (@rotateAnim.done)="rotateAnimDone($event)" [name]="_name" [color]="color"></ion-icon>
2-
<span [@scaleAnim]="indicatorState" *ngIf="indicatorValue >= 0" class="indicator"></span>
3-
<span *ngIf="_indicatorValue > 0" class="indicator-background"></span>
2+
<span [@scaleAnim]="indicatorState" *ngIf="dotVisible" class="indicator"></span>
3+
<span *ngIf="_indicatorValue > 0 || dotVisible" class="indicator-background"></span>
44
<span class="off-background" *ngIf="off"></span>
55
<span class="off" *ngIf="off"></span>
6-
<span *ngIf="indicatorValue >= 0" [@scaleAnim]="indicatorValueState" (@scaleAnim.done)="incrementDone($event)"
6+
<span *ngIf="indicatorValue > 0 && !dotVisible" [@scaleAnim]="indicatorValueState" (@scaleAnim.done)="incrementDone($event)"
77
class="indicator-value">
88
<span *ngIf="indicatorValue <= 9">{{indicatorValue}}</span>
99
<span *ngIf="indicatorValue > 9">9+</span>

projects/core/src/lib/icon/icon.component.ts

+21-7
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,16 @@ import { trigger, transition, animate, state, style } from '@angular/animations'
3636
export class FivIcon implements OnInit {
3737

3838
_name: string;
39-
_indicatorValue = -1;
39+
_indicatorValue = 0;
4040
tempValue: number;
4141
state: 'normal' | 'rotate' = 'normal';
4242
temp: string;
4343
@Input() color: string;
44+
4445
@Input() slot: string;
4546
@Input() off = false;
4647
@Output() transitionDone = new EventEmitter<string>();
4748

48-
4949
indicatorState: 'normal' | 'scale' = 'scale';
5050
indicatorValueState: 'normal' | 'scale' = 'scale';
5151

@@ -69,6 +69,20 @@ export class FivIcon implements OnInit {
6969
this.transformIndicator(value);
7070
}
7171

72+
@Input()
73+
set dotVisible(dotVisible: boolean) {
74+
this._dotVisible = dotVisible;
75+
if (dotVisible) {
76+
this.indicatorState = 'normal';
77+
}
78+
}
79+
80+
get dotVisible(): boolean {
81+
return this._dotVisible;
82+
}
83+
84+
_dotVisible: boolean;
85+
7286
constructor() { }
7387

7488
ngOnInit() {
@@ -80,12 +94,12 @@ export class FivIcon implements OnInit {
8094
}
8195

8296
transformIndicator(value: number) {
83-
if (value === -1) {
97+
if (this.dotVisible) {
98+
this._indicatorValue = value;
99+
return;
100+
}
101+
if (value === 0) {
84102
this._indicatorValue = value;
85-
this.indicatorState = 'scale';
86-
this.indicatorValueState = 'scale';
87-
} else if (value === 0) {
88-
this.tempValue = value;
89103
this.indicatorState = 'normal';
90104
this.indicatorValueState = 'scale';
91105
} else {

src/app/pages/icon/icon.page.html

+5-1
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,14 @@
2424
<ion-label>Icon turned off</ion-label>
2525
<ion-checkbox [(ngModel)]="off" slot="end"></ion-checkbox>
2626
</ion-item>
27+
<ion-item>
28+
<ion-label>Icon dot</ion-label>
29+
<ion-checkbox [(ngModel)]="dot" slot="end"></ion-checkbox>
30+
</ion-item>
2731

2832
<div class="example">
2933
<ion-button [fivCenter] fill="clear">
30-
<fiv-icon [off]="off" slot="icon-only" [indicatorValue]="indicatorValue" [name]="icon"></fiv-icon>
34+
<fiv-icon [off]="off" [dotVisible]="dot" slot="icon-only" [indicatorValue]="indicatorValue" [name]="icon"></fiv-icon>
3135
</ion-button>
3236
</div>
3337

src/app/pages/icon/icon.page.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,17 @@ import { Component, OnInit } from '@angular/core';
99
export class IconPage implements OnInit {
1010

1111
icon = 'md-notifications';
12-
indicatorValue = -1;
12+
indicatorValue = 0;
1313
off = false;
14+
dot = false;
1415

1516
constructor(private util: UtilService) { }
1617

1718
ngOnInit() {
1819
}
1920

2021
decrement() {
21-
if (this.indicatorValue >= 0) {
22+
if (this.indicatorValue > 0) {
2223
this.indicatorValue--;
2324
}
2425
}

0 commit comments

Comments
 (0)