Skip to content

Commit

Permalink
Move UI widgets to new location
Browse files Browse the repository at this point in the history
Shared scss file for widgets & overview
  • Loading branch information
kewde committed Oct 23, 2017
1 parent 49e831b commit 1f10bc2
Show file tree
Hide file tree
Showing 12 changed files with 205 additions and 106 deletions.
4 changes: 3 additions & 1 deletion src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import { StakinginfoComponent } from './overview/widgets/stakinginfo/stakinginfo
import 'hammerjs';
import { FlashNotificationService } from './services/flash-notification.service';
import { BlockStatusService } from './core/rpc/blockstatus.service';
import { ColdstakeComponent } from './overview/widgets/coldstake/coldstake.component';

const routes: Routes = [
{ path: 'overview', component: OverviewComponent, data: { title: 'Overview' } },
Expand All @@ -45,7 +46,8 @@ const routes: Routes = [
StatusComponent,
OverviewComponent,
SettingsComponent,
StakinginfoComponent
StakinginfoComponent,
ColdstakeComponent
],
imports: [
BrowserModule,
Expand Down
81 changes: 2 additions & 79 deletions src/app/overview/overview.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,86 +42,9 @@

<div class="flexitem" fxFlex="50%">

<app-header>
<ul class="header-nav">
<li>Staking Information</li>
</ul>
<ul class="header-nav pull-right">
<!-- <li><a href="javascript:void(0)"><span class="icon fa fa-cog color-green"></span></a></li> -->
</ul>
</app-header>
<md-card class="multiple">
<div fxFlex [fxLayout]="'row'">
<div class="one flexitem" fxFlex>
<div class="stat-box">
<div class="value">~3 h</div>
<div class="description">Next reward</div>
<app-stakinginfo></app-stakinginfo>
</div>
</div>
<div class="two flexitem" fxFlex>
<div class="stat-box">
<div class="value">1<span class="point">.</span><small>5</small>&nbsp;%</div>
<div class="description">Stake percentage</div>
</div>
</div>
<div class="three flexitem" fxFlex>
<div class="stat-box">
<div class="value">1<span class="point">.</span><small>4949327</small>&nbsp;PART</div>
<div class="description">Stake reward</div>
</div>
</div>
</div>
</md-card>

<md-card class="multiple">
<div fxFlex [fxLayout]="'row'">
<div class="two flexitem" fxFlex>
<div class="stat-box">
<div class="value">2254764680994</div>
<div class="description">Your Stake weight</div>
</div>
</div>
<div class="two flexitem" fxFlex>
<div class="stat-box">
<div class="value">434972889332496</div>
<div class="description">Network Stake weight</div>
</div>
</div>
</div>
</md-card>


<div class="cold-staking">
<app-header>
<ul class="header-nav">
<li class="section-title">Cold Staking</li>
</ul>
</app-header>

<md-card class="multiple staking-node">
<div class="title">
<md-icon fontSet="faIcon" class="cs-icon" fontIcon="fa-snowflake-o"></md-icon>
Cold Staking <span class="not-enabled">not enabled</span>
</div>
<button class="mat-raised-button mat-primary pull-right">
<md-icon fontSet="faIcon" fontIcon="fa-plus"></md-icon>
<strong>Add</strong> node key
</button>
</md-card>

<md-card class="multiple staking-node">
<div class="title">
<md-icon fontSet="faIcon" class="cs-icon" fontIcon="fa-snowflake-o"></md-icon>
Cold Staking <span class="enabled">enabled</span>
</div>
<button class="mat-button pull-right">
<md-icon fontSet="faIcon" fontIcon="fa-pencil"></md-icon>
<strong>Edit</strong> node key
</button>
</md-card>
<app-stakinginfo></app-stakinginfo>

</div><!-- .cold-staking -->
<app-coldstake></app-coldstake>

</div><!-- .flexitem 50% -->

Expand Down
26 changes: 2 additions & 24 deletions src/app/overview/overview.component.scss
Original file line number Diff line number Diff line change
@@ -1,13 +1,4 @@
$color: #02E8B0; // primary green-ish color
$color-alert: #EE494D;
$bg-shadow: #E9E9E9; // lines under titles etc.

$text-muted: #7E8790; // grey (for section titles, descriptions etc.)

.header-nav { // section titles
padding: 0 0 20px; margin: 30px 0 30px;
border-bottom: 1px solid $bg-shadow;
}
@import 'widgets/shared/shared.scss';

.balance-overview { // list of balances
padding: 24px 50px;
Expand All @@ -24,22 +15,9 @@ $text-muted: #7E8790; // grey (for section titles, descriptions etc.)
padding: 10px 50px;
}

span.point { color: $color; }

md-card.multiple {
margin-bottom: 20px;
}

.stat-box {
& > .value {
font-size: 24px;
}
& > .description {
color: $text-muted;
text-transform: uppercase;
margin-top: 15px;
}
}


.cold-staking {
.staking-node {
Expand Down
1 change: 1 addition & 0 deletions src/app/overview/overview.component.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Component } from '@angular/core';

import { StakinginfoComponent } from './widgets/stakinginfo/stakinginfo.component';
import { ColdstakeComponent } from './widgets/coldstake/coldstake.component';

@Component({
selector: 'app-overview',
Expand Down
30 changes: 30 additions & 0 deletions src/app/overview/widgets/coldstake/coldstake.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<div class="cold-staking">
<app-header>
<ul class="header-nav">
<li class="section-title">Cold Staking</li>
</ul>
</app-header>

<md-card class="multiple staking-node">
<div class="title">
<md-icon fontSet="faIcon" class="cs-icon" fontIcon="fa-snowflake-o"></md-icon>
Cold Staking <span class="not-enabled">not enabled</span>
</div>
<button class="mat-raised-button mat-primary pull-right">
<md-icon fontSet="faIcon" fontIcon="fa-plus"></md-icon>
<strong>Add</strong> node key
</button>
</md-card>

<md-card class="multiple staking-node">
<div class="title">
<md-icon fontSet="faIcon" class="cs-icon" fontIcon="fa-snowflake-o"></md-icon>
Cold Staking <span class="enabled">enabled</span>
</div>
<button class="mat-button pull-right">
<md-icon fontSet="faIcon" fontIcon="fa-pencil"></md-icon>
<strong>Edit</strong> node key
</button>
</md-card>

</div><!-- .cold-staking -->
27 changes: 27 additions & 0 deletions src/app/overview/widgets/coldstake/coldstake.component.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
@import '../shared/shared.scss';

.cold-staking {
.staking-node {
padding: 24px 24px 30px;
.cs-icon { // snowflake
font-size: 40px;
color: $bg-shadow;
position: relative;
top: 9px;
width: auto;
height: auto;
margin: -11px 15px 0 0;
}
.title {
display: inline-block;
text-transform: uppercase;
font-weight: bold;
& > .enabled { color: $color; }
& > .not-enabled { color: $color-alert; }
}
button {
font-size: 12px;
text-transform: uppercase;
}
}
}
25 changes: 25 additions & 0 deletions src/app/overview/widgets/coldstake/coldstake.component.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';

import { ColdstakeComponent } from './coldstake.component';

describe('ColdstakeComponent', () => {
let component: ColdstakeComponent;
let fixture: ComponentFixture<ColdstakeComponent>;

beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ ColdstakeComponent ]
})
.compileComponents();
}));

beforeEach(() => {
fixture = TestBed.createComponent(ColdstakeComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should be created', () => {
expect(component).toBeTruthy();
});
});
15 changes: 15 additions & 0 deletions src/app/overview/widgets/coldstake/coldstake.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { Component, OnInit } from '@angular/core';

