Skip to content

Commit

Permalink
fix(tab-nav): justify centered tab-titles evenly to extend across t…
Browse files Browse the repository at this point in the history
…he width of `tab-nav` (#7047)

**Related Issue:** #7025 

## Summary

Follow-up to fix to #7026.

Centered `tabs` should spread the `tab-titles` evenly to extend across
the entire width of `tab-nav`, as opposed to `inline tab-titles` that
only justify against the start of `tab-nav` width.

Added coverage for both `centeredTabsAreEvenlyJustifiedAcrossNavWidth`
and `inlineTabsJustifyAgainstTheStartOfTheNavWidth`.
  • Loading branch information
Elijbet authored May 27, 2023
1 parent c2d8c79 commit 8ef0421
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/components/tab-nav/tab-nav.scss
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@
ease-out;
}

:host([layout="center"]) .tab-nav {
@apply justify-evenly;
}

:host([position="bottom"]) .tab-nav-active-indicator {
inset-block-end: unset;
@apply top-0;
Expand Down
7 changes: 5 additions & 2 deletions src/components/tab-title/tab-title.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@
margin-inline-end: theme("margin.5");
}

:host([layout="center"]) {
@apply my-0 mx-5 text-center;
:host([layout="center"][scale="s"]),
:host([layout="center"][scale="m"]),
:host([layout="center"][scale="l"]) {
@apply my-0 text-center;
margin-inline-end: theme("margin.0");
flex-basis: theme("spacing.48");
.content {
@apply m-auto;
Expand Down
30 changes: 30 additions & 0 deletions src/components/tabs/tabs.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,36 @@ export const centeredBorderedClosable_TestOnly = (): string => html`
</calcite-tabs>
`;

export const centeredTabsAreEvenlyJustifiedAcrossNavWidth_TestOnly = (): string => html`
<calcite-tabs layout="center">
<calcite-tab-nav slot="title-group">
<calcite-tab-title closable>Tab 1 Title</calcite-tab-title>
<calcite-tab-title icon-end="arrow-right" closable>Tab 2 Title</calcite-tab-title>
<calcite-tab-title icon-start="arrow-left" icon-end="arrow-right" closable selected
>Tab 3 Title</calcite-tab-title
>
</calcite-tab-nav>
<calcite-tab><p>Tab 1 Content</p></calcite-tab>
<calcite-tab><p>Tab 2 Content</p></calcite-tab>
<calcite-tab><p>Tab 3 Content</p></calcite-tab>
</calcite-tabs>
`;

export const inlineTabsJustifyAgainstTheStartOfTheNavWidth_TestOnly = (): string => html`
<calcite-tabs layout="inline">
<calcite-tab-nav slot="title-group">
<calcite-tab-title closable>Tab 1 Title</calcite-tab-title>
<calcite-tab-title icon-end="arrow-right" closable>Tab 2 Title</calcite-tab-title>
<calcite-tab-title icon-start="arrow-left" icon-end="arrow-right" closable selected
>Tab 3 Title</calcite-tab-title
>
</calcite-tab-nav>
<calcite-tab><p>Tab 1 Content</p></calcite-tab>
<calcite-tab><p>Tab 2 Content</p></calcite-tab>
<calcite-tab><p>Tab 3 Content</p></calcite-tab>
</calcite-tabs>
`;

export const TabChildrenWithPercentageHeights = (): string => html`
<calcite-tabs style="height: 250px;">
<calcite-tab-nav slot="title-group">
Expand Down

0 comments on commit 8ef0421

Please sign in to comment.