refactor: improve hero carousel styling
This commit is contained in:
2 files changed
+143
-65
No files matched your search
@@ -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 {
|
||||||
|
|||||||
@@ -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,36 +67,47 @@ 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}
|
||||||
imageUrl={
|
ref={(el) => {
|
||||||
getImageUrlsApi(api).getItemImageUrlById(
|
tickerRefs.current[index] = el;
|
||||||
item.Id ?? "",
|
}}
|
||||||
"Primary",
|
style={{ scrollMarginBlock: "24px" }}
|
||||||
{
|
>
|
||||||
quality: 90,
|
<CarouselTickers
|
||||||
fillWidth: 360,
|
imageUrl={
|
||||||
},
|
getImageUrlsApi(api).getItemImageUrlById(
|
||||||
) ?? undefined
|
item.Id ?? "",
|
||||||
}
|
"Thumb",
|
||||||
isActive={index === currentSlide}
|
{
|
||||||
itemName={item.Name ?? "Unknown"}
|
quality: 90,
|
||||||
itemYear={
|
fillHeight: 360,
|
||||||
item.Type === BaseItemKind.Series && item.EndDate
|
},
|
||||||
? `${item.ProductionYear ?? ""} - ${new Date(item.EndDate).getFullYear().toString()}`
|
) ?? undefined
|
||||||
: (item.ProductionYear?.toString() ?? "")
|
}
|
||||||
}
|
isActive={index === currentSlide}
|
||||||
onClick={() => handleTickerClick(index)}
|
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>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in new issue
Block a user