Skip to content

Fix Line appearing under selected tab at larger zoom #4122

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

Merged
merged 19 commits into from
Nov 1, 2024
Merged
Show file tree
Hide file tree
Changes from 17 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
6 changes: 6 additions & 0 deletions .changeset/lucky-fireants-complain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@twilio-paste/design-tokens": minor
"@twilio-paste/core": minor
---

[Tokens]: Add new tokens related to box shadow of Tabs component
8 changes: 8 additions & 0 deletions .changeset/tricky-jeans-collect.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"@twilio-paste/code-block": patch
"@twilio-paste/in-page-navigation": patch
"@twilio-paste/tabs": patch
"@twilio-paste/core": patch
---

[Tabs]: Fix underline bug for trackpad zoom
Copy link
Collaborator

Choose a reason for hiding this comment

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

suggestion: split up these changesets up per package (preferred) or add the other package names to the prefix ([Tabs] part)

12 changes: 11 additions & 1 deletion packages/paste-core/components/code-block/src/OverflowButton.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Box, BoxProps, BoxStyleProps } from "@twilio-paste/box";
import { ChevronLeftIcon } from "@twilio-paste/icons/esm/ChevronLeftIcon";
import { ChevronRightIcon } from "@twilio-paste/icons/esm/ChevronRightIcon";
import { BoxShadow } from "@twilio-paste/style-props";
import { useTheme } from "@twilio-paste/theme";
import React from "react";

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

const determineShadow = (): BoxShadow | undefined => {
if (visible && showShadow) {
if (position === "left") return theme.shadows.shadowLeftInverse;
return theme.shadows.shadowRightInverse;
}
return undefined;
};

