Skip to content

Commit f1f1e97

Browse files
committed
Implement auto-scrolling tab navigation with fixed-width containers
- Change to fixed-width tab containers that fit screen with existing margins - Enable horizontal scroll within the fixed containers (cropped tabs) - Add auto-scroll functionality to keep active tab centered and visible - Use scrollIntoView with smooth behavior when tab selection changes - Maintain background styling on the scrollable container - Both Principles and Values sections now auto-scroll to active tabs
1 parent 3284708 commit f1f1e97

File tree

1 file changed

+34
-6
lines changed

1 file changed

+34
-6
lines changed

src/components/PrinciplesValuesShowcase.tsx

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,34 @@ const PrinciplesValuesShowcase = () => {
284284
};
285285
}, [isHovered, isPrinciplesInView, translatedPrinciples.length]);
286286

287+
// Auto-scroll to active value tab
288+
useEffect(() => {
289+
if (valuesNavRef.current) {
290+
const activeButton = valuesNavRef.current.children[selectedValue] as HTMLElement;
291+
if (activeButton) {
292+
activeButton.scrollIntoView({
293+
behavior: 'smooth',
294+
block: 'nearest',
295+
inline: 'center'
296+
});
297+
}
298+
}
299+
}, [selectedValue]);
300+
301+
// Auto-scroll to active principle tab
302+
useEffect(() => {
303+
if (principlesNavRef.current) {
304+
const activeButton = principlesNavRef.current.children[selectedPrinciple] as HTMLElement;
305+
if (activeButton) {
306+
activeButton.scrollIntoView({
307+
behavior: 'smooth',
308+
block: 'nearest',
309+
inline: 'center'
310+
});
311+
}
312+
}
313+
}, [selectedPrinciple]);
314+
287315
return (
288316
<div id="foundations" className="space-y-32 py-20">
289317
{/* Mission & Vision Section */}
@@ -351,11 +379,11 @@ const PrinciplesValuesShowcase = () => {
351379
</div>
352380

353381
{/* Principle Navigation */}
354-
<div className="mb-12">
355-
<div className="overflow-x-auto scrollbar-hide">
382+
<div className="flex justify-center mb-12 px-4">
383+
<div className="overflow-x-auto scrollbar-hide bg-muted/30 p-2 rounded-xl max-w-full">
356384
<div
357385
ref={principlesNavRef}
358-
className="flex gap-2 bg-muted/30 p-2 rounded-xl w-fit mx-auto px-4"
386+
className="flex gap-2"
359387
onMouseEnter={() => setIsHovered(true)}
360388
onMouseLeave={() => setIsHovered(false)}
361389
>
@@ -461,11 +489,11 @@ const PrinciplesValuesShowcase = () => {
461489
</div>
462490

463491
{/* Value Navigation */}
464-
<div className="mb-12">
465-
<div className="overflow-x-auto scrollbar-hide">
492+
<div className="flex justify-center mb-12 px-4">
493+
<div className="overflow-x-auto scrollbar-hide bg-muted/30 p-2 rounded-xl max-w-full">
466494
<div
467495
ref={valuesNavRef}
468-
className="flex gap-2 bg-muted/30 p-2 rounded-xl w-fit mx-auto px-4"
496+
className="flex gap-2"
469497
onMouseEnter={() => setIsHovered(true)}
470498
onMouseLeave={() => setIsHovered(false)}
471499
>

0 commit comments

Comments
 (0)