Skip to content

Commit

Permalink
feat(共享模块): 添加page-header组件
Browse files Browse the repository at this point in the history
  • Loading branch information
jiayisheji committed Jan 12, 2018
1 parent 542d913 commit 83534a9
Show file tree
Hide file tree
Showing 5 changed files with 87 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/app/shared/page-header/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './page-header.component';
19 changes: 19 additions & 0 deletions src/app/shared/page-header/page-header.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<sim-breadcrumb></sim-breadcrumb>
<div class="detail">
<ng-container *ngIf="heading">
<div class="row">
<h2 class="heading">{{heading}}</h2>
</div>
</ng-container>
<ng-container *ngIf="content">
<div class="row" fxLayout="row" fxLayoutAlign="start start">
<div class="content-wrapper" fxFlex="100%">
<ng-content select="[header-content]"></ng-content>
</div>
<div class="extra-wrapper" fxFlex="auto">
<ng-content select="[header-extra]"></ng-content>
</div>
</div>
</ng-container>
</div>
<ng-content select="[header-other]"></ng-content>
20 changes: 20 additions & 0 deletions src/app/shared/page-header/page-header.component.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
.g-page-header {
position: relative;
display: block;
background: #fff;
padding: 16px 32px 0 32px;
border-bottom: 1px solid #e8e8e8;
.title {
margin-bottom: 16px;
font-size: 20px;
font-weight: 500;
color: rgba(0, 0, 0, 0.85);
}
.content-wrapper{
margin-bottom: 16px;
}
.extra-wrapper{
text-align: right;
margin-bottom: 16px;
}
}
25 changes: 25 additions & 0 deletions src/app/shared/page-header/page-header.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 { PageHeaderComponent } from './page-header.component';

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

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

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

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

@Component({
selector: 'app-page-header',
templateUrl: './page-header.component.html',
styleUrls: ['./page-header.component.scss'],
encapsulation: ViewEncapsulation.None,
})
export class PageHeaderComponent implements OnInit {
@HostBinding('class.g-page-header') true;
// 标题
@Input() heading: string;
// 是否有内容
@Input() content: boolean;
// 是否有其他信息
@Input() other: boolean;
constructor() { }

ngOnInit() {
}

}

0 comments on commit 83534a9

Please sign in to comment.