Skip to content

Commit b9fe75a

Browse files
andrewseguinkara
authored andcommitted
feat(tabs): add ripples to the tab group and nav bar links (#1700)
1 parent b79c953 commit b9fe75a

File tree

5 files changed

+24
-7
lines changed

5 files changed

+24
-7
lines changed

src/lib/tabs/tab-group.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<div class="md-tab-header" role="tablist"
22
(keydown)="handleKeydown($event)">
3-
<div class="md-tab-label" role="tab" md-tab-label-wrapper
3+
<div class="md-tab-label" role="tab" md-tab-label-wrapper md-ripple
44
*ngFor="let tab of _tabs; let i = index"
55
[id]="_getTabLabelId(i)"
66
[tabIndex]="selectedIndex == i ? 0 : -1"

src/lib/tabs/tab-group.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
// Wraps each tab label
1717
.md-tab-label {
1818
@include tab-label;
19+
position: relative;
1920
}
2021

2122
@media ($md-xsmall) {

src/lib/tabs/tab-nav-bar/tab-nav-bar.scss

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
// Wraps each link in the header
1010
[md-tab-link] {
1111
@include tab-label;
12-
text-decoration: none;
12+
text-decoration: none; // Removes anchor underline styling
13+
position: relative;
14+
overflow: hidden; // Keeps the ripple from extending outside the element bounds
1315
}
1416

1517
@media ($md-xsmall) {

src/lib/tabs/tab-nav-bar/tab-nav-bar.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import {Component, Input, ViewChild, ElementRef, ViewEncapsulation, Directive} from '@angular/core';
22
import {MdInkBar} from '../ink-bar';
3+
import {MdRipple} from '../../core/ripple/ripple';
34

45
/**
56
* Navigation component matching the styles of the tab group header.
@@ -41,3 +42,16 @@ export class MdTabLink {
4142

4243
constructor(private _mdTabNavBar: MdTabNavBar, private _element: ElementRef) {}
4344
}
45+
46+
/**
47+
* Simple directive that extends the ripple and matches the selector of the MdTabLink. This
48+
* adds the ripple behavior to nav bar labels.
49+
*/
50+
@Directive({
51+
selector: '[md-tab-link]',
52+
})
53+
export class MdTabLinkRipple extends MdRipple {
54+
constructor(private _element: ElementRef) {
55+
super(_element);
56+
}
57+
}

src/lib/tabs/tabs.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,15 @@ import {
3838
} from '../core';
3939
import {MdTabLabel} from './tab-label';
4040
import {MdTabLabelWrapper} from './tab-label-wrapper';
41-
import {MdTabNavBar, MdTabLink} from './tab-nav-bar/tab-nav-bar';
41+
import {MdTabNavBar, MdTabLink, MdTabLinkRipple} from './tab-nav-bar/tab-nav-bar';
4242
import {MdInkBar} from './ink-bar';
4343
import {Observable} from 'rxjs/Observable';
4444
import 'rxjs/add/operator/map';
45+
import {MdRippleModule} from '../core/ripple/ripple';
4546

4647

4748
/** Used to generate unique ID's for each tab component */
4849
let nextId = 0;
49-
5050
/** A simple change event emitted on focus or selection changes. */
5151
export class MdTabChangeEvent {
5252
index: number;
@@ -375,11 +375,11 @@ export class MdTabBody implements OnInit {
375375
}
376376

377377
@NgModule({
378-
imports: [CommonModule, PortalModule],
378+
imports: [CommonModule, PortalModule, MdRippleModule],
379379
// Don't export MdInkBar or MdTabLabelWrapper, as they are internal implementation details.
380-
exports: [MdTabGroup, MdTabLabel, MdTab, MdTabNavBar, MdTabLink],
380+
exports: [MdTabGroup, MdTabLabel, MdTab, MdTabNavBar, MdTabLink, MdTabLinkRipple],
381381
declarations: [MdTabGroup, MdTabLabel, MdTab, MdInkBar, MdTabLabelWrapper,
382-
MdTabNavBar, MdTabLink, MdTabBody],
382+
MdTabNavBar, MdTabLink, MdTabBody, MdTabLinkRipple],
383383
})
384384
export class MdTabsModule {
385385
static forRoot(): ModuleWithProviders {

0 commit comments

Comments
 (0)