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

Commit

Permalink
feat(icon): add dotVisible input
Browse files Browse the repository at this point in the history
  • Loading branch information
marcjulian committed Apr 19, 2019
1 parent 8280262 commit dd502be
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 13 deletions.
6 changes: 3 additions & 3 deletions projects/core/src/lib/icon/icon.component.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<ion-icon [slot]="slot" [@rotateAnim]="state" (@rotateAnim.done)="rotateAnimDone($event)" [name]="_name" [color]="color"></ion-icon>
<span [@scaleAnim]="indicatorState" *ngIf="indicatorValue >= 0" class="indicator"></span>
<span *ngIf="_indicatorValue > 0" class="indicator-background"></span>
<span [@scaleAnim]="indicatorState" *ngIf="dotVisible" class="indicator"></span>
<span *ngIf="_indicatorValue > 0 || dotVisible" class="indicator-background"></span>
<span class="off-background" *ngIf="off"></span>
<span class="off" *ngIf="off"></span>
<span *ngIf="indicatorValue >= 0" [@scaleAnim]="indicatorValueState" (@scaleAnim.done)="incrementDone($event)"
<span *ngIf="indicatorValue > 0 && !dotVisible" [@scaleAnim]="indicatorValueState" (@scaleAnim.done)="incrementDone($event)"
class="indicator-value">
<span *ngIf="indicatorValue <= 9">{{indicatorValue}}</span>
<span *ngIf="indicatorValue > 9">9+</span>
Expand Down
28 changes: 21 additions & 7 deletions projects/core/src/lib/icon/icon.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,16 @@ import { trigger, transition, animate, state, style } from '@angular/animations'
export class FivIcon implements OnInit {

_name: string;
_indicatorValue = -1;
_indicatorValue = 0;
tempValue: number;
state: 'normal' | 'rotate' = 'normal';
temp: string;
@Input() color: string;

@Input() slot: string;
@Input() off = false;
@Output() transitionDone = new EventEmitter<string>();


indicatorState: 'normal' | 'scale' = 'scale';
indicatorValueState: 'normal' | 'scale' = 'scale';

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

@Input()
set dotVisible(dotVisible: boolean) {
this._dotVisible = dotVisible;
if (dotVisible) {
this.indicatorState = 'normal';
}
}

get dotVisible(): boolean {
return this._dotVisible;
}

_dotVisible: boolean;

constructor() { }

ngOnInit() {
Expand All @@ -80,12 +94,12 @@ export class FivIcon implements OnInit {
}

transformIndicator(value: number) {
if (value === -1) {
if (this.dotVisible) {
this._indicatorValue = value;
return;
}
if (value === 0) {
this._indicatorValue = value;
this.indicatorState = 'scale';
this.indicatorValueState = 'scale';
} else if (value === 0) {
this.tempValue = value;
this.indicatorState = 'normal';
this.indicatorValueState = 'scale';
} else {
Expand Down
6 changes: 5 additions & 1 deletion src/app/pages/icon/icon.page.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,14 @@
<ion-label>Icon turned off</ion-label>
<ion-checkbox [(ngModel)]="off" slot="end"></ion-checkbox>
</ion-item>
<ion-item>
<ion-label>Icon dot</ion-label>
<ion-checkbox [(ngModel)]="dot" slot="end"></ion-checkbox>
</ion-item>

<div class="example">
<ion-button [fivCenter] fill="clear">
<fiv-icon [off]="off" slot="icon-only" [indicatorValue]="indicatorValue" [name]="icon"></fiv-icon>
<fiv-icon [off]="off" [dotVisible]="dot" slot="icon-only" [indicatorValue]="indicatorValue" [name]="icon"></fiv-icon>
</ion-button>
</div>

Expand Down
5 changes: 3 additions & 2 deletions src/app/pages/icon/icon.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,17 @@ import { Component, OnInit } from '@angular/core';
export class IconPage implements OnInit {

icon = 'md-notifications';
indicatorValue = -1;
indicatorValue = 0;
off = false;
dot = false;

constructor(private util: UtilService) { }

ngOnInit() {
}

decrement() {
if (this.indicatorValue >= 0) {
if (this.indicatorValue > 0) {
this.indicatorValue--;
}
}
Expand Down

0 comments on commit dd502be

Please sign in to comment.