-
Notifications
You must be signed in to change notification settings - Fork 6.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(tab-nav-bar): add initial functionality of tab nav bar (#1589)
- Loading branch information
1 parent
9e849cf
commit 572b36e
Showing
19 changed files
with
329 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import {Routes} from '@angular/router'; | ||
|
||
import {SunnyTabContent, RainyTabContent, FoggyTabContent} from '../tabs/tabs-demo'; | ||
|
||
export const TABS_DEMO_ROUTES: Routes = [ | ||
{path: '', redirectTo: 'sunny-tab', pathMatch: 'full'}, | ||
{path: 'sunny-tab', component: SunnyTabContent}, | ||
{path: 'rainy-tab', component: RainyTabContent}, | ||
{path: 'foggy-tab', component: FoggyTabContent}, | ||
]; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import {NgModule} from '@angular/core'; | ||
import {MaterialModule} from '@angular/material'; | ||
import {FormsModule} from '@angular/forms'; | ||
import {BrowserModule} from '@angular/platform-browser'; | ||
import {RouterModule} from '@angular/router'; | ||
|
||
import {TabsDemo, SunnyTabContent, RainyTabContent, FoggyTabContent} from './tabs-demo'; | ||
|
||
@NgModule({ | ||
imports: [ | ||
FormsModule, | ||
BrowserModule, | ||
MaterialModule, | ||
RouterModule, | ||
], | ||
declarations: [ | ||
TabsDemo, | ||
SunnyTabContent, | ||
RainyTabContent, | ||
FoggyTabContent, | ||
] | ||
}) | ||
export class TabsDemoModule {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
.demo-nav-bar { | ||
border: 1px solid #e0e0e0; | ||
[md-tab-nav-bar] { | ||
background: #f9f9f9; | ||
} | ||
sunny-routed-content, | ||
rainy-routed-content, | ||
foggy-routed-content { | ||
display: block; | ||
padding: 12px; | ||
} | ||
} | ||
|
||
.demo-tab-group { | ||
border: 1px solid #e0e0e0; | ||
.md-tab-header { | ||
background: #f9f9f9; | ||
} | ||
.md-tab-body { | ||
padding: 12px; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import {Component, ViewEncapsulation} from '@angular/core'; | ||
import {Router} from '@angular/router'; | ||
import {Observable} from 'rxjs/Observable'; | ||
|
||
@Component({ | ||
moduleId: module.id, | ||
selector: 'tabs-demo', | ||
templateUrl: 'tabs-demo.html', | ||
styleUrls: ['tabs-demo.css'], | ||
encapsulation: ViewEncapsulation.None, | ||
}) | ||
export class TabsDemo { | ||
tabLinks = [ | ||
{ label: 'Sun', link: 'sunny-tab'}, | ||
{ label: 'Rain', link: 'rainy-tab'}, | ||
{ label: 'Fog', link: 'foggy-tab'}, | ||
]; | ||
activeLinkIndex = 0; | ||
|
||
tabs = [ | ||
{ label: 'Tab One', content: 'This is the body of the first tab' }, | ||
{ label: 'Tab Two', content: 'This is the body of the second tab' }, | ||
{ label: 'Tab Three', content: 'This is the body of the third tab' }, | ||
]; | ||
|
||
asyncTabs: Observable<any>; | ||
|
||
constructor(private router: Router) { | ||
this.asyncTabs = Observable.create((observer: any) => { | ||
setTimeout(() => { | ||
observer.next(this.tabs); | ||
}, 1000); | ||
}); | ||
|
||
// Initialize the index by checking if a tab link is contained in the url. | ||
// This is not an ideal check and can be removed if routerLink exposes if it is active. | ||
// https://github.com/angular/angular/pull/12525 | ||
this.activeLinkIndex = | ||
this.tabLinks.findIndex(routedTab => router.url.indexOf(routedTab.link) != -1); | ||
} | ||
} | ||
|
||
|
||
@Component({ | ||
moduleId: module.id, | ||
selector: 'sunny-routed-content', | ||
template: 'This is the routed body of the sunny tab.', | ||
}) | ||
export class SunnyTabContent {} | ||
|
||
|
||
@Component({ | ||
moduleId: module.id, | ||
selector: 'rainy-routed-content', | ||
template: 'This is the routed body of the rainy tab.', | ||
}) | ||
export class RainyTabContent {} | ||
|
||
|
||
@Component({ | ||
moduleId: module.id, | ||
selector: 'foggy-routed-content', | ||
template: 'This is the routed body of the foggy tab.', | ||
}) | ||
export class FoggyTabContent {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
@import '../core/style/variables'; | ||
|
||
$md-tab-bar-height: 48px !default; | ||
|
||
// Mixin styles for labels that are contained within the tab header. | ||
@mixin tab-label { | ||
line-height: $md-tab-bar-height; | ||
height: $md-tab-bar-height; | ||
padding: 0 12px; | ||
font-size: $md-body-font-size-base; | ||
font-family: $md-font-family; | ||
font-weight: 500; | ||
cursor: pointer; | ||
box-sizing: border-box; | ||
color: currentColor; | ||
opacity: 0.6; | ||
min-width: 160px; | ||
text-align: center; | ||
&:focus { | ||
outline: none; | ||
opacity: 1; | ||
} | ||
} | ||
|
||
// Mixin styles for the top section of the view; contains the tab labels. | ||
@mixin tab-header { | ||
overflow: hidden; | ||
position: relative; | ||
display: flex; | ||
flex-direction: row; | ||
flex-shrink: 0; | ||
} | ||
|
||
// Mixin styles for the ink bar that displays near the active tab in the header. | ||
@mixin ink-bar { | ||
position: absolute; | ||
bottom: 0; | ||
height: 2px; | ||
transition: 350ms ease-out; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './tab-nav-bar'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<ng-content></ng-content> | ||
<md-ink-bar></md-ink-bar> |
Oops, something went wrong.