Skip to content

Commit

Permalink
extract ripple directive from the md tab link
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewseguin committed Nov 9, 2016
1 parent 0b4a466 commit f88baad
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
15 changes: 13 additions & 2 deletions src/lib/tabs/tab-nav-bar/tab-nav-bar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export class MdTabNavBar {
@Directive({
selector: '[md-tab-link]',
})
export class MdTabLink extends MdRipple {
export class MdTabLink {
private _isActive: boolean = false;

@Input()
Expand All @@ -40,7 +40,18 @@ export class MdTabLink extends MdRipple {
}
}

constructor(private _mdTabNavBar: MdTabNavBar, private _element: ElementRef) {
constructor(private _mdTabNavBar: MdTabNavBar, private _element: ElementRef) {}
}

/**
* Simple directive that extends the ripple and matches the selector of the MdTabLink. This
* adds the ripple behavior to nav bar labels.
*/
@Directive({
selector: '[md-tab-link]',
})
export class MdTabLinkRipple extends MdRipple {
constructor(private _element: ElementRef) {
super(_element);
}
}
7 changes: 3 additions & 4 deletions src/lib/tabs/tabs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import {
} from '../core';
import {MdTabLabel} from './tab-label';
import {MdTabLabelWrapper} from './tab-label-wrapper';
import {MdTabNavBar, MdTabLink} from './tab-nav-bar/tab-nav-bar';
import {MdTabNavBar, MdTabLink, MdTabLinkRipple} from './tab-nav-bar/tab-nav-bar';
import {MdInkBar} from './ink-bar';
import {Observable} from 'rxjs/Observable';
import 'rxjs/add/operator/map';
Expand All @@ -35,7 +35,6 @@ import {MdRippleModule} from '../core/ripple/ripple';

/** Used to generate unique ID's for each tab component */
let nextId = 0;

/** A simple change event emitted on focus or selection changes. */
export class MdTabChangeEvent {
index: number;
Expand Down Expand Up @@ -255,9 +254,9 @@ export class MdTabGroup {
@NgModule({
imports: [CommonModule, PortalModule, MdRippleModule],
// Don't export MdInkBar or MdTabLabelWrapper, as they are internal implementation details.
exports: [MdTabGroup, MdTabLabel, MdTab, MdTabNavBar, MdTabLink],
exports: [MdTabGroup, MdTabLabel, MdTab, MdTabNavBar, MdTabLink, MdTabLinkRipple],
declarations: [MdTabGroup, MdTabLabel, MdTab, MdInkBar, MdTabLabelWrapper,
MdTabNavBar, MdTabLink],
MdTabNavBar, MdTabLink, MdTabLinkRipple],
})
export class MdTabsModule {
static forRoot(): ModuleWithProviders {
Expand Down

0 comments on commit f88baad

Please sign in to comment.