Repository navigation
feat(tab-nav-bar): add initial functionality of tab nav bar - #1589
Conversation
|
|
||
| import {RoutedContent1, RoutedContent2, RoutedContext3} from '../tabs/tabs-demo'; | ||
|
|
||
| export const TABS_DEMO_ROUTE: Routes = [ |
There was a problem hiding this comment.
TABS_DEMO_ROUTES (plural)
| { path: '', redirectTo: 'content-1', pathMatch: 'full' }, | ||
| { path: 'content-1', component: RoutedContent1 }, | ||
| { path: 'content-2', component: RoutedContent2 }, | ||
| { path: 'content-3', component: RoutedContext3 }, |
There was a problem hiding this comment.
I'd use a different name for the routed content components to be super clear that they're examples and that people don't have to call their components "RoutedContentX". Popular examples are food, weather, pokemon...
| @@ -0,0 +1,40 @@ | |||
| import { Component, Input, ViewChild, ElementRef } from '@angular/core'; | |||
| import { MdInkBar } from '../ink-bar'; | |||
There was a problem hiding this comment.
No spaces inside imports (this might be a WebStorm settings)
| styleUrls: ['tab-nav-bar.css'], | ||
| }) | ||
| export class MdTabNavBar { | ||
| @ViewChild(MdInkBar) private _inkBar: MdInkBar; |
There was a problem hiding this comment.
@ViewChild can't be applied to a private member (since Angular itself is external to this class and has to touch it).
| export class MdTabNavBar { | ||
| @ViewChild(MdInkBar) private _inkBar: MdInkBar; | ||
|
|
||
| updateActiveLink(element: HTMLElement) { |
There was a problem hiding this comment.
Add function description comment
| import { Component, Input, ViewChild, ElementRef } from '@angular/core'; | ||
| import { MdInkBar } from '../ink-bar'; | ||
|
|
||
| @Component({ |
There was a problem hiding this comment.
Add class description for what this component does (since it's not one of the totally obvious ones like radio-button).
| $md-tab-bar-height: 48px !default; | ||
|
|
||
|
|
||
| @mixin tab-label { |
There was a problem hiding this comment.
Add comment explaining what the mixin is for
| @@ -0,0 +1,4 @@ | |||
| <div class="md-tab-header"> | |||
There was a problem hiding this comment.
I'm thinking that this should probably be a <nav> element instead of a div.
@marcysutton Is it appropriate to always use a <nav> element for a component that contains anchors and navigates the page, or should <nav> only be used for major site navigation?
There was a problem hiding this comment.
Help me level-set: is the set of anchors visually like tabs, but without the associated tabpanels and ARIA tab semantics/keyboard behavior?
The difference between a <div> and <nav> is that the latter has a landmark role, making it easy for a screen reader user to discover. I think this component would be a reasonable use case for how I've seen tabs presented in the Material Design spec. Unless you anticipate so many of them on a page they dominate the landmarks list, I don't see much of a downside.
If you do end up using <nav>, I'd recommend labeling the element with an aria-label so it can be easily identified as a screen reader landmark.
Edit: I thought I had sent this comment days ago, but I'm still not used to the Review workflow apparently.
There was a problem hiding this comment.
Thanks for the input Marcy. Jeremy and I discussed this and agree that we can move this responsibility to the user by making this a component with an attribute selector.
Usage of this component will be written by the user as such:
<nav md-tab-nav-bar aria-label="navigation links"> ... </nav>
| private _isActive: boolean = false; | ||
|
|
||
| @Input() | ||
| get active(): boolean { |
There was a problem hiding this comment.
I didn't know about this before, but looking through the router docs turned up this:
https://angular.io/docs/ts/latest/guide/router.html#!#router-link-active
Seems like we could rely on that to apply the appropriate class based on the route being active
There was a problem hiding this comment.
Adding a comment that addresses the workaround in our demo app because we lack an isActive api on routerLinks
jelbourn
left a comment
There was a problem hiding this comment.
Just a few more things I noticed
| { path: '', redirectTo: 'sunny-tab', pathMatch: 'full' }, | ||
| { path: 'sunny-tab', component: SunnyTabContent }, | ||
| { path: 'rainy-tab', component: RainyTabContent }, | ||
| { path: 'foggy-tab', component: FoggyTabContent }, |
There was a problem hiding this comment.
Remove the leading/trailing spaces in object literals
| display: block; | ||
| } | ||
|
|
||
| a[md-tab-link] { |
There was a problem hiding this comment.
I'd remove the a part of this selector just to reduce the specificity.
| @@ -0,0 +1,51 @@ | |||
| @import '../core/style/variables'; | |||
There was a problem hiding this comment.
This file should either consist of exclusively mixins or exclusively concrete styles.
If it's the former, then the file name should start with an underscore (which tells the sass compiler that it's a "partial" file that doesn't have output).
If it's the latter, it should be included in the "styleUrls" for each of the components that use it (rather than doing a sass @import)
|
Thanks for the review, I made the tabs common to be purely mixins |
|
LGTM- nice work! |
|
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Initial development of the tab nav bar
Closes #524