-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(atomic): improve atomic-tab overflow behaviour (#4725)
This PR improves the way overflow is handled on atomic tabs. Instead of a dropdown on small screen widths, tabs overflow in a dropdown. Additionally, when not enough space is available to display tabs, they will get truncated as needed. https://coveord.atlassian.net/browse/KIT-3732
- Loading branch information
Showing
11 changed files
with
411 additions
and
221 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 52 additions & 29 deletions
81
packages/atomic/src/components/common/tab-manager/tab-button.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,54 @@ | ||
import {FunctionalComponent, h} from '@stencil/core'; | ||
import {Button} from '../button'; | ||
import {Component, Host, Prop, h} from '@stencil/core'; | ||
|
||
export interface TabButtonProps { | ||
label: string | undefined; | ||
handleClick: () => void; | ||
isActive: boolean; | ||
} | ||
/** | ||
* @internal | ||
*/ | ||
@Component({ | ||
tag: 'tab-button', | ||
}) | ||
export class TabButton { | ||
/** | ||
* The label to display on the tab button. | ||
*/ | ||
@Prop() label!: string; | ||
|
||
/** | ||
* Whether the tab button is active. | ||
*/ | ||
@Prop() active: boolean = false; | ||
|
||
/** | ||
* Click handler for the tab button. | ||
*/ | ||
@Prop() select!: () => void; | ||
|
||
export const TabButton: FunctionalComponent<TabButtonProps> = (props) => { | ||
const activeTabClass = props.isActive | ||
? "relative after:content-[''] after:block after:w-full after:h-1 after:absolute after:-bottom-0.5 after:bg-primary after:rounded" | ||
: ''; | ||
const activeTabTextClass = props.isActive ? '' : 'text-neutral-dark'; | ||
return ( | ||
<li | ||
aria-current={props.isActive ? 'true' : 'false'} | ||
aria-label={'tab for ' + props.label} | ||
part="button-container" | ||
class={activeTabClass} | ||
> | ||
<Button | ||
style="text-transparent" | ||
class={`w-full px-6 pb-1 text-xl ${activeTabTextClass}`} | ||
text={props.label} | ||
part="tab-button" | ||
onClick={props.handleClick} | ||
></Button> | ||
</li> | ||
); | ||
}; | ||
private get activeTabClass() { | ||
return this.active | ||
? 'relative after:block after:w-full after:h-1 after:absolute after:-bottom-0.5 after:bg-primary after:rounded' | ||
: ''; | ||
} | ||
|
||
private get activeTabTextClass() { | ||
return this.active ? '' : 'text-neutral-dark'; | ||
} | ||
|
||
render() { | ||
return ( | ||
<Host | ||
role="listitem" | ||
class={`${this.activeTabClass}`} | ||
aria-current={this.active ? 'true' : 'false'} | ||
aria-label={'tab for ' + this.label} | ||
part="button-container" | ||
> | ||
<button | ||
class={`w-full truncate px-2 pb-1 text-xl sm:px-6 ${this.activeTabTextClass}`} | ||
part="tab-button" | ||
onClick={this.select} | ||
> | ||
{this.label} | ||
</button> | ||
</Host> | ||
); | ||
} | ||
} |
22 changes: 0 additions & 22 deletions
22
packages/atomic/src/components/common/tab-manager/tab-dropdown-option.tsx
This file was deleted.
Oops, something went wrong.
42 changes: 0 additions & 42 deletions
42
packages/atomic/src/components/common/tab-manager/tab-dropdown.tsx
This file was deleted.
Oops, something went wrong.
23 changes: 23 additions & 0 deletions
23
packages/atomic/src/components/common/tab-manager/tab-manager-bar.pcss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
@import '../../../global/global.pcss'; | ||
|
||
:host { | ||
white-space: nowrap; | ||
width: 100%; | ||
overflow-x: visible; | ||
display: flex; | ||
position: relative; | ||
|
||
button { | ||
@apply text-left; | ||
} | ||
|
||
tab-popover::part(popover-button) { | ||
@apply text-xl; | ||
@apply sm:px-6; | ||
@apply px-2; | ||
@apply pb-1; | ||
@apply font-normal; | ||
@apply m-0; | ||
@apply text-black; | ||
} | ||
} |
Oops, something went wrong.