diff --git a/docs/core/info-drawer-tab.md b/docs/core/info-drawer-tab.md new file mode 100644 index 0000000000..f2aac6cb82 --- /dev/null +++ b/docs/core/info-drawer-tab.md @@ -0,0 +1,51 @@ +# Info Drawer Tab component + +![Info drawer screenshot](../docassets/images/label-tab.png) + +## Basic usage + +Render a tab with label: + +```html + + + +
Tab1 content
+
+ + +
Tab2 content
+
+
+``` + +Render tab with icon instead of labels: + +```html + + + +
Tab1 content
+
+ + +
Tab2 content
+
+ +
+``` + +![Info drawer screenshot](../docassets/images/icon-tab.png) + +## Class members + +### Properties + +| Name | Type | Default value | Description | +| -- | -- | -- | -- | +| label | `string` | '' | Tab label. | +| icon | `string` | null | The material design icon. | + +## See also + +- [Info drawer layout component](info-drawer.component.md) diff --git a/docs/core/info-drawer.component.md b/docs/core/info-drawer.component.md index 4edde517e4..c893e84734 100644 --- a/docs/core/info-drawer.component.md +++ b/docs/core/info-drawer.component.md @@ -53,4 +53,5 @@ You can also customize the three regions (title, buttons and content) as with th ## See also -- [Info drawer layout component](info-drawer-layout.component.md) +- [Info drawer layout component](info-drawer-layout.component.md) +- [Info drawer layout component](info-drawer-tab.component.md) diff --git a/docs/docassets/images/icon-tab.png b/docs/docassets/images/icon-tab.png new file mode 100644 index 0000000000..8637d861ae Binary files /dev/null and b/docs/docassets/images/icon-tab.png differ diff --git a/docs/docassets/images/label-tab.png b/docs/docassets/images/label-tab.png new file mode 100644 index 0000000000..612b2f9bf9 Binary files /dev/null and b/docs/docassets/images/label-tab.png differ diff --git a/lib/core/info-drawer/info-drawer.component.html b/lib/core/info-drawer/info-drawer.component.html index 45b406728b..6ffddbc2ad 100644 --- a/lib/core/info-drawer/info-drawer.component.html +++ b/lib/core/info-drawer/info-drawer.component.html @@ -10,6 +10,12 @@ + + + {{ contentBlock.icon }} + + + diff --git a/lib/core/info-drawer/info-drawer.component.spec.ts b/lib/core/info-drawer/info-drawer.component.spec.ts index bc3d0dcfec..e063ca242c 100644 --- a/lib/core/info-drawer/info-drawer.component.spec.ts +++ b/lib/core/info-drawer/info-drawer.component.spec.ts @@ -75,6 +75,8 @@ describe('InfoDrawerComponent', () => { + + ` }) @@ -123,4 +125,12 @@ describe('Custom InfoDrawer', () => { expect(tab.length).toBe(1); expect(tab[0].nativeElement.innerText).toBe('Tab2'); }); + + it('should render a tab with icon', () => { + component.tabIndex = 2; + fixture.detectChanges(); + let tab: any = fixture.debugElement.queryAll(By.css('.mat-tab-label-active')); + expect(tab[0].nativeElement.innerText).not.toBe('Tab3'); + expect(tab[0].nativeElement.innerText).toContain('tab-icon'); + }); }); diff --git a/lib/core/info-drawer/info-drawer.component.ts b/lib/core/info-drawer/info-drawer.component.ts index b838467272..aa093b8b96 100644 --- a/lib/core/info-drawer/info-drawer.component.ts +++ b/lib/core/info-drawer/info-drawer.component.ts @@ -22,9 +22,14 @@ import { MatTabChangeEvent } from '@angular/material'; template: '' }) export class InfoDrawerTabComponent { + /** The title of the tab. */ @Input() label: string = 'Main tab'; + /** Icon to render for the tab. */ + @Input() + icon: string = null; + @ViewChild(TemplateRef) content: TemplateRef; }