Skip to content

Sticky header demo code #6033

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
Aug 1, 2017
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/demo-app/demo-app-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,12 @@ import {
MdToolbarModule,
MdTooltipModule,
OverlayContainer,
StyleModule
StyleModule,
StickyHeaderModule
} from '@angular/material';
import {CdkTableModule} from '@angular/cdk';
import {TableHeaderDemo} from './table/table-header-demo';
import {StickyHeaderDemo} from './sticky-header/sticky-header-demo';

/**
* NgModule that includes all Material modules that are required to serve the demo-app.
Expand Down Expand Up @@ -118,7 +120,8 @@ import {TableHeaderDemo} from './table/table-header-demo';
MdTooltipModule,
MdNativeDateModule,
CdkTableModule,
StyleModule
StyleModule,
StickyHeaderModule
]
})
export class DemoMaterialModule {}
Expand Down Expand Up @@ -184,6 +187,7 @@ export class DemoMaterialModule {}
PlatformDemo,
TypographyDemo,
ExpansionDemo,
StickyHeaderDemo
],
providers: [
{provide: OverlayContainer, useClass: FullscreenOverlayContainer},
Expand Down
3 changes: 2 additions & 1 deletion src/demo-app/demo-app/demo-app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ export class DemoApp {
{name: 'Tooltip', route: 'tooltip'},
{name: 'Platform', route: 'platform'},
{name: 'Style', route: 'style'},
{name: 'Typography', route: 'typography'}
{name: 'Typography', route: 'typography'},
{name: 'Sticky Header', route: 'sticky-header'}
];

constructor(private _element: ElementRef) {
Expand Down
2 changes: 2 additions & 0 deletions src/demo-app/demo-app/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import {DatepickerDemo} from '../datepicker/datepicker-demo';
import {TableDemo} from '../table/table-demo';
import {TypographyDemo} from '../typography/typography-demo';
import {ExpansionDemo} from '../expansion/expansion-demo';
import {StickyHeaderDemo} from '../sticky-header/sticky-header-demo';

export const DEMO_APP_ROUTES: Routes = [
{path: '', component: Home},
Expand Down Expand Up @@ -74,4 +75,5 @@ export const DEMO_APP_ROUTES: Routes = [
{path: 'style', component: StyleDemo},
{path: 'typography', component: TypographyDemo},
{path: 'expansion', component: ExpansionDemo},
{path: 'sticky-header', component: StickyHeaderDemo}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add this to the navItems in demo-app.ts?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Added to navItems in demo-app.ts

];
33 changes: 33 additions & 0 deletions src/demo-app/sticky-header/sticky-header-demo.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<div class="demo-sticky">
<div class="demo-centered" cdk-scrollable>
<div>
<h1>Sticky-header Demo</h1>
</div>

<div class="demo-container">

<div>
<div cdkStickyHeader class="demo-header-style demo-header-color3" >
<h2>Unread Messages</h2>
</div>
<P *ngFor="let item of items">{{item.name}} : {{item.messages}}</P>
</div>

<div cdkStickyRegion >
<div cdkStickyHeader class="demo-header-style demo-header-color2">
<h2>Late Messages</h2>
</div>
<P *ngFor="let item of items">{{item.name}} : {{item.messages}}</P>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change to lower case p?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 <P> -> <p>

<P *ngFor="let item of items">{{item.name}} : {{item.messages}}</P>
</div>

<div cdkStickyRegion>
<div cdkStickyHeader class="demo-header-style demo-header-color1" >
<h2>Read Messages</h2>
</div>
<P *ngFor="let item of items">{{item.name}} : {{item.messages}}</P>
<P *ngFor="let item of items">{{item.name}} : {{item.messages}}</P>
</div>
</div>
</div>
</div>
80 changes: 80 additions & 0 deletions src/demo-app/sticky-header/sticky-header-demo.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
.demo-sticky {
.demo-centered {
text-align: left;
-webkit-appearance: none;
-moz-appearance: none;
height: 500px;
overflow: auto;}

button {
position: fixed;
margin: 16px;
z-index: 99;
}

* {
margin: 0;
padding: 0;
}

body {
font: 14px/1.5 Helvetica, Arial, sans-serif;
-webkit-appearance: none;
-moz-appearance: none;

}

h1 {
font-size: 20px;
padding: 20px;
-webkit-appearance: none;
-moz-appearance: none;
}

h2 {
font-size: 20px;
padding: 20px;
-webkit-appearance: none;
-moz-appearance: none;
}

p {
text-indent: 4em;
padding:15px;
-webkit-appearance: none;
-moz-appearance: none;
}

div{
margin: 0; border: 0; padding: 0;
-webkit-appearance: none;
-moz-appearance: none;
}
}

.mat-radio-button {
display: block;
}

.demo-container {
margin: 0;
-webkit-appearance: none;
-moz-appearance: none;
}

.demo-header-style{
-webkit-appearance: none;
padding: 20px;
}

.demo-header-color1 {
background: #cecece;
}

.demo-header-color2 {
background: #cea7a7;
}

.demo-header-color3 {
background: #c2eae5;
}
27 changes: 27 additions & 0 deletions src/demo-app/sticky-header/sticky-header-demo.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import {Component} from '@angular/core';
import {BrowserModule} from '@angular/platform-browser';
import {CdkStickyRegion, CdkStickyHeader} from '@angular/material';


@Component({
moduleId: module.id,
selector: 'sticky-header-demo',
templateUrl: 'sticky-header-demo.html',
styleUrls: ['sticky-header-demo.css'],
})

export class StickyHeaderDemo {
items: any[] = [
{name: 'Min', messages: 'Brunch is this weekend?'},
{name: 'Li', messages: 'Yes'},
{name: 'Chan', messages: 'Looking'},
{name: 'Chan', messages: 'Forward'},
{name: 'Chan', messages: 'To It !'},
{name: 'Min', messages: 'Branch is this weekend?'},
{name: 'Eat', messages: 'Green Peppers'},
{name: 'Chan', messages: 'Where?'},
{name: 'Jack', messages: 'Pirate!'},
{name: 'Jone', messages: 'Black pearl'},
{name: 'Jack', messages: 'Back to the sea!'},
];
}