refactor: improve hero carousel styling

This commit is contained in:
--remove-section committed 2026-01-21 20:53:38 +05:30
1 parent cb83b05c7a
commit b39a15449d
2 files changed
+125 -47

No files matched your search

+85 -41
View File
@@ -1,40 +1,37 @@
.carousel { .carousel {
position: relative; position: relative;
overflow: visible; overflow: visible;
height: 62vh; height: 65vh;
margin-bottom: 2em; margin-bottom: 3em;
display: grid; display: grid;
grid-template-areas: "main sidebar"; grid-template-areas: "main sidebar";
grid-template-columns: 1fr 25vw; grid-template-columns: 1fr 340px;
gap: 1em; gap: 1.5em;
&-sidebar { &-sidebar {
overflow-y: auto; overflow-y: auto;
height: inherit; height: 100%;
background: rgb(0 0 0 / 0.2); background: rgba(10, 10, 14, 0.4); // Darker, more distinct
border-radius: 20px; border-radius: 24px;
border: 1.2px solid rgb(255 255 255 / 0.1); backdrop-filter: blur(24px) saturate(180%);
border: 1px solid rgba(255, 255, 255, 0.08);
grid-area: sidebar; grid-area: sidebar;
display: flex;
flex-direction: column;
padding: 12px;
gap: 8px;
box-shadow: 0 4px 24px rgba(0,0,0,0.2);
// Ensure programmatic scroll respects padding
scroll-padding-block: 24px;
// Hide scrollbar but keep functionality
scrollbar-width: none;
-ms-overflow-style: none;
&::-webkit-scrollbar { &::-webkit-scrollbar {
width: 14px; width: 0;
border-left: 1px solid rgb(255 255 255 / 0.1); height: 0;
} display: none;
&::-webkit-scrollbar-track {
background: transparent;
margin-block: 1em;
}
&::-webkit-scrollbar-thumb {
background-color: rgba(255, 255, 255, 0.2);
border-radius: 10px;
border: 4px solid transparent;
background-clip: content-box;
&:hover {
background-color: rgba(255, 255, 255, 0.4);
}
} }
} }
@@ -55,34 +52,81 @@
&-ticker{ &-ticker{
overflow: hidden; overflow: hidden;
height: 8em; height: 72px;
display: flex; display: flex;
// margin-bottom: 1em; padding: 8px;
padding: 1em;
align-items: center; align-items: center;
gap: 1em; gap: 12px;
border-bottom: 1px solid rgb(255 255 255 / 0.1); transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
transition: background $transition-time-fast; position: relative;
border-radius: 12px; // Slightly smaller radius to work with the bar
&:last-child { background: transparent;
margin-bottom: 0; border: 1px solid transparent;
border: none;
}
&:hover { &:hover {
background: rgb(0 0 0 / .25); background: rgba(255, 255, 255, 0.05);
cursor: pointer; cursor: pointer;
} }
&.active { &.active {
background: rgb(255 255 255 / 0.05); background: rgba(255, 255, 255, 0.08); // Subtle background
// Vertical Progress Bar
&::after {
content: '';
position: absolute;
left: 0;
bottom: 0;
width: 4px;
background-color: var(--mui-palette-primary-main, #fff);
height: 0%;
animation: ticker-v-progress 8s linear;
}
} }
&-image { &-image {
height: 100%; height: 56px;
border-radius: 4px; width: 100px;
flex-shrink: 0;
border-radius: 8px;
object-fit: cover; object-fit: cover;
box-shadow: 0 2px 8px rgba(0,0,0,0.2);
} }
& > div {
display: flex;
flex-direction: column;
justify-content: center;
min-width: 0; // flexible text truncation
padding-left: 4px; // compensate for visual weight of potential bar
.carousel-ticker-title {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
font-weight: 500; // Slightly lighter
font-size: 0.95rem;
line-height: 1.2;
margin-bottom: 2px;
opacity: 0.9;
}
.carousel-ticker-year {
font-size: 0.8rem;
opacity: 0.6;
}
}
}
// Pause progress when carousel is paused
&.paused {
.carousel-ticker.active::after {
animation-play-state: paused;
}
}
@keyframes ticker-v-progress {
from { height: 0%; }
to { height: 100%; }
} }
&-indicator { &-indicator {
+40 -6
View File
@@ -23,12 +23,35 @@ const Carousel = ({
onChange: (currentSlide: number) => void; onChange: (currentSlide: number) => void;
}) => { }) => {
const [currentSlide, setCurrentSlide] = useState(0); const [currentSlide, setCurrentSlide] = useState(0);
const [isPaused, setIsPaused] = useState(false);
const sidebarRef = React.useRef<HTMLDivElement>(null);
const tickerRefs = React.useRef<(HTMLDivElement | null)[]>([]);
const [setDirection] = useCarouselStore((state) => [state.setDirection]); const [setDirection] = useCarouselStore((state) => [state.setDirection]);
useEffect(() => { useEffect(() => {
onChange(currentSlide); onChange(currentSlide);
}, [content[currentSlide]?.Id]);
// Auto-scroll sidebar to keep active item in view
if (tickerRefs.current[currentSlide]) {
tickerRefs.current[currentSlide]?.scrollIntoView({
behavior: "smooth",
block: "nearest",
});
}
}, [currentSlide, content, onChange]);
// Autoplay functionality
useEffect(() => {
if (isPaused || content.length === 0) return;
const timer = setInterval(() => {
setDirection("right");
setCurrentSlide((prev) => (prev + 1) % content.length);
}, 8000);
return () => clearInterval(timer);
}, [isPaused, content.length, setDirection, currentSlide]);
const api = useApiInContext((s) => s.api); const api = useApiInContext((s) => s.api);
@@ -44,24 +67,34 @@ const Carousel = ({
if (!api) return null; if (!api) return null;
return ( return (
<div className="carousel"> <div
className={`carousel ${isPaused ? "paused" : ""}`}
onMouseEnter={() => setIsPaused(true)}
onMouseLeave={() => setIsPaused(false)}
>
<AnimatePresence mode="sync"> <AnimatePresence mode="sync">
<MemoizedCarouselSlide <MemoizedCarouselSlide
item={content[currentSlide]} item={content[currentSlide]}
key={content[currentSlide].Id} key={content[currentSlide].Id}
/> />
</AnimatePresence> </AnimatePresence>
<div className="carousel-sidebar"> <div className="carousel-sidebar" ref={sidebarRef}>
{content.map((item, index) => ( {content.map((item, index) => (
<CarouselTickers <div
key={item.Id} key={item.Id}
ref={(el) => {
tickerRefs.current[index] = el;
}}
style={{ scrollMarginBlock: "24px" }}
>
<CarouselTickers
imageUrl={ imageUrl={
getImageUrlsApi(api).getItemImageUrlById( getImageUrlsApi(api).getItemImageUrlById(
item.Id ?? "", item.Id ?? "",
"Primary", "Thumb",
{ {
quality: 90, quality: 90,
fillWidth: 360, fillHeight: 360,
}, },
) ?? undefined ) ?? undefined
} }
@@ -74,6 +107,7 @@ const Carousel = ({
} }
onClick={() => handleTickerClick(index)} onClick={() => handleTickerClick(index)}
/> />
</div>
))} ))}
</div> </div>
</div> </div>