Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(tab-title): tabs center when set to layout='center' #7026

Merged
merged 13 commits into from
May 26, 2023
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion src/components/tab-title/tab-title.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
:host([layout="center"]) {
@apply my-0 mx-5 text-center;
flex-basis: theme("spacing.48");
margin: auto;
.content {
@apply m-auto;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

given that there's no difference between margin: auto and @apply m-auto I'd recommend using margin: auto it's more readable

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we're using tailwind for now, it makes sense to stick to tailwind classes if they are available, for consistency. This is what we've been doing so far. Also, overlapping uses of tailwind and regular css props might create oversight doubling use of both by accident.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, lets keep tailwind for now for consistency. Hopefully we can remove tailwind in the future.

}
}

:host([position="bottom"]) .container {
Expand Down Expand Up @@ -190,11 +192,21 @@
}
}

:host([closable]) {
.content {
padding-inline-start: 1.5rem;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alisonailea @Elijbet are there any tokens we can use as values for these paddings?f

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this padding should be referenced from theme()/tailwind we could do it as a followup.

Copy link
Contributor Author

@Elijbet Elijbet May 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me see what design says about the centering approach in general (will determine the padding amount) and yeah that would be the next question.

padding-inline-end: 1.25rem;
}
}

:host([closable]) .container,
:host([bordered]) .container {
border-block-end-style: unset;
border-inline-start: 1px solid transparent;
border-inline-end: 1px solid transparent;
.close-button {
margin-inline: 0;
}
}

:host([closable][position="bottom"]) .container,
Expand Down
49 changes: 49 additions & 0 deletions src/components/tabs/tabs.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,55 @@ export const disabledTabsAndMediumIconsForLargeTabsTitle_TestOnly = (): string =
</calcite-tabs>
`;

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

export const centeredClosable_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-start="arrow-left" closable>Tab 2 Title</calcite-tab-title>
<calcite-tab-title icon-end="arrow-right" closable>Tab 3 Title</calcite-tab-title>
<calcite-tab-title icon-start="arrow-left" icon-end="arrow-right" closable selected
>Tab 4 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-tab><p>Tab 4 Content</p></calcite-tab>
</calcite-tabs>
`;

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

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