Skip to content

Commit b932b71

Browse files
committed
feat(tabs/bottomNav): return icon and label from relatedPanel #4297
1 parent df5babd commit b932b71

File tree

2 files changed

+57
-18
lines changed

2 files changed

+57
-18
lines changed

projects/igniteui-angular/src/lib/tabbar/tabbar.component.ts

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,7 @@ export class IgxBottomNavComponent implements AfterViewInit {
9393
* @memberof IgxBottomNavComponent
9494
*/
9595
public get tabs(): QueryList<IgxTabComponent> {
96-
if (this.hasContentTabs) {
97-
return this.contentTabs;
98-
}
99-
return this.viewTabs;
96+
return this.hasContentTabs ? this.contentTabs : this.viewTabs;
10097
}
10198

10299
/**
@@ -475,6 +472,11 @@ export class IgxTabComponent {
475472
@Input()
476473
public relatedPanel: IgxTabPanelComponent;
477474

475+
/**
476+
*@hidden
477+
*/
478+
private _label: string;
479+
478480
/**
479481
* Sets/gets the `label` of the tab panel.
480482
* ```html
@@ -486,20 +488,41 @@ export class IgxTabComponent {
486488
* @memberof IgxTabComponent
487489
*/
488490
@Input()
489-
public label: string;
491+
public get label(): string {
492+
return this.relatedPanel ? this.relatedPanel.label : this._label;
493+
}
494+
public set label(newValue: string) {
495+
if (this.relatedPanel) {
496+
this.relatedPanel.label = newValue;
497+
}
498+
this._label = newValue;
499+
}
500+
501+
/**
502+
*@hidden
503+
*/
504+
private _icon: string;
490505

491506
/**
492507
* Sets/gets the `icon` of the tab panel.
493508
* ```html
494-
* <igx-tab [icon] = "panel_icon"><igx-tab>
509+
* <igx-tab [icon] = "tab_icon"><igx-tab>
495510
* ```
496511
* ```typescript
497512
* let tabIcon = this.tab.icon;
498513
* ```
499514
* @memberof IgxTabComponent
500515
*/
501516
@Input()
502-
public icon: string;
517+
public get icon(): string {
518+
return this.relatedPanel ? this.relatedPanel.icon : this._icon;
519+
}
520+
public set icon(newValue: string) {
521+
if (this.relatedPanel) {
522+
this.relatedPanel.icon = newValue;
523+
}
524+
this._icon = newValue;
525+
}
503526

504527
/**
505528
*@hidden
@@ -613,10 +636,7 @@ export class IgxTabComponent {
613636
* ```
614637
*/
615638
public get context(): any {
616-
if (this.relatedPanel) {
617-
return this.relatedPanel;
618-
}
619-
return this;
639+
return this.relatedPanel ? this.relatedPanel : this;
620640
}
621641

622642
constructor(private _tabBar: IgxBottomNavComponent, private _element: ElementRef) {

projects/igniteui-angular/src/lib/tabs/tab-item.component.ts

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ export class IgxTabItemComponent implements IgxTabItemBase {
2727
@Input()
2828
public relatedGroup: IgxTabsGroupComponent;
2929

30+
/**@hidden*/
31+
private _icon: string;
32+
3033
/**
3134
* An @Input property that sets the value of the `icon`.
3235
* The value should be valid icon name from {@link https://material.io/tools/icons/?style=baseline}.
@@ -35,16 +38,35 @@ export class IgxTabItemComponent implements IgxTabItemBase {
3538
*```
3639
*/
3740
@Input()
38-
public icon: string;
41+
public get icon(): string {
42+
return this.relatedGroup ? this.relatedGroup.icon : this._icon;
43+
}
44+
public set icon(newValue: string) {
45+
if (this.relatedGroup) {
46+
this.relatedGroup.icon = newValue;
47+
}
48+
this._icon = newValue;
49+
}
50+
51+
/**@hidden*/
52+
private _label: string;
3953

4054
/**
4155
* An @Input property that sets the value of the `label`.
4256
*```html
43-
*<igx-tabs-item label="Tab 1" icon="folder">
57+
*<igx-tabs-item label="Tab 2" icon="folder">
4458
*```
4559
*/
4660
@Input()
47-
public label: string;
61+
public get label(): string {
62+
return this.relatedGroup ? this.relatedGroup.label : this._label;
63+
}
64+
public set label(newValue: string) {
65+
if (this.relatedGroup) {
66+
this.relatedGroup.label = newValue;
67+
}
68+
this._label = newValue;
69+
}
4870

4971
/**@hidden*/
5072
@ViewChild('defaultTabTemplate', { read: TemplateRef })
@@ -162,10 +184,7 @@ export class IgxTabItemComponent implements IgxTabItemBase {
162184
*/
163185
@Input()
164186
get disabled(): boolean {
165-
if (this.relatedGroup) {
166-
return this.relatedGroup.disabled;
167-
}
168-
return this._disabled;
187+
return this.relatedGroup ? this.relatedGroup.disabled : this._disabled;
169188
}
170189
set disabled(newValue: boolean) {
171190
if (this.relatedGroup) {

0 commit comments

Comments
 (0)