mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-06-30 18:15:11 +00:00
[ADF-2627] Icons-only mode for Info Drawer (#3398)
* tab with icon * docs * test
This commit is contained in:
parent
fd729e76c0
commit
648ac585b4
51
docs/core/info-drawer-tab.md
Normal file
51
docs/core/info-drawer-tab.md
Normal file
@ -0,0 +1,51 @@
|
||||
# Info Drawer Tab component
|
||||
|
||||

|
||||
|
||||
## Basic usage
|
||||
|
||||
Render a tab with label:
|
||||
|
||||
```html
|
||||
<adf-info-drawer>
|
||||
|
||||
<adf-info-drawer-tab [label]="'Tab1'">
|
||||
<div> Tab1 content</div>
|
||||
</adf-info-drawer-tab>
|
||||
|
||||
<adf-info-drawer-tab [label]="'Tab2'">
|
||||
<div> Tab2 content</div>
|
||||
</adf-info-drawer-tab>
|
||||
</adf-info-drawer>
|
||||
```
|
||||
|
||||
Render tab with icon instead of labels:
|
||||
|
||||
```html
|
||||
<adf-info-drawer>
|
||||
|
||||
<adf-info-drawer-tab [label]="'Tab1'" icon="comment">
|
||||
<div> Tab1 content</div>
|
||||
</adf-info-drawer-tab>
|
||||
|
||||
<adf-info-drawer-tab [label]="'Tab2'" icon="people">
|
||||
<div> Tab2 content</div>
|
||||
</adf-info-drawer-tab>
|
||||
|
||||
</adf-info-drawer>
|
||||
```
|
||||
|
||||

|
||||
|
||||
## 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)
|
@ -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)
|
||||
|
BIN
docs/docassets/images/icon-tab.png
Normal file
BIN
docs/docassets/images/icon-tab.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 12 KiB |
BIN
docs/docassets/images/label-tab.png
Normal file
BIN
docs/docassets/images/label-tab.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 13 KiB |
@ -10,6 +10,12 @@
|
||||
<mat-tab-group [(selectedIndex)]="selectedIndex" class="adf-info-drawer-tabs" (selectedTabChange)="onTabChange($event)">
|
||||
<ng-container *ngFor="let contentBlock of contentBlocks">
|
||||
<mat-tab [label]="contentBlock.label" class="adf-info-drawer-tab">
|
||||
<ng-container *ngIf="contentBlock.icon">
|
||||
<ng-template mat-tab-label>
|
||||
<mat-icon>{{ contentBlock.icon }}</mat-icon>
|
||||
</ng-template>
|
||||
</ng-container>
|
||||
|
||||
<ng-container *ngTemplateOutlet="contentBlock.content"></ng-container>
|
||||
</mat-tab>
|
||||
</ng-container>
|
||||
|
@ -75,6 +75,8 @@ describe('InfoDrawerComponent', () => {
|
||||
</adf-info-drawer-tab>
|
||||
<adf-info-drawer-tab label="Tab2">
|
||||
</adf-info-drawer-tab>
|
||||
<adf-info-drawer-tab label="Tab3" icon="tab-icon">
|
||||
</adf-info-drawer-tab>
|
||||
</adf-info-drawer>
|
||||
`
|
||||
})
|
||||
@ -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');
|
||||
});
|
||||
});
|
||||
|
@ -22,9 +22,14 @@ import { MatTabChangeEvent } from '@angular/material';
|
||||
template: '<ng-template><ng-content></ng-content></ng-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<any>;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user