@Component({
selector: 'app-coldstake',
templateUrl: './coldstake.component.html',
styleUrls: ['./coldstake.component.scss']
})
export class ColdstakeComponent implements OnInit {

constructor() { }

ngOnInit() {
}

}
24 changes: 24 additions & 0 deletions src/app/overview/widgets/shared/shared.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
Values shared among widgets
*/
$color: #02E8B0; // primary green-ish color
$color-alert: #EE494D;
$bg-shadow: #E9E9E9; // lines under titles etc.


$text-muted: #7E8790; // grey (for section titles, descriptions etc.)

.header-nav { // section titles
padding: 0 0 20px; margin: 30px 0 30px;
border-bottom: 1px solid $bg-shadow;
}

/*
Shared among widgets
*/

span.point { color: $color; }

md-card.multiple {
margin-bottom: 20px;
}
49 changes: 47 additions & 2 deletions src/app/overview/widgets/stakinginfo/stakinginfo.component.html
Original file line number Diff line number Diff line change
@@ -1,2 +1,47 @@
<h4>STAKING REWARD: ~{{dynamicStakingReward}}%</h4>
<h4>NETWORK WEIGHT: ~{{curWeight}}</h4>
<app-header>
<ul class="header-nav">
<li>Staking Information</li>
</ul>
<ul class="header-nav pull-right">
<!-- <li><a href="javascript:void(0)"><span class="icon fa fa-cog color-green"></span></a></li> -->
</ul>
</app-header>
<md-card class="multiple">
<div fxFlex [fxLayout]="'row'">
<div class="one flexitem" fxFlex>
<div class="stat-box">
<div class="value">~3 h</div>
<div class="description">Next reward</div>
</div>
</div>
<div class="two flexitem" fxFlex>
<div class="stat-box">
<div class="value">{{dynamicStakingReward}}<span class="point">.</span><small>{{getAfterDot(dynamicStakingReward)}}</small>&nbsp;%</div>
<div class="description">Stake percentage</div>
</div>
</div>
<div class="three flexitem" fxFlex>
<div class="stat-box">
<div class="value">1<span class="point">.</span><small>4949327</small>&nbsp;PART</div>
<div class="description">Stake reward</div>
</div>
</div>
</div>
</md-card>

<md-card class="multiple">
<div fxFlex [fxLayout]="'row'">
<div class="two flexitem" fxFlex>
<div class="stat-box">
<div class="value">2254764680994</div>
<div class="description">Your Stake weight</div>
</div>
</div>
<div class="two flexitem" fxFlex>
<div class="stat-box">
<div class="value">434972889332496</div>
<div class="description">Network Stake weight</div>
</div>
</div>
</div>
</md-card>
12 changes: 12 additions & 0 deletions src/app/overview/widgets/stakinginfo/stakinginfo.component.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
@import '../shared/shared.scss';

.stat-box {
& > .value {
font-size: 24px;
}
& > .description {
color: $text-muted;
text-transform: uppercase;
margin-top: 15px;
}
}
17 changes: 17 additions & 0 deletions src/app/overview/widgets/stakinginfo/stakinginfo.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,21 @@ export class StakinginfoComponent implements OnInit {
this.curWeight = Math.floor(this.curWeight);
this.log.d(`calculateDynamicStakingReward, dynamicStakingReward = ${this.dynamicStakingReward}`);
}

getBeforeDot(int: number): string {
if ((int + '').indexOf('.') >= 0) {
return (int + '').split('.')[0];
} else {
return '0';
}
}

getAfterDot(int: number): string {
if ((int + '').indexOf('.') >= 0) {
return (int + '').split('.')[1];
} else {
return '0';
}
}

}

0 comments on commit 1f10bc2

Please sign in to comment.