Skip to content

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

Merged
jelbourn merged 10 commits into
angular:masterfrom
andrewseguin:tabs-dev
Oct 26, 2016
Merged

jelbourn merged 10 commits into
angular:masterfrom
andrewseguin:tabs-dev

Conversation

@andrewseguin

@andrewseguin andrewseguin commented Oct 24, 2016 •

Copy link
Copy Markdown
Contributor

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
Comment thread src/demo-app/tabs/routes.ts Outdated

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

export const TABS_DEMO_ROUTE: Routes = [

Copy link
Copy Markdown
Contributor

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
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done.

Comment thread src/demo-app/tabs/routes.ts Outdated
{ path: '', redirectTo: 'content-1', pathMatch: 'full' },
{ path: 'content-1', component: RoutedContent1 },
{ path: 'content-2', component: RoutedContent2 },
{ path: 'content-3', component: RoutedContext3 },

Copy link
Copy Markdown
Contributor

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
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done.

Comment thread src/lib/tabs/tab-nav-bar/tab-nav-bar.ts Outdated
@@ -0,0 +1,40 @@
import { Component, Input, ViewChild, ElementRef } from '@angular/core';
import { MdInkBar } from '../ink-bar';

Copy link
Copy Markdown
Contributor

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
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done.

Comment thread src/lib/tabs/tab-nav-bar/tab-nav-bar.ts Outdated
styleUrls: ['tab-nav-bar.css'],
})
export class MdTabNavBar {
@ViewChild(MdInkBar) private _inkBar: MdInkBar;

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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
Copy Markdown
Contributor

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
Copy Markdown
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
Copy Markdown
Contributor

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
Copy Markdown
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
Copy Markdown
Contributor

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
Copy Markdown
Contributor

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?

@marcysutton marcysutton Oct 25, 2016 •

Copy link
Copy Markdown

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
Copy Markdown
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
Copy Markdown
Contributor

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
Copy Markdown
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

@jelbourn jelbourn left a comment

Copy link
Copy Markdown
Contributor

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

Comment thread src/demo-app/tabs/routes.ts Outdated
{ path: '', redirectTo: 'sunny-tab', pathMatch: 'full' },
{ path: 'sunny-tab', component: SunnyTabContent },
{ path: 'rainy-tab', component: RainyTabContent },
{ path: 'foggy-tab', component: FoggyTabContent },

Copy link
Copy Markdown
Contributor

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
Copy Markdown
Contributor

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
Copy Markdown
Contributor

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
Copy Markdown
Contributor Author

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

@jelbourn

Copy link
Copy Markdown
Contributor

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
Copy Markdown

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