Skip to content

Commit c23bb4c

Browse files
authored
Fix Line appearing under selected tab at larger zoom (#4122)
* feat(tokens): update border tokens related to tabs * feat(tabs): fix underline bug on trackpad zoom * feat(tokens): add changesets * feat(Tabs): add changesets * feat(tokens): update changesets * feat(tabs): fix build issue * feat(tabs): update changeset * feat(tabs): update typedocs * feat(tabs): update tests * feat(tabs): update typedocs * feat(tabs): update tokens * feat(tabs): update tests * feat(tabs): update token * feat(tabs): try different solution * feat(tabs): add different background for inverse * feat(tabs): add changes from review * feat(tabs): update tests * feat(tabs): implement changes from review * feat(tabs): update token name
1 parent a150cf7 commit c23bb4c

File tree

17 files changed

+124
-27
lines changed

17 files changed

+124
-27
lines changed

.changeset/dirty-mails-kick.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@twilio-paste/in-page-navigation": patch
3+
"@twilio-paste/core": patch
4+
---
5+
6+
[In Page Navigation]: Fix underline bug caused due to pixel rounding

.changeset/lucky-fireants-complain.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@twilio-paste/design-tokens": minor
3+
"@twilio-paste/core": minor
4+
---
5+
6+
[Tokens]: Add new tokens related to box shadow of Tabs component

.changeset/tender-bugs-itch.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@twilio-paste/code-block": patch
3+
"@twilio-paste/core": patch
4+
---
5+
6+
[Code Block]: Fix underline bug caused due to pixel rounding

.changeset/tricky-jeans-collect.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@twilio-paste/tabs": patch
3+
"@twilio-paste/core": patch
4+
---
5+
6+
[Tabs]: Fix underline bug caused due to pixel rounding

packages/paste-core/components/code-block/src/OverflowButton.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Box, BoxProps, BoxStyleProps } from "@twilio-paste/box";
22
import { ChevronLeftIcon } from "@twilio-paste/icons/esm/ChevronLeftIcon";
33
import { ChevronRightIcon } from "@twilio-paste/icons/esm/ChevronRightIcon";
4+
import { BoxShadow } from "@twilio-paste/style-props";
45
import { useTheme } from "@twilio-paste/theme";
56
import React from "react";
67

