Skip to content

Commit

Permalink
feat(全局布局): 添加全局布局组件
Browse files Browse the repository at this point in the history
  • Loading branch information
jiayisheji committed Nov 7, 2017
1 parent 4c70505 commit f8f2ca0
Show file tree
Hide file tree
Showing 5 changed files with 101 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/app/shared/layouts/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export * from './layouts.component';
export * from './sider/sider.component';
export * from './header/header.component';
export * from './footer/footer.component';
12 changes: 12 additions & 0 deletions src/app/shared/layouts/layouts.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<aside class="g-layout-sider" [ngClass]="{'layout-sider-collapsed': _fold}">
<app-sider [fold]="_fold"></app-sider>
</aside>
<div class="g-layout">
<app-header class="layout-header" (onToggle)="toggleSider($event)"></app-header>
<main class="layout-content">
<div class="layout-router">
<router-outlet></router-outlet>
</div>
<app-footer class="layout-footer"></app-footer>
</main>
</div>
40 changes: 40 additions & 0 deletions src/app/shared/layouts/layouts.component.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
.g-layout-sider {
position: relative;
transition: all .2s;
background: #001529;
min-width: 0;
min-height: 100vh;
box-shadow: 2px 0 6px rgba(0, 21, 41, 0.35);
z-index: 10;
max-width: 256px;
min-width: 256px;
width: 256px;
float: left;
&.layout-sider-collapsed {
max-width: 80px;
min-width: 80px;
width: 80px;
}
}

.g-layout {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-orient: vertical;
-webkit-box-direction: normal;
-ms-flex-direction: column;
flex-direction: column;
-webkit-box-flex: 1;
-ms-flex: auto;
flex: auto;
background: #f0f2f5;
}

.layout-content {
margin: 24px 24px 0px;
height: 100%;
-webkit-box-flex: 1;
-ms-flex: auto;
flex: auto;
}
25 changes: 25 additions & 0 deletions src/app/shared/layouts/layouts.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 { LayoutsComponent } from './layouts.component';

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

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

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

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

@Component({
selector: 'app-layouts',
templateUrl: './layouts.component.html',
styleUrls: ['./layouts.component.scss']
})
export class LayoutsComponent implements OnInit {
_fold: boolean;
constructor() { }

ngOnInit() {
}

toggleSider(event) {
console.log(event);
this._fold = event;
}

}

0 comments on commit f8f2ca0

Please sign in to comment.