Skip to content
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

feat(tab-nav-bar): add initial functionality of tab nav bar #1589

Merged
merged 10 commits into from
Oct 26, 2016

Conversation

andrewseguin
Copy link
Contributor

@andrewseguin andrewseguin commented Oct 24, 2016

Initial development of the tab nav bar

Closes #524

@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Oct 24, 2016

import {RoutedContent1, RoutedContent2, RoutedContext3} from '../tabs/tabs-demo';

export const TABS_DEMO_ROUTE: Routes = [
Copy link
Member

Choose a reason for hiding this comment

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

TABS_DEMO_ROUTES (plural)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

{ path: '', redirectTo: 'content-1', pathMatch: 'full' },
{ path: 'content-1', component: RoutedContent1 },
{ path: 'content-2', component: RoutedContent2 },
{ path: 'content-3', component: RoutedContext3 },
Copy link
Member

Choose a reason for hiding this comment

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

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...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@@ -0,0 +1,40 @@
import { Component, Input, ViewChild, ElementRef } from '@angular/core';
import { MdInkBar } from '../ink-bar';
Copy link
Member

Choose a reason for hiding this comment

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

No spaces inside imports (this might be a WebStorm settings)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

styleUrls: ['tab-nav-bar.css'],
})
export class MdTabNavBar {
@ViewChild(MdInkBar) private _inkBar: MdInkBar;
Copy link
Member

Choose a reason for hiding this comment

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

@ViewChild can't be applied to a private member (since Angular itself is external to this class and has to touch it).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

export class MdTabNavBar {
@ViewChild(MdInkBar) private _inkBar: MdInkBar;

updateActiveLink(element: HTMLElement) {
Copy link
Member

Choose a reason for hiding this comment

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

Add function description comment

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

import { Component, Input, ViewChild, ElementRef } from '@angular/core';
import { MdInkBar } from '../ink-bar';

@Component({
Copy link
Member

Choose a reason for hiding this comment

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

Add class description for what this component does (since it's not one of the totally obvious ones like radio-button).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

$md-tab-bar-height: 48px !default;


@mixin tab-label {
Copy link
Member

Choose a reason for hiding this comment

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

Add comment explaining what the mixin is for

@@ -0,0 +1,4 @@
<div class="md-tab-header">
Copy link
Member

Choose a reason for hiding this comment

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

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?

Copy link

@marcysutton marcysutton Oct 25, 2016

Choose a reason for hiding this comment

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

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

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 {
Copy link
Member

Choose a reason for hiding this comment

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

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Adding a comment that addresses the workaround in our demo app because we lack an isActive api on routerLinks

Copy link
Member

@jelbourn jelbourn left a comment

Choose a reason for hiding this comment

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

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 },
Copy link
Member

Choose a reason for hiding this comment

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

Remove the leading/trailing spaces in object literals

display: block;
}

a[md-tab-link] {
Copy link
Member

Choose a reason for hiding this comment

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

I'd remove the a part of this selector just to reduce the specificity.

@@ -0,0 +1,51 @@
@import '../core/style/variables';
Copy link
Member

Choose a reason for hiding this comment

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

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)

@andrewseguin
Copy link
Contributor Author

Thanks for the review, I made the tabs common to be purely mixins

@jelbourn
Copy link
Member

LGTM- nice work!

@jelbourn jelbourn merged commit 572b36e into angular:master Oct 26, 2016
@andrewseguin andrewseguin deleted the tabs-dev branch October 27, 2016 22:19
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
cla: yes PR author has agreed to Google's Contributor License Agreement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Tabs + Routing
4 participants