-
Notifications
You must be signed in to change notification settings - Fork 8.5k
[Discover] [Unified Tabs] Tabs new design polishes #244179
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
base: main
Are you sure you want to change the base?
Changes from 22 commits
696eb6d
fbb144d
73c0b6a
7311ccf
29603e3
ab81f92
e5ebfe0
5ee1535
195c392
6224ef6
8ac5270
c427459
fcb4035
9d52c5f
b235cf5
2dc7662
080a1bc
6ac19d3
ad8e86e
7649e14
f198be0
224f930
7391b93
6dfca27
fafdfd1
2906a35
234f425
1ddebd5
6360151
a9b652a
8b9b568
06b2a66
d19dc59
ede2461
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -38,15 +38,16 @@ export const useResponsiveTabs = ({ | |
| }: UseResponsiveTabsProps) => { | ||
| const { euiTheme } = useEuiTheme(); | ||
| const dimensions = useResizeObserver(tabsContainerWithPlusElement); | ||
| const horizontalGap = parseInt(euiTheme.size.s, 10); // matches gap between tabs | ||
|
|
||
| const tabsSizeConfig = useMemo(() => { | ||
| const horizontalGap = parseInt(euiTheme.size.s, 10); // matches gap between tabs | ||
| return calculateResponsiveTabs({ | ||
| items, | ||
| containerWidth: dimensions.width, | ||
| hasReachedMaxItemsCount, | ||
| horizontalGap, | ||
| }); | ||
| }, [items, dimensions.width, hasReachedMaxItemsCount, euiTheme.size.s]); | ||
| }, [items, dimensions.width, hasReachedMaxItemsCount, horizontalGap]); | ||
|
|
||
| const [scrollState, setScrollState] = useState<ScrollState>(); | ||
|
|
||
|
|
@@ -135,8 +136,8 @@ export const useResponsiveTabs = ({ | |
| mask-image: linear-gradient( | ||
| to right, | ||
| rgba(255, 0, 0, 0.1) 0%, | ||
| rgb(255, 0, 0) ${euiTheme.size.s}, | ||
| rgb(255, 0, 0) calc(100% - ${euiTheme.size.s}), | ||
| rgb(255, 0, 0) ${euiTheme.size.l}, | ||
| rgb(255, 0, 0) calc(100% - ${euiTheme.size.l}), | ||
|
||
| rgba(255, 0, 0, 0.1) 100% | ||
| ); | ||
| `; | ||
|
|
@@ -145,14 +146,14 @@ export const useResponsiveTabs = ({ | |
| mask-image: linear-gradient( | ||
| to right, | ||
| rgba(255, 0, 0, 0.1) 0%, | ||
| rgb(255, 0, 0) ${euiTheme.size.s} | ||
| rgb(255, 0, 0) ${euiTheme.size.l} | ||
| ); | ||
| `; | ||
| } else if (scrollState?.isScrollableRight) { | ||
| overflowGradient = ` | ||
| mask-image: linear-gradient( | ||
| to right, | ||
| rgb(255, 0, 0) calc(100% - ${euiTheme.size.s}), | ||
| rgb(255, 0, 0) calc(100% - ${euiTheme.size.l}), | ||
| rgba(255, 0, 0, 0.1) 100% | ||
| ); | ||
| `; | ||
|
|
@@ -164,13 +165,14 @@ export const useResponsiveTabs = ({ | |
| user-select: none; | ||
| scrollbar-width: none; // hide the scrollbar | ||
| scroll-behavior: smooth; | ||
| padding-inline: ${euiTheme.size.xs}; // space for curved notch | ||
| &::-webkit-scrollbar { | ||
| display: none; | ||
| } | ||
| transform: translateZ(0); | ||
| ${overflowGradient} | ||
| `; | ||
| }, [scrollState, euiTheme.size.s]); | ||
| }, [scrollState, euiTheme.size.l, euiTheme.size.xs]); | ||
|
|
||
| return { | ||
| tabsSizeConfig, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can also do it simpler, but violating useEffect deps rule, so I went with ref here. I'm open for discussion though
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It feels like there should be an easier way to do this, but I'm not sure off the top of my head tbh. So I think it's good for now 👍