Skip to content

Commit

Permalink
fix(tabs): address issues from comments
Browse files Browse the repository at this point in the history
- Update the sample for nested tabs
  • Loading branch information
desig9stein committed Nov 19, 2024
1 parent 29e81b1 commit 074d059
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 15 deletions.
8 changes: 5 additions & 3 deletions src/components/tabs/themes/tab.base.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
@use 'sass:map';

[part~='tab-header'] {
$transition: .3s cubic-bezier(.35, 0, .25, 1);
$transition: .3s $tabs-animation-function;

display: flex;
scroll-snap-align: var(--_ig-tab-snap);
Expand All @@ -15,8 +15,8 @@
justify-content: center;
pointer-events: all;
height: 100%;
max-width: var(--tab-max-width--justify, var(--tab-max-width));
min-width: var(--tab-min-width);
max-width: var(--tab-max-width--justify, $tab-max-width);
min-width: $tab-min-width;
cursor: pointer;
position: relative;
z-index: map.get($tabs-z-index, 'header');
Expand Down Expand Up @@ -74,6 +74,8 @@
height: 100%;
grid-row: 3;
grid-column: 1 / -1;

// The value of --_ig-tabs-width is calculated in TypeScript and represents the width of the ig-tabs component
max-width: var(--_ig-tabs-width);
transition: transform 250ms ease-in-out;
}
Expand Down
15 changes: 5 additions & 10 deletions src/components/tabs/themes/tabs.base.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@

:host {
--scroll-btn-size: #{rem(48px)};
--tab-max-width: #{rem(360px)};
--tab-min-width: #{rem(90px)};
--_border-size: #{rem(1px)};

display: block;
Expand Down Expand Up @@ -53,14 +51,13 @@
}

[part~='scrollable'] {
/* stylelint-disable */
/* stylelint-disable-next-line max-line-length */
grid-template-columns: var(--scroll-btn-size) repeat(var(--_tabs-count), minmax(max-content, auto)) var(--scroll-btn-size);
/* stylelint-enable */
}

[part~='inner']:not([part~='scrollable']) {
grid-template-columns: repeat(var(--_tabs-count), minmax(auto, min-content));
min-width: var(--tab-min-width);
min-width: $tab-min-width;
}

:host([alignment='start']) {
Expand Down Expand Up @@ -99,12 +96,12 @@

[part~='scrollable'] {
/* stylelint-disable */
grid-template-columns: var(--scroll-btn-size) repeat(var(--_tabs-count), minmax(var(--tab-min-width), 1fr)) var(--scroll-btn-size);
grid-template-columns: var(--scroll-btn-size) repeat(var(--_tabs-count), minmax($tab-min-width, 1fr)) var(--scroll-btn-size);
/* stylelint-enable */
}

[part~='inner']:not([part~='scrollable']) {
grid-template-columns: repeat(var(--_tabs-count), minmax(var(--tab-min-width), auto));
grid-template-columns: repeat(var(--_tabs-count), minmax($tab-min-width, auto));
}
}

Expand Down Expand Up @@ -138,16 +135,14 @@ igc-icon-button::part(base) {
}

[part='selected-indicator'] {
$indicator-bezier: cubic-bezier(.35, 0, .25, 1);

position: relative;
grid-row: 2;
grid-column: 1 / -1;

span {
position: absolute;
display: inline-block;
transition: transform .3s $indicator-bezier, width .2s $indicator-bezier;
transition: transform .3s $tabs-animation-function, width .2s $tabs-animation-function;
z-index: map.get($tabs-z-index, 'selected-indicator');
}
}
5 changes: 5 additions & 0 deletions src/components/tabs/themes/tabs.common.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
@use 'styles/utilities' as *;

$tabs-z-index: (
scroll-button: 2,
selected-indicator: 1,
header: 1,
);
$tab-min-width: rem(90px);
$tab-max-width: rem(360px);
$tabs-animation-function: cubic-bezier(.35, 0, .25, 1);
4 changes: 2 additions & 2 deletions stories/tabs.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -288,8 +288,8 @@ export const NestedTabs: Story = {
margin: 0 auto;
}
.nested {
padding-inline-start: 1rem;
padding-block-start: 1rem;
padding: 1rem;
background: var(--ig-gray-50);
}
</style>
<igc-tabs
Expand Down

0 comments on commit 074d059

Please sign in to comment.