Skip to content

Commit

Permalink
feat(TabGroup): update handling for tab item hover states
Browse files Browse the repository at this point in the history
  • Loading branch information
booc0mtaco committed Jan 15, 2025
1 parent ca8f551 commit 131b198
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 37 deletions.
1 change: 1 addition & 0 deletions .storybook/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ export const parameters: Preview['parameters'] = {
...createComponentVersion('1.0'),
...createThemeVersion('1.0'),
...createThemeVersion('2.0'),
...createThemeVersion('2.1'),
implementationExample: {
styles: {
backgroundColor: '#ffffff',
Expand Down
60 changes: 24 additions & 36 deletions src/components/TabGroup/TabGroup.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/**
* TODO: Icon inherits color from the surrounding text, but should use the matching -icon- tokens from below
*/

/**
* List of of links where each link toggles open associated information
*/
Expand All @@ -29,11 +29,9 @@
* The color "white" is arbitrary and any non transparent color can be used here.
*/
.tabs--scrollable-left {
-webkit-mask-image: -webkit-linear-gradient(
left,
transparent,
white 4rem
);
-webkit-mask-image: -webkit-linear-gradient(left,
transparent,
white 4rem);
}

.tabs--scrollable-left .tabs__list--align-center,
Expand All @@ -42,21 +40,17 @@
}

.tabs--scrollable-right {
-webkit-mask-image: -webkit-linear-gradient(
right,
transparent,
white 4rem
);
-webkit-mask-image: -webkit-linear-gradient(right,
transparent,
white 4rem);
}

.tabs--scrollable-left.tabs--scrollable-right {
-webkit-mask-image: -webkit-linear-gradient(
left,
transparent,
white 4rem,
white calc(100% - 4rem),
transparent 100%
);
-webkit-mask-image: -webkit-linear-gradient(left,
transparent,
white 4rem,
white calc(100% - 4rem),
transparent 100%);
}

/**
Expand Down Expand Up @@ -106,8 +100,6 @@
flex-shrink: 0;
position: relative;
overflow: hidden;
border-top-left-radius: calc(var(--eds-theme-border-radius-objects-sm) * 1px);
border-top-right-radius: calc(var(--eds-theme-border-radius-objects-sm) * 1px);

&.eds-is-active {
font-weight: 500;
Expand Down Expand Up @@ -170,13 +162,15 @@
.tab__highlight {
border-radius: calc(var(--eds-border-radius-full) * 1px);
transition: bottom calc(var(--eds-anim-fade-quick) * 1s) var(--eds-anim-ease),
width calc(var(--eds-anim-fade-quick) * 1s) var(--eds-anim-ease);
width calc(var(--eds-anim-fade-quick) * 1s) var(--eds-anim-ease), background-color calc(var(--eds-anim-fade-quick) * 1s) var(--eds-anim-ease);

.tabs__item.eds-is-active & {
.tabs__item & {
position: absolute;
bottom: 0;
height: 0.25rem;
width: 100%;

background-color: transparent;
}

.tabs__item .tabs__link:focus-visible & {
Expand All @@ -203,14 +197,11 @@
&:focus-visible {
box-shadow: inset 0 0 0 0.125rem var(--eds-theme-color-border-utility-focus);
}
}

&:hover {
background-color: var(--eds-theme-color-background-utility-interactive-no-emphasis-hover);
}

&:active {
background-color: var(--eds-theme-color-background-utility-interactive-no-emphasis-active);
}
/* add in handling of showing highlight on hover */
.tabs__item:hover .tab__highlight {
background-color: var(--eds-theme-color-text-utility-interactive-primary);
}

.tabs__item.eds-is-active .tab__highlight {
Expand All @@ -227,14 +218,11 @@
&:focus-visible {
box-shadow: inset 0 0 0 0.125rem var(--eds-theme-color-border-utility-inverse);
}
}

&:hover {
background-color: var(--eds-theme-color-background-utility-inverse-no-emphasis-hover);
}

&:active {
background-color: var(--eds-theme-color-background-utility-inverse-no-emphasis-active);
}
/* add in handling of showing highlight on hover */
.tabs__item:hover .tab__highlight {
background-color: var(--eds-theme-color-background-utility-inverse-high-emphasis);
}

.tabs__item.eds-is-active .tab__highlight {
Expand Down
2 changes: 1 addition & 1 deletion src/components/TabGroup/TabGroup.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default {
component: TabGroup,
parameters: {
layout: 'centered',
badges: ['api-2.0', 'theme-2.0'],
badges: ['api-2.0', 'theme-2.1'],
},
args: {
children: (
Expand Down

0 comments on commit 131b198

Please sign in to comment.