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
+143 -65

No files matched your search

+86 -42
View File
@@ -1,40 +1,37 @@
.carousel {
position: relative;
overflow: visible;
height: 62vh;
margin-bottom: 2em;
height: 65vh;
margin-bottom: 3em;
display: grid;
grid-template-areas: "main sidebar";
grid-template-columns: 1fr 25vw;
gap: 1em;
grid-template-columns: 1fr 340px;
gap: 1.5em;
&-sidebar {
overflow-y: auto;
height: inherit;
background: rgb(0 0 0 / 0.2);
border-radius: 20px;
border: 1.2px solid rgb(255 255 255 / 0.1);
height: 100%;
background: rgba(10, 10, 14, 0.4); // Darker, more distinct
border-radius: 24px;
backdrop-filter: blur(24px) saturate(180%);
border: 1px solid rgba(255, 255, 255, 0.08);
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 {
width: 14px;
border-left: 1px solid rgb(255 255 255 / 0.1);
}
&::-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);
}
width: 0;
height: 0;
display: none;
}
}
@@ -55,34 +52,81 @@
&-ticker{
overflow: hidden;
height: 8em;
height: 72px;
display: flex;
// margin-bottom: 1em;
padding: 1em;
padding: 8px;
align-items: center;
gap: 1em;
border-bottom: 1px solid rgb(255 255 255 / 0.1);
transition: background $transition-time-fast;
&:last-child {
margin-bottom: 0;
border: none;
}
gap: 12px;
transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
position: relative;
border-radius: 12px; // Slightly smaller radius to work with the bar
background: transparent;
border: 1px solid transparent;
&:hover {
background: rgb(0 0 0 / .25);
background: rgba(255, 255, 255, 0.05);
cursor: pointer;
}
&.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 {
height: 100%;
border-radius: 4px;
height: 56px;
width: 100px;
flex-shrink: 0;
border-radius: 8px;
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 {
+57 -23
View File
@@ -23,12 +23,35 @@ const Carousel = ({
onChange: (currentSlide: number) => void;
}) => {
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]);
useEffect(() => {
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);
@@ -44,36 +67,47 @@ const Carousel = ({
if (!api) return null;
return (
<div className="carousel">
<div
className={`carousel ${isPaused ? "paused" : ""}`}
onMouseEnter={() => setIsPaused(true)}
onMouseLeave={() => setIsPaused(false)}
>
<AnimatePresence mode="sync">
<MemoizedCarouselSlide
item={content[currentSlide]}
key={content[currentSlide].Id}
/>
</AnimatePresence>
<div className="carousel-sidebar">
<div className="carousel-sidebar" ref={sidebarRef}>
{content.map((item, index) => (
<CarouselTickers
<div
key={item.Id}
imageUrl={
getImageUrlsApi(api).getItemImageUrlById(
item.Id ?? "",
"Primary",
{
quality: 90,
fillWidth: 360,
},
) ?? undefined
}
isActive={index === currentSlide}
itemName={item.Name ?? "Unknown"}
itemYear={
item.Type === BaseItemKind.Series && item.EndDate
? `${item.ProductionYear ?? ""} - ${new Date(item.EndDate).getFullYear().toString()}`
: (item.ProductionYear?.toString() ?? "")
}
onClick={() => handleTickerClick(index)}
/>
ref={(el) => {
tickerRefs.current[index] = el;
}}
style={{ scrollMarginBlock: "24px" }}
>
<CarouselTickers
imageUrl={
getImageUrlsApi(api).getItemImageUrlById(
item.Id ?? "",
"Thumb",
{
quality: 90,
fillHeight: 360,
},
) ?? undefined
}
isActive={index === currentSlide}
itemName={item.Name ?? "Unknown"}
itemYear={
item.Type === BaseItemKind.Series && item.EndDate
? `${item.ProductionYear ?? ""} - ${new Date(item.EndDate).getFullYear().toString()}`
: (item.ProductionYear?.toString() ?? "")
}
onClick={() => handleTickerClick(index)}
/>
</div>
))}
</div>
</div>