From ae38fe4fe0427256f4d1039372fd41758e6eed15 Mon Sep 17 00:00:00 2001 From: topshenyi-web Date: Sun, 2 Feb 2025 17:25:46 -0500 Subject: [PATCH] fix: a bit smoother title reveal --- src/components/EateryCardSkeleton.tsx | 35 +++++++++++++++++---- src/pages/ListPage.css | 44 ++++++++++++++++++++++----- src/pages/ListPage.tsx | 8 +++-- 3 files changed, 70 insertions(+), 17 deletions(-) diff --git a/src/components/EateryCardSkeleton.tsx b/src/components/EateryCardSkeleton.tsx index d3e4f31..b406a76 100644 --- a/src/components/EateryCardSkeleton.tsx +++ b/src/components/EateryCardSkeleton.tsx @@ -26,13 +26,23 @@ const SkeletonText = styled(Skeleton)({ marginBottom: '12px', }); -function EateryCardSkeleton() { +function EateryCardSkeleton({ index }: { index: number }) { return ( - + + } avatar={ } /> - - - + + + diff --git a/src/pages/ListPage.css b/src/pages/ListPage.css index 8c05283..3ffd8f4 100644 --- a/src/pages/ListPage.css +++ b/src/pages/ListPage.css @@ -16,28 +16,42 @@ grid-gap: 1rem; padding: 3rem 0; } +/* we need this to properly animate the mask gradient */ +@property --left-pos { + syntax: ''; + inherits: false; + initial-value: 0%; +} .Locations-header__greeting { - display: block; - overflow: hidden; + --left-pos: 100%; width: fit-content; animation: slide-in 1.2s forwards; animation-timing-function: cubic-bezier(0.04, 0.34, 0.5, 1.02); + /* we add a delay so it doesn't look jittery on page load */ animation-delay: 0.1s; opacity: 0; + + mask-image: linear-gradient( + to right, + rgba(0, 0, 0, 1) 0%, + rgba(0, 0, 0, 1) var(--left-pos), + rgba(0, 0, 0, 0) calc(var(--left-pos) + 10%) + ); } @keyframes slide-in { 0% { opacity: 0; - clip-path: inset(0px 100% 0px 0px); + /* clip-path: inset(0px 100% 0px 0px); */ transform: translate(-10px, 0); + --left-pos: 0%; } 20% { opacity: 1; } 100% { opacity: 1; - clip-path: inset(0px -5% 0px 0px); - transform: translate(); + transform: translate(0, 0); + --left-pos: 100%; } } @media screen and (min-width: 900px) { @@ -96,20 +110,20 @@ &:hover { animation: var(--fade-in-animation), - /* so we don't overwrite this*/ glow-animation 1.5s infinite; + glow-animation 1.5s infinite; } } @keyframes fade-in { 0% { - filter: opacity(0); + opacity: 0; transform: translate(-20px, 0); } 20% { opacity: 1; } 100% { - opacity: 1; transform: translate(0, 0); + opacity: 1; } } @keyframes glow-animation { @@ -123,3 +137,17 @@ box-shadow: 0 0 5px rgba(238, 111, 82, 0.7); } } +@keyframes oscillate-opacity { + 0% { + opacity: 1; + } + 30% { + opacity: 0.6; + } + 90% { + opacity: 1; + } +} +.skeleton-card--animated { + opacity: 0; +} diff --git a/src/pages/ListPage.tsx b/src/pages/ListPage.tsx index 3280bb5..0c13f21 100644 --- a/src/pages/ListPage.tsx +++ b/src/pages/ListPage.tsx @@ -179,9 +179,11 @@ function ListPage({ {/* TODO: find a better solution */} {Array(36) .fill(null) - .map((_, index) => index) - .map((v) => ( - + .map((_, index) => ( + ))} );