Skip to content

Commit ea14870

Browse files
authored
Merge pull request #527 from cal-smith/issue#256
feat(tabs): add before and after content support to tab headers
2 parents f9048ea + d325aa2 commit ea14870

File tree

3 files changed

+45
-4
lines changed

3 files changed

+45
-4
lines changed

src/tabs/tab-headers.component.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ import { Tab } from "./tab.component";
5050
}"
5151
class="bx--tabs__nav"
5252
role="tablist">
53+
<li role="presentation">
54+
<ng-container *ngIf="contentBefore" [ngTemplateOutlet]="contentBefore"></ng-container>
55+
</li>
5356
<li
5457
*ngFor="let tab of tabs; let i = index;"
5558
[ngClass]="{
@@ -79,11 +82,11 @@ import { Tab } from "./tab.component";
7982
</ng-template>
8083
</a>
8184
</li>
85+
<li role="presentation">
86+
<ng-container *ngIf="contentAfter" [ngTemplateOutlet]="contentAfter"></ng-container>
87+
</li>
8288
</ul>
8389
</nav>
84-
<div>
85-
<ng-content select="ibm-tab"></ng-content>
86-
</div>
8790
`
8891
})
8992

@@ -108,6 +111,9 @@ export class TabHeaders implements AfterContentInit {
108111
*/
109112
@Input() skeleton = false;
110113

114+
@Input() contentBefore;
115+
@Input() contentAfter;
116+
111117
/**
112118
* Gets the Unordered List element that holds the `Tab` headings from the view DOM.
113119
*/

src/tabs/tabs.component.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,17 @@ import { TabHeaders } from "./tab-headers.component";
4444
[skeleton]="skeleton"
4545
[tabs]="tabs"
4646
[followFocus]="followFocus"
47-
[cacheActive]="cacheActive">
47+
[cacheActive]="cacheActive"
48+
[contentBefore]="before"
49+
[contentAfter]="after">
4850
</ibm-tab-headers>
4951
<ng-content></ng-content>
52+
<ng-template #before>
53+
<ng-content select="[before]"></ng-content>
54+
</ng-template>
55+
<ng-template #after>
56+
<ng-content select="[after]"></ng-content>
57+
</ng-template>
5058
<ibm-tab-headers
5159
*ngIf="hasTabHeaders() && position === 'bottom'"
5260
[skeleton]="skeleton"

src/tabs/tabs.stories.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,33 @@ storiesOf("Tabs", module)
5555
]
5656
}
5757
}))
58+
.add("Width before and after content", () => ({
59+
template: `
60+
<div style="font-weight: 600; padding-bottom: 10px; padding-top: 20px;">before</div>
61+
<ibm-tabs [followFocus]="followFocus" [isNavigation]="isNavigation">
62+
<ibm-tab heading="one">foo</ibm-tab>
63+
<ibm-tab heading="two">bar</ibm-tab>
64+
<span before>content before</span>
65+
</ibm-tabs>
66+
<div style="font-weight: 600; padding-bottom: 10px; padding-top: 20px;">after</div>
67+
<ibm-tabs [followFocus]="followFocus" [isNavigation]="isNavigation">
68+
<ibm-tab heading="one">foo</ibm-tab>
69+
<ibm-tab heading="two">bar</ibm-tab>
70+
<span after>content after</span>
71+
</ibm-tabs>
72+
<div style="font-weight: 600; padding-bottom: 10px; padding-top: 20px;">both</div>
73+
<ibm-tabs [followFocus]="followFocus" [isNavigation]="isNavigation">
74+
<ibm-tab heading="one">foo</ibm-tab>
75+
<ibm-tab heading="two">bar</ibm-tab>
76+
<span before>content before</span>
77+
<span after>content after</span>
78+
</ibm-tabs>
79+
`,
80+
props: {
81+
followFocus: boolean("followFocus", true),
82+
isNavigation: boolean("isNavigation", false)
83+
}
84+
}))
5885
.add("Skeleton", () => ({
5986
template: `
6087
<ibm-tabs skeleton="true">

0 commit comments

Comments
 (0)