return (
<Box
onClick={onClick}
Expand All @@ -41,9 +50,10 @@ export const OverflowButton: React.FC<OverflowButtonProps> = ({
width="sizeIcon40"
padding="space20"
position="relative"
boxShadow={visible && showShadow ? theme.shadows.shadowScrollInverse : undefined}
boxShadow={determineShadow()}
element={`${element}_OVERFLOW_BUTTON_${position.toUpperCase()}`}
cursor={visible ? "pointer" : "none"}
zIndex="zIndex10"
{...Styles}
>
{/* For left button to align with spacing of header we hide icon */}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ export const OverflowButton: React.FC<OverflowButtonProps> = ({

const determineShadow = (): BoxShadow | undefined => {
if (showShadow) {
return isInverse ? theme.shadows.shadowScrollInverse : theme.shadows.shadowScroll;
if (position === "left") return isInverse ? theme.shadows.shadowLeftInverse : theme.shadows.shadowLeft;
return isInverse ? theme.shadows.shadowRightInverse : theme.shadows.shadowRight;
}
return undefined;
};
Expand All @@ -62,6 +63,7 @@ export const OverflowButton: React.FC<OverflowButtonProps> = ({
padding="space20"
boxShadow={determineShadow()}
element={`${element}_OVERFLOW_BUTTON_${position.toUpperCase()}`}
zIndex="zIndex10"
{...(isInverse ? InverseStyles : Styles)}
>
<Chevron decorative={true} />
Expand Down
4 changes: 3 additions & 1 deletion packages/paste-core/components/tabs/src/OverflowButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ export const OverflowButton: React.FC<OverflowButtonProps> = ({

const determineShadow = (): BoxShadow | undefined => {
if (showShadow) {
return isInverse ? theme.shadows.shadowScrollInverse : theme.shadows.shadowScroll;
if (position === "left") return isInverse ? theme.shadows.shadowLeftInverse : theme.shadows.shadowLeft;
return isInverse ? theme.shadows.shadowRightInverse : theme.shadows.shadowRight;
}
return undefined;
};
Expand All @@ -63,6 +64,7 @@ export const OverflowButton: React.FC<OverflowButtonProps> = ({
padding="space20"
boxShadow={determineShadow()}
element={`${element}_OVERFLOW_BUTTON_${position.toUpperCase()}`}
zIndex="zIndex10"
{...(isInverse ? InverseStyles : Styles)}
>
<Chevron decorative={true} />
Expand Down
4 changes: 3 additions & 1 deletion packages/paste-core/components/tabs/src/Tab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ const getTabBoxStyles = (orientation: Orientation, variant: Variants): BoxStyleP
borderBottomColor: isInverse ? "colorBorderInverseWeakest" : "colorBorderWeakest",
color: isInverse ? "colorTextInverse" : "colorTextPrimary",
boxShadow: isInverse ? "shadowBorderTopInverseStrongest" : "shadowBorderTopPrimary",
backgroundColor: isInverse ? "colorBackgroundInverse" : "colorBackgroundBody",
},
/* Disabled state */
_disabled: {
Expand All @@ -139,7 +140,7 @@ const getTabBoxStyles = (orientation: Orientation, variant: Variants): BoxStyleP
},
_selected_hover: {
color: isInverse ? "colorTextInverse" : "colorTextPrimaryStronger",
borderBottomColor: isInverse ? "colorBorderInverseWeakest" : "colorBorderWeakest",
borderBottomColor: "transparent",
boxShadow: isInverse ? "shadowBorderTopPrimary" : "shadowBorderTopPrimaryStrongest",
},
/* Focus states */
Expand All @@ -159,6 +160,7 @@ const getTabBoxStyles = (orientation: Orientation, variant: Variants): BoxStyleP
borderColor: isInverse ? "colorBorderInverseWeaker" : "colorBorderWeak",
boxShadow: "none",
borderBottom: "none",
overflow: "clip",
},
};
}
Expand Down
15 changes: 12 additions & 3 deletions packages/paste-core/components/tabs/src/TabList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,17 +107,26 @@ const HorizontalTabList: React.FC<React.PropsWithChildren<{ variant?: Variants;
<Box as={StyledTabList as any} ref={scrollableRef} flexGrow={1} element={`${element}_SCROLL_WRAPPER`}>
<Box
ref={ref}
position="relative"
whiteSpace="nowrap"
element={element}
display="flex"
borderBottomStyle="solid"
borderBottomWidth="borderWidth10"
columnGap="space20"
borderBottomColor={isInverse ? "colorBorderInverseWeaker" : "colorBorderWeak"}
// @ts-expect-error 1px is not available in tokens
paddingTop="1px"
// marginBottom="1px"
Copy link
Collaborator

Choose a reason for hiding this comment

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

reminder: remove comment

boxShadow={isInverse ? "shadowBorderBottomInverseWeaker" : "shadowBorderBottomWeak"}
// Scrollable element needs borderto stretch to full contianer width. Non scrollable needs to stretch border to parent width.
width={elementOutOBoundsRight || elementOutOBoundsLeft ? "max-content" : "auto"}
>
{children}
<Box
position="absolute"
width="100%"
height="1px"
backgroundColor={isInverse ? "colorBackgroundInverse" : "colorBackgroundBody"}
bottom="-1px"
/>
</Box>
</Box>
<OverflowButton
Expand Down
2 changes: 1 addition & 1 deletion packages/paste-core/primitives/box/type-docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -958,7 +958,7 @@
"description": "Responsive prop for the CSS `bottom` property"
},
"boxShadow": {
"type": "\"none\" | \"shadow\" | \"shadowBorder\" | \"shadowBorderBottomBrand10Strong\" | \"shadowBorderBottomBrand20Strong\" | \"shadowBorderBottomBrand30Strong\" | \"shadowBorderBottomDecorative10Weaker\" | ... 69 more ... | { ...; }",
"type": "\"none\" | \"shadow\" | \"shadowBorder\" | \"shadowBorderBottomBrand10Strong\" | \"shadowBorderBottomBrand20Strong\" | \"shadowBorderBottomBrand30Strong\" | \"shadowBorderBottomDecorative10Weaker\" | ... 73 more ... | { ...; }",
"defaultValue": null,
"required": false,
"externalProp": false,
Expand Down
2 changes: 1 addition & 1 deletion packages/paste-core/primitives/sibling-box/type-docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -1060,7 +1060,7 @@
"description": "Responsive prop for the CSS `bottom` property"
},
"boxShadow": {
"type": "\"none\" | \"shadow\" | \"shadowBorder\" | \"shadowBorderBottomBrand10Strong\" | \"shadowBorderBottomBrand20Strong\" | \"shadowBorderBottomBrand30Strong\" | \"shadowBorderBottomDecorative10Weaker\" | ... 69 more ... | { ...; }",
"type": "\"none\" | \"shadow\" | \"shadowBorder\" | \"shadowBorderBottomBrand10Strong\" | \"shadowBorderBottomBrand20Strong\" | \"shadowBorderBottomBrand30Strong\" | \"shadowBorderBottomDecorative10Weaker\" | ... 73 more ... | { ...; }",
"defaultValue": null,
"required": false,
"externalProp": false,
Expand Down
2 changes: 1 addition & 1 deletion packages/paste-core/primitives/text/type-docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@
"description": "Responsive prop for the CSS `bottom` property"
},
"boxShadow": {
"type": "\"none\" | \"shadow\" | \"shadowBorder\" | \"shadowBorderBottomBrand10Strong\" | \"shadowBorderBottomBrand20Strong\" | \"shadowBorderBottomBrand30Strong\" | \"shadowBorderBottomDecorative10Weaker\" | ... 69 more ... | { ...; }",
"type": "\"none\" | \"shadow\" | \"shadowBorder\" | \"shadowBorderBottomBrand10Strong\" | \"shadowBorderBottomBrand20Strong\" | \"shadowBorderBottomBrand30Strong\" | \"shadowBorderBottomDecorative10Weaker\" | ... 73 more ... | { ...; }",
"defaultValue": null,
"required": false,
"externalProp": false,
Expand Down
Loading
Loading