Add transaction page and styling for page layout.

This commit is contained in:
Spencer Ofwiti
2020-11-04 15:36:30 +03:00
parent cbe51520fa
commit b9734e60ad
37 changed files with 942 additions and 536 deletions

View File

@@ -0,0 +1,8 @@
import { MenuSelectionDirective } from './menu-selection.directive';
describe('MenuSelectionDirective', () => {
it('should create an instance', () => {
const directive = new MenuSelectionDirective();
expect(directive).toBeTruthy();
});
});

View File

@@ -0,0 +1,28 @@
import {Directive, ElementRef, Renderer2} from '@angular/core';
@Directive({
selector: '[appMenuSelection]'
})
export class MenuSelectionDirective {
constructor(
private elementRef: ElementRef,
private renderer: Renderer2
) {
this.renderer.listen(this.elementRef.nativeElement, 'click', () => {
const mediaQuery = window.matchMedia('(max-width: 768px)');
if (mediaQuery.matches) {
this.onMenuSelect();
}
});
}
onMenuSelect(): void {
const sidebar = document.getElementById('sidebar');
sidebar.classList.add('active');
const content = document.getElementById('content');
content.classList.add( 'active');
const sidebarCollapse = document.getElementById('sidebarCollapse');
sidebarCollapse.classList.remove('active');
}
}

View File

@@ -0,0 +1,8 @@
import { MenuToggleDirective } from './menu-toggle.directive';
describe('MenuToggleDirective', () => {
it('should create an instance', () => {
const directive = new MenuToggleDirective();
expect(directive).toBeTruthy();
});
});

View File

@@ -0,0 +1,26 @@
import {Directive, ElementRef, Renderer2} from '@angular/core';
@Directive({
selector: '[appMenuToggle]'
})
export class MenuToggleDirective {
constructor(
private elementRef: ElementRef,
private renderer: Renderer2
) {
this.renderer.listen(this.elementRef.nativeElement, 'click', () => {
this.onMenuToggle();
});
}
// Menu Trigger
onMenuToggle(): void {
const sidebar = document.getElementById('sidebar');
sidebar.classList.toggle('active');
const content = document.getElementById('content');
content.classList.toggle('active');
const sidebarCollapse = document.getElementById('sidebarCollapse');
sidebarCollapse.classList.toggle('active');
}
}

View File

@@ -0,0 +1,5 @@
<!-- Footer Start -->
<footer class="footer">
2020 © Grassroots Economics
</footer>
<!-- end Footer -->

View File

@@ -0,0 +1,25 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { FooterComponent } from './footer.component';
describe('FooterComponent', () => {
let component: FooterComponent;
let fixture: ComponentFixture<FooterComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ FooterComponent ]
})
.compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(FooterComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@@ -0,0 +1,15 @@
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-footer',
templateUrl: './footer.component.html',
styleUrls: ['./footer.component.scss']
})
export class FooterComponent implements OnInit {
constructor() { }
ngOnInit(): void {
}
}

View File

@@ -0,0 +1,31 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { TopbarComponent } from './topbar/topbar.component';
import { FooterComponent } from './footer/footer.component';
import { SidebarComponent } from './sidebar/sidebar.component';
import { MenuSelectionDirective } from './_directives/menu-selection.directive';
import { MenuToggleDirective } from './_directives/menu-toggle.directive';
import {RouterModule} from '@angular/router';
@NgModule({
declarations: [
TopbarComponent,
FooterComponent,
SidebarComponent,
MenuSelectionDirective,
MenuToggleDirective
],
exports: [
TopbarComponent,
FooterComponent,
SidebarComponent,
MenuSelectionDirective
],
imports: [
CommonModule,
RouterModule
]
})
export class SharedModule { }

View File

@@ -0,0 +1,26 @@
<!-- ========== Left Sidebar Start ========== -->
<div id="sidebar">
<nav>
<div class="sidebar-header">
<h3>CIC - Staff Client</h3>
<strong>CIC</strong>
</div>
<ul class="list-unstyled components">
<li>
<a routerLink="/home" routerLinkActive="active" appMenuSelection>
<i class="fa fa-home"></i>
<span> Dashboard </span>
</a>
</li>
<li>
<a routerLink="/tx" routerLinkActive="active" appMenuSelection>
<i class="fa fa-briefcase"></i>
<span> Transactions </span>
</a>
</li>
</ul>
</nav>
</div>
<!-- Left Sidebar End -->

View File

@@ -0,0 +1,25 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { SidebarComponent } from './sidebar.component';
describe('SidebarComponent', () => {
let component: SidebarComponent;
let fixture: ComponentFixture<SidebarComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ SidebarComponent ]
})
.compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(SidebarComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@@ -0,0 +1,15 @@
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-sidebar',
templateUrl: './sidebar.component.html',
styleUrls: ['./sidebar.component.scss']
})
export class SidebarComponent implements OnInit {
constructor() { }
ngOnInit(): void {
}
}

View File

@@ -0,0 +1,11 @@
<!-- Topbar Start -->
<nav class="navbar navbar-expand-lg navbar-light bg-light sticky-top">
<div class="container-fluid">
<button type="button" id="sidebarCollapse" class="navbar-btn menutoggle" appMenuToggle>
<span></span>
<span></span>
<span></span>
</button>
</div>
</nav>
<!-- end Topbar -->

View File

@@ -0,0 +1,25 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { TopbarComponent } from './topbar.component';
describe('TopbarComponent', () => {
let component: TopbarComponent;
let fixture: ComponentFixture<TopbarComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ TopbarComponent ]
})
.compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(TopbarComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@@ -0,0 +1,15 @@
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-topbar',
templateUrl: './topbar.component.html',
styleUrls: ['./topbar.component.scss']
})
export class TopbarComponent implements OnInit {
constructor() { }
ngOnInit(): void {
}
}