Skip to content

Commit

Permalink
feat(layout): 增加布局页面组件
Browse files Browse the repository at this point in the history
  • Loading branch information
stbui committed May 21, 2018
1 parent 2cd453a commit 1376ace
Show file tree
Hide file tree
Showing 12 changed files with 172 additions and 181 deletions.
17 changes: 16 additions & 1 deletion src/app/layouts/base-layout/base-layout.component.html
Original file line number Diff line number Diff line change
@@ -1 +1,16 @@
<ng-content></ng-content>
<div class="page-layout">
<div class="top-bg"></div>

<div class="wrapper">
<div class="header" fxLayout="row" fxLayoutAlign="start center">
<ng-content select="base-layout-header"></ng-content>
</div>

<div class="card">
<div class="toolbar" fxLayout="row" fxLayoutAlign="start center"></div>
<div class="content">
<ng-content></ng-content>
</div>
</div>
</div>
</div>
71 changes: 69 additions & 2 deletions src/app/layouts/base-layout/base-layout.component.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,71 @@
:host {
display: block;
.layout-container {
display: flex;
flex: 1;
width: 100%;
}

.layout-strategy {
height: 100%;
}

.page-layout {
display: flex;
flex-direction: column;
flex: 1 0 auto;
width: 100%;
min-width: 100%;
position: relative;
}

.top-bg {
position: absolute;
z-index: 1;
top: 0;
right: 0;
left: 0;
height: 200px;
background: #c471f3;
background-size: cover;
}

.wrapper {
display: flex;
flex-direction: column;
flex: 1;
position: relative;
z-index: 2;
padding: 0 32px;
width: 100%;
min-width: 100%;
max-width: 100%;
max-height: 100%;
box-sizing: border-box;
>.header {
height: 136px;
min-height: 136px;
max-height: 136px;
}
>.card {
display: flex;
flex-direction: column;
flex: 1;
overflow: hidden;
background: #fff;
box-shadow: 0 4px 5px -2px rgba(0, 0, 0, .2), 0 7px 10px 1px rgba(0, 0, 0, .14), 0 2px 16px 1px rgba(0, 0, 0, .12);
}
}

.toolbar {
border-bottom: 1px solid rgba(0, 0, 0, .12);
height: 64px;
min-height: 64px;
max-height: 64px;
padding: 0 24px;
}

.content {
display: flex;
flex: 1;
padding: 24px;
overflow: auto
}
42 changes: 38 additions & 4 deletions src/app/layouts/base-layout/base-layout.component.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,49 @@
import { Component, OnInit } from '@angular/core';
/**
* @license
* Copyright Stbui All Rights Reserved.
*/

import { Component, OnInit, Input, ViewEncapsulation } from '@angular/core';

@Component({
selector: 'stbui-base-layout',
templateUrl: './base-layout.component.html',
styleUrls: ['./base-layout.component.scss']
styleUrls: ['./base-layout.component.scss'],
encapsulation: ViewEncapsulation.None,
host: {
class: 'layout-container',
'[class.layout-strategy]': 'scrollStrategy === "strategy"'
}
})
export class BaseLayoutComponent implements OnInit {
@Input() scrollStrategy;
constructor() {}

constructor() { }
ngOnInit() {}
}

ngOnInit() {
@Component({
selector: 'stbui-base-layout-header',
template: '<ng-content></ng-content>',
host: {
class: 'base-layout-header'
}
})
export class BaseLayoutHeaderComponent implements OnInit {
constructor() {}

ngOnInit() {}
}

@Component({
selector: 'stbui-base-layout-content',
template: '<ng-content></ng-content>',
host: {
class: 'base-layout-content'
}
})
export class BaseLayoutContentComponent implements OnInit {
constructor() {}

ngOnInit() {}
}
20 changes: 13 additions & 7 deletions src/app/layouts/base-layout/base-layout.module.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
/**
* @license
* Copyright Stbui All Rights Reserved.
*/

import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { BaseLayoutComponent } from './base-layout.component';
import {
BaseLayoutComponent,
BaseLayoutHeaderComponent
} from './base-layout.component';

@NgModule({
imports: [
CommonModule
],
declarations: [BaseLayoutComponent],
exports: [BaseLayoutComponent]
imports: [CommonModule],
declarations: [BaseLayoutComponent, BaseLayoutHeaderComponent],
exports: [BaseLayoutComponent, BaseLayoutHeaderComponent]
})
export class BaseLayoutModule { }
export class BaseLayoutModule {}
6 changes: 6 additions & 0 deletions src/app/layouts/base-layout/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/**
* @license
* Copyright Stbui All Rights Reserved.
*/

export * from './public-api';
7 changes: 7 additions & 0 deletions src/app/layouts/base-layout/public-api.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/**
* @license
* Copyright Stbui All Rights Reserved.
*/

export * from './base-layout.module';
export * from './base-layout.component';
2 changes: 1 addition & 1 deletion src/app/layouts/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from './base-layout/base-layout.module';
export * from './base-layout';
17 changes: 3 additions & 14 deletions src/app/page-layouts/carded/fullwidth/fullwidth.component.html
Original file line number Diff line number Diff line change
@@ -1,14 +1,3 @@
<div class="page-layout">
<div class="top-bg"></div>

<div class="wrapper">
<div class="header" fxLayout="row" fxLayoutAlign="start center"></div>

<div class="card">
<div class="toolbar" fxLayout="row" fxLayoutAlign="start center"></div>
<div class="content">
<app-demo-content></app-demo-content>
</div>
</div>
</div>
</div>
<stbui-base-layout>
<app-demo-content></app-demo-content>
</stbui-base-layout>
68 changes: 0 additions & 68 deletions src/app/page-layouts/carded/fullwidth/fullwidth.component.scss
Original file line number Diff line number Diff line change
@@ -1,68 +0,0 @@
:host {
display: flex;
flex: 1;
width: 100%;
min-width: 100%;
}

.page-layout {
display: flex;
flex-direction: column;
flex: 1 0 auto;
width: 100%;
min-width: 100%;
position: relative;
}

.top-bg {
position: absolute;
z-index: 1;
top: 0;
right: 0;
left: 0;
height: 200px;
background: #c471f3;
background-size: cover;
}

.wrapper {
display: flex;
flex-direction: column;
flex: 1;
position: relative;
z-index: 2;
padding: 0 32px;
width: 100%;
min-width: 100%;
max-width: 100%;
max-height: 100%;
box-sizing: border-box;
>.header {
height: 136px;
min-height: 136px;
max-height: 136px;
}
>.card {
display: flex;
flex-direction: column;
flex: 1;
overflow: hidden;
background: #fff;
box-shadow: 0 4px 5px -2px rgba(0, 0, 0, .2), 0 7px 10px 1px rgba(0, 0, 0, .14), 0 2px 16px 1px rgba(0, 0, 0, .12);
}
}

.toolbar {
border-bottom: 1px solid rgba(0, 0, 0, .12);
height: 64px;
min-height: 64px;
max-height: 64px;
padding: 0 24px;
}

.content {
display: flex;
flex: 1;
padding: 24px;
overflow: auto
}
16 changes: 3 additions & 13 deletions src/app/page-layouts/carded/fullwidth2/fullwidth2.component.html
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
<div class="page-layout">
<div class="top-bg"></div>

<div class="wrapper">
<div class="header" fxLayout="row" fxLayoutAlign="start center"></div>
<div class="card">
<div class="toolbar" fxLayout="row" fxLayoutAlign="start center"></div>
<div class="content">
<app-demo-content></app-demo-content>
</div>
</div>
</div>
</div>
<stbui-base-layout scrollStrategy="strategy">
<app-demo-content></app-demo-content>
</stbui-base-layout>
69 changes: 0 additions & 69 deletions src/app/page-layouts/carded/fullwidth2/fullwidth2.component.scss
Original file line number Diff line number Diff line change
@@ -1,69 +0,0 @@
:host {
display: flex;
flex: 1;
width: 100%;
min-width: 100%;
height: 100%;
}

.page-layout {
display: flex;
flex-direction: column;
flex: 1 0 auto;
width: 100%;
min-width: 100%;
position: relative;
}

.top-bg {
position: absolute;
z-index: 1;
top: 0;
right: 0;
left: 0;
height: 200px;
background: #c471f3;
background-size: cover;
}

.wrapper {
display: flex;
flex-direction: column;
flex: 1;
position: relative;
z-index: 2;
padding: 0 32px;
width: 100%;
min-width: 100%;
max-width: 100%;
max-height: 100%;
box-sizing: border-box;
>.header {
height: 136px;
min-height: 136px;
max-height: 136px;
}
>.card {
display: flex;
flex-direction: column;
flex: 1;
overflow: hidden;
background: #fff;
box-shadow: 0 4px 5px -2px rgba(0, 0, 0, .2), 0 7px 10px 1px rgba(0, 0, 0, .14), 0 2px 16px 1px rgba(0, 0, 0, .12);
}
}

.toolbar {
border-bottom: 1px solid rgba(0, 0, 0, .12);
height: 64px;
min-height: 64px;
max-height: 64px;
padding: 0 24px;
}

.content {
display: flex;
flex: 1;
padding: 24px;
overflow: auto
}
18 changes: 16 additions & 2 deletions src/app/page-layouts/page-layouts.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,27 @@ import { LeftSidenavComponent } from './carded/left-sidenav/left-sidenav.compone
import { LeftSidenavTabbedComponent } from './carded/left-sidenav-tabbed/left-sidenav-tabbed.component';
import { RightSidenavComponent } from './carded/right-sidenav/right-sidenav.component';

import { BaseLayoutModule } from '../layouts';

const DEFAULT_PERFECT_SCROLLBAR_CONFIG: PerfectScrollbarConfigInterface = {
suppressScrollX: true
};

@NgModule({
imports: [SharedModule, PageLayoutsRoutingModule, PerfectScrollbarModule],
declarations: [FullwidthComponent, Fullwidth2Component, DemoContentComponent, LeftSidenavComponent, LeftSidenavTabbedComponent, RightSidenavComponent],
imports: [
SharedModule,
PageLayoutsRoutingModule,
PerfectScrollbarModule,
BaseLayoutModule
],
declarations: [
FullwidthComponent,
Fullwidth2Component,
DemoContentComponent,
LeftSidenavComponent,
LeftSidenavTabbedComponent,
RightSidenavComponent
],
providers: [
{
provide: PERFECT_SCROLLBAR_CONFIG,
Expand Down

0 comments on commit 1376ace

Please sign in to comment.