mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-17 07:26:48 +00:00
Adds a sidebar component
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
<app-navbar></app-navbar>
|
||||
<md-sidenav-container class="example-sidenav-fab-container">
|
||||
<app-navbar></app-navbar>
|
||||
|
||||
<div class="sidebar"></div>
|
||||
<app-sidebar></app-sidebar>
|
||||
|
||||
<div class="main">
|
||||
<div class="main-content">
|
||||
<router-outlet></router-outlet>
|
||||
<div class="main">
|
||||
<div class="main-content">
|
||||
<router-outlet></router-outlet>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</md-sidenav-container>
|
||||
@@ -19,6 +19,7 @@ import {
|
||||
MdCheckboxModule,
|
||||
MdGridListModule,
|
||||
MdProgressSpinnerModule,
|
||||
MdSidenavModule,
|
||||
} from '@angular/material';
|
||||
|
||||
|
||||
@@ -29,11 +30,13 @@ import { SettingsComponent } from './pages/settings/settings.component';
|
||||
import { DashboardComponent } from './pages/dashboard/dashboard.component';
|
||||
|
||||
import { NavbarComponent } from './shared/navbar/navbar.component';
|
||||
import { SidebarComponent } from './shared/sidebar/sidebar.component';
|
||||
import { ExchangeCurrencyTickerComponent } from './shared/exchange-currency-ticker/exchange-currency-ticker.component';
|
||||
import { AllEnabledCurrencyTickersComponent } from './shared/all-enabled-currency-tickers/all-enabled-currency-tickers.component';
|
||||
//services
|
||||
import { WebsocketService } from './services/websocket/websocket.service';
|
||||
import { WebsocketHandlerService } from './services/websocket-handler/websocket-handler.service';
|
||||
import { SidebarService } from './services/sidebar/sidebar.service';
|
||||
import { ElectronService } from './providers/electron.service';
|
||||
//Routing
|
||||
import { AppRoutingModule } from './app-routing.module';
|
||||
@@ -50,7 +53,8 @@ import * as Rx from 'rxjs/Rx';
|
||||
SettingsComponent,
|
||||
DashboardComponent,
|
||||
ExchangeCurrencyTickerComponent,
|
||||
AllEnabledCurrencyTickersComponent
|
||||
AllEnabledCurrencyTickersComponent,
|
||||
SidebarComponent
|
||||
],
|
||||
imports: [
|
||||
BrowserModule,
|
||||
@@ -68,8 +72,9 @@ import * as Rx from 'rxjs/Rx';
|
||||
MdCheckboxModule,
|
||||
MdGridListModule,
|
||||
MdProgressSpinnerModule,
|
||||
MdSidenavModule,
|
||||
],
|
||||
providers: [ElectronService,WebsocketService,WebsocketHandlerService],
|
||||
providers: [ElectronService,WebsocketService,WebsocketHandlerService, SidebarService],
|
||||
bootstrap: [AppComponent]
|
||||
})
|
||||
export class AppModule {
|
||||
|
||||
@@ -15,6 +15,6 @@
|
||||
.md-fab {
|
||||
margin: 0;
|
||||
position: fixed;
|
||||
bottom: 5%;
|
||||
right: 2%;
|
||||
right: 20px;
|
||||
bottom: 10px;
|
||||
}
|
||||
15
web/src/app/services/sidebar/sidebar.service.spec.ts
Normal file
15
web/src/app/services/sidebar/sidebar.service.spec.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import { TestBed, inject } from '@angular/core/testing';
|
||||
|
||||
import { SidebarService } from './sidebar.service';
|
||||
|
||||
describe('SidebarService', () => {
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
providers: [SidebarService]
|
||||
});
|
||||
});
|
||||
|
||||
it('should be created', inject([SidebarService], (service: SidebarService) => {
|
||||
expect(service).toBeTruthy();
|
||||
}));
|
||||
});
|
||||
45
web/src/app/services/sidebar/sidebar.service.ts
Normal file
45
web/src/app/services/sidebar/sidebar.service.ts
Normal file
@@ -0,0 +1,45 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { MdSidenav, MdDrawerToggleResult } from '@angular/material';
|
||||
|
||||
@Injectable()
|
||||
export class SidebarService {
|
||||
private sidenav: MdSidenav;
|
||||
|
||||
/**
|
||||
* Setter for sidenav.
|
||||
*
|
||||
* @param {MdSidenav} sidenav
|
||||
*/
|
||||
public setSidenav(sidenav: MdSidenav) {
|
||||
this.sidenav = sidenav;
|
||||
}
|
||||
|
||||
/**
|
||||
* Open this sidenav, and return a Promise that will resolve when it's fully opened (or get rejected if it didn't).
|
||||
*
|
||||
* @returns Promise<MdSidenavToggleResult>
|
||||
*/
|
||||
public open(): Promise<MdDrawerToggleResult> {
|
||||
return this.sidenav.open();
|
||||
}
|
||||
|
||||
/**
|
||||
* Close this sidenav, and return a Promise that will resolve when it's fully closed (or get rejected if it didn't).
|
||||
*
|
||||
* @returns Promise<MdSidenavToggleResult>
|
||||
*/
|
||||
public close(): Promise<MdDrawerToggleResult> {
|
||||
return this.sidenav.close();
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggle this sidenav. This is equivalent to calling open() when it's already opened, or close() when it's closed.
|
||||
*
|
||||
* @param {boolean} isOpen Whether the sidenav should be open.
|
||||
*
|
||||
* @returns {Promise<MdSidenavToggleResult>}
|
||||
*/
|
||||
public toggle(isOpen?: boolean): Promise<MdDrawerToggleResult> {
|
||||
return this.sidenav.toggle(isOpen);
|
||||
}
|
||||
}
|
||||
@@ -1,16 +1,11 @@
|
||||
<!-- TODO: figure out if the <nav> should go inside of a <header> element. -->
|
||||
<nav class="docs-navbar">
|
||||
<md-toolbar color="primary">
|
||||
<a md-button class="docs-button" routerLink="/" aria-label="Angular Material">
|
||||
<span>Logo</span>
|
||||
</a>
|
||||
<a md-button class="docs-button" routerLink="dashboard">Dashboard</a>
|
||||
<a md-button class="docs-button" routerLink="about">Wallet Summary</a>
|
||||
<a md-button class="docs-button" routerLink="settings">Settings</a>
|
||||
<a md-button class="docs-button" routerLink="about">Help</a>
|
||||
<div class="flex-spacer"></div>
|
||||
<a md-button class="docs-button" href="https://github.com/thrasher-/gocryptotrader/issues" aria-label="GitHub Repository">
|
||||
Report issue
|
||||
</a>
|
||||
</md-toolbar>
|
||||
<md-toolbar color="primary">
|
||||
<a (click)="sidenav.toggle()" class="material-icons"></a>
|
||||
<a md-button class="docs-button" routerLink="/" aria-label="Angular Material">
|
||||
<span>GoCryptoTrader</span>
|
||||
</a>
|
||||
<div class="flex-spacer"></div>
|
||||
<a md-button class="docs-button">Pagename</a>
|
||||
</md-toolbar>
|
||||
</nav>
|
||||
8
web/src/app/shared/sidebar/sidebar.component.html
Normal file
8
web/src/app/shared/sidebar/sidebar.component.html
Normal file
@@ -0,0 +1,8 @@
|
||||
<md-sidenav #sidenav mode="side" opened="true">
|
||||
<button md-mini-fab class="example-fab" (click)="sidenav.toggle()">
|
||||
<md-icon>add</md-icon>
|
||||
</button>
|
||||
<div class="example-scrolling-content">
|
||||
The
|
||||
</div>
|
||||
</md-sidenav>
|
||||
0
web/src/app/shared/sidebar/sidebar.component.scss
Normal file
0
web/src/app/shared/sidebar/sidebar.component.scss
Normal file
25
web/src/app/shared/sidebar/sidebar.component.spec.ts
Normal file
25
web/src/app/shared/sidebar/sidebar.component.spec.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { SidebarComponent } from './sidebar.component';
|
||||
|
||||
describe('SidebarComponent', () => {
|
||||
let component: SidebarComponent;
|
||||
let fixture: ComponentFixture<SidebarComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ SidebarComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(SidebarComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should be created', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
18
web/src/app/shared/sidebar/sidebar.component.ts
Normal file
18
web/src/app/shared/sidebar/sidebar.component.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { Component, OnInit, ViewChild } from '@angular/core';
|
||||
import { MdSidenav } from '@angular/material';
|
||||
import { SidebarService } from './../../services/sidebar/sidebar.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-sidebar',
|
||||
templateUrl: './sidebar.component.html',
|
||||
styleUrls: ['./sidebar.component.scss']
|
||||
})
|
||||
export class SidebarComponent implements OnInit {
|
||||
@ViewChild('sidenav') public sidenav: MdSidenav;
|
||||
sidebarService: SidebarService
|
||||
constructor() { }
|
||||
|
||||
ngOnInit() {
|
||||
this.sidebarService.setSidenav(this.sidenav);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user