@@ -31,6 +32,14 @@ export const OverflowButton: React.FC<OverflowButtonProps> = ({
3132
const Chevron = position === "left" ? ChevronLeftIcon : ChevronRightIcon;
3233
if (!visible && position === "right") return null;
3334

35+
const determineShadow = (): BoxShadow | undefined => {
36+
if (visible && showShadow) {
37+
if (position === "left") return theme.shadows.shadowLeftInverse;
38+
return theme.shadows.shadowRightInverse;
39+
}
40+
return undefined;
41+
};
42+
3443
return (
3544
<Box
3645
onClick={onClick}
@@ -41,9 +50,10 @@ export const OverflowButton: React.FC<OverflowButtonProps> = ({
4150
width="sizeIcon40"
4251
padding="space20"
4352
position="relative"
44-
boxShadow={visible && showShadow ? theme.shadows.shadowScrollInverse : undefined}
53+
boxShadow={determineShadow()}
4554
element={`${element}_OVERFLOW_BUTTON_${position.toUpperCase()}`}
4655
cursor={visible ? "pointer" : "none"}
56+
zIndex="zIndex10"
4757
{...Styles}
4858
>
4959
{/* For left button to align with spacing of header we hide icon */}

packages/paste-core/components/in-page-navigation/src/OverflowButton.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ export const OverflowButton: React.FC<OverflowButtonProps> = ({
4646

4747
const determineShadow = (): BoxShadow | undefined => {
4848
if (showShadow) {
49-
return isInverse ? theme.shadows.shadowScrollInverse : theme.shadows.shadowScroll;
49+
if (position === "left") return isInverse ? theme.shadows.shadowLeftInverse : theme.shadows.shadowLeft;
50+
return isInverse ? theme.shadows.shadowRightInverse : theme.shadows.shadowRight;
5051
}
5152
return undefined;
5253
};
@@ -62,6 +63,7 @@ export const OverflowButton: React.FC<OverflowButtonProps> = ({
6263
padding="space20"
6364
boxShadow={determineShadow()}
6465
element={`${element}_OVERFLOW_BUTTON_${position.toUpperCase()}`}
66+
zIndex="zIndex10"
6567
{...(isInverse ? InverseStyles : Styles)}
6668
>
6769
<Chevron decorative={true} />

packages/paste-core/components/tabs/src/OverflowButton.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ export const OverflowButton: React.FC<OverflowButtonProps> = ({
4747

4848
const determineShadow = (): BoxShadow | undefined => {
4949
if (showShadow) {
50-
return isInverse ? theme.shadows.shadowScrollInverse : theme.shadows.shadowScroll;
50+
if (position === "left") return isInverse ? theme.shadows.shadowLeftInverse : theme.shadows.shadowLeft;
51+
return isInverse ? theme.shadows.shadowRightInverse : theme.shadows.shadowRight;
5152
}
5253
return undefined;
5354
};
@@ -63,6 +64,7 @@ export const OverflowButton: React.FC<OverflowButtonProps> = ({
6364
padding="space20"
6465
boxShadow={determineShadow()}
6566
element={`${element}_OVERFLOW_BUTTON_${position.toUpperCase()}`}
67+
zIndex="zIndex10"
6668
{...(isInverse ? InverseStyles : Styles)}
6769
>
6870
<Chevron decorative={true} />

packages/paste-core/components/tabs/src/Tab.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ const getTabBoxStyles = (orientation: Orientation, variant: Variants): BoxStyleP
126126
borderBottomColor: isInverse ? "colorBorderInverseWeakest" : "colorBorderWeakest",
127127
color: isInverse ? "colorTextInverse" : "colorTextPrimary",
128128
boxShadow: isInverse ? "shadowBorderTopInverseStrongest" : "shadowBorderTopPrimary",
129+
backgroundColor: isInverse ? "colorBackgroundInverse" : "colorBackgroundBody",
129130
},
130131
/* Disabled state */
131132
_disabled: {
@@ -139,7 +140,7 @@ const getTabBoxStyles = (orientation: Orientation, variant: Variants): BoxStyleP
139140
},
140141
_selected_hover: {
141142
color: isInverse ? "colorTextInverse" : "colorTextPrimaryStronger",
142-
borderBottomColor: isInverse ? "colorBorderInverseWeakest" : "colorBorderWeakest",
143+
borderBottomColor: "transparent",
143144
boxShadow: isInverse ? "shadowBorderTopPrimary" : "shadowBorderTopPrimaryStrongest",
144145
},
145146
/* Focus states */
@@ -159,6 +160,7 @@ const getTabBoxStyles = (orientation: Orientation, variant: Variants): BoxStyleP
159160
borderColor: isInverse ? "colorBorderInverseWeaker" : "colorBorderWeak",
160161
boxShadow: "none",
161162
borderBottom: "none",
163+
overflow: "clip",
162164
},
163165
};
164166
}

packages/paste-core/components/tabs/src/TabList.tsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,17 +107,25 @@ const HorizontalTabList: React.FC<React.PropsWithChildren<{ variant?: Variants;
107107
<Box as={StyledTabList as any} ref={scrollableRef} flexGrow={1} element={`${element}_SCROLL_WRAPPER`}>
108108
<Box
109109
ref={ref}
110+
position="relative"
110111
whiteSpace="nowrap"
111112
element={element}
112113
display="flex"
113-
borderBottomStyle="solid"
114-
borderBottomWidth="borderWidth10"
115114
columnGap="space20"
116-
borderBottomColor={isInverse ? "colorBorderInverseWeaker" : "colorBorderWeak"}
115+
// @ts-expect-error 1px is not available in tokens
116+
paddingTop="1px"
117+
boxShadow={isInverse ? "shadowBorderBottomInverseWeakerInset" : "shadowBorderBottomWeakInset"}
117118
// Scrollable element needs borderto stretch to full contianer width. Non scrollable needs to stretch border to parent width.
118119
width={elementOutOBoundsRight || elementOutOBoundsLeft ? "max-content" : "auto"}
119120
>
120121
{children}
122+
<Box
123+
position="absolute"
124+
width="100%"
125+
height="1px"
126+
backgroundColor={isInverse ? "colorBackgroundInverse" : "colorBackgroundBody"}
127+
bottom="-1px"
128+
/>
121129
</Box>
122130
</Box>
123131
<OverflowButton

packages/paste-core/primitives/box/type-docs.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -958,7 +958,7 @@
958958
"description": "Responsive prop for the CSS `bottom` property"
959959
},
960960
"boxShadow": {
961-
"type": "\"none\" | \"shadow\" | \"shadowBorder\" | \"shadowBorderBottomBrand10Strong\" | \"shadowBorderBottomBrand20Strong\" | \"shadowBorderBottomBrand30Strong\" | \"shadowBorderBottomDecorative10Weaker\" | ... 69 more ... | { ...; }",
961+
"type": "\"none\" | \"shadow\" | \"shadowBorder\" | \"shadowBorderBottomBrand10Strong\" | \"shadowBorderBottomBrand20Strong\" | \"shadowBorderBottomBrand30Strong\" | \"shadowBorderBottomDecorative10Weaker\" | ... 73 more ... | { ...; }",
962962
"defaultValue": null,
963963
"required": false,
964964
"externalProp": false,

packages/paste-core/primitives/sibling-box/type-docs.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1060,7 +1060,7 @@
10601060
"description": "Responsive prop for the CSS `bottom` property"
10611061
},
10621062
"boxShadow": {
1063-
"type": "\"none\" | \"shadow\" | \"shadowBorder\" | \"shadowBorderBottomBrand10Strong\" | \"shadowBorderBottomBrand20Strong\" | \"shadowBorderBottomBrand30Strong\" | \"shadowBorderBottomDecorative10Weaker\" | ... 69 more ... | { ...; }",
1063+
"type": "\"none\" | \"shadow\" | \"shadowBorder\" | \"shadowBorderBottomBrand10Strong\" | \"shadowBorderBottomBrand20Strong\" | \"shadowBorderBottomBrand30Strong\" | \"shadowBorderBottomDecorative10Weaker\" | ... 73 more ... | { ...; }",
10641064
"defaultValue": null,
10651065
"required": false,
10661066
"externalProp": false,

packages/paste-core/primitives/text/type-docs.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,7 @@
531531
"description": "Responsive prop for the CSS `bottom` property"
532532
},
533533
"boxShadow": {
534-
"type": "\"none\" | \"shadow\" | \"shadowBorder\" | \"shadowBorderBottomBrand10Strong\" | \"shadowBorderBottomBrand20Strong\" | \"shadowBorderBottomBrand30Strong\" | \"shadowBorderBottomDecorative10Weaker\" | ... 69 more ... | { ...; }",
534+
"type": "\"none\" | \"shadow\" | \"shadowBorder\" | \"shadowBorderBottomBrand10Strong\" | \"shadowBorderBottomBrand20Strong\" | \"shadowBorderBottomBrand30Strong\" | \"shadowBorderBottomDecorative10Weaker\" | ... 73 more ... | { ...; }",
535535
"defaultValue": null,
536536
"required": false,
537537
"externalProp": false,

0 commit comments

Comments
 (0)