diff --git a/src/components/LinkWithStatus.tsx b/src/components/LinkWithStatus.tsx index c2e1ad7e..db93cbe1 100644 --- a/src/components/LinkWithStatus.tsx +++ b/src/components/LinkWithStatus.tsx @@ -36,7 +36,7 @@ export default function LinkWithStatus({ isLoading && loadingClassName, )} > - + {typeof children === 'function' ? children({ isLoading }) : children} diff --git a/src/components/primitives/LinkWithStatusChild.tsx b/src/components/primitives/LinkWithStatusChild.tsx index f63ff546..55ca0297 100644 --- a/src/components/primitives/LinkWithStatusChild.tsx +++ b/src/components/primitives/LinkWithStatusChild.tsx @@ -7,11 +7,9 @@ const FLICKER_THRESHOLD = 400; export default function LinkWithStatusChild({ children, - isLoading, setIsLoading, }: { children: ReactNode - isLoading: boolean setIsLoading: (isLoading: boolean) => void }) { const { pending } = useLinkStatus(); @@ -20,25 +18,22 @@ export default function LinkWithStatusChild({ const stopLoadingTimeout = useRef(undefined); const isLoadingStartTime = useRef(undefined); - useEffect(() => { - if (isLoading) { - isLoadingStartTime.current = Date.now(); - } else { - isLoadingStartTime.current = undefined; - } - }, [isLoading]); useEffect(() => { if (pending) { clearTimeout(stopLoadingTimeout.current); + stopLoadingTimeout.current = undefined; startLoadingTimeout.current = setTimeout(() => { setIsLoading(true); + isLoadingStartTime.current = Date.now(); }, FLICKER_THRESHOLD); - } else if (isLoadingStartTime.current) { + } else if (startLoadingTimeout.current) { clearTimeout(startLoadingTimeout.current); - const loadingDuration = Date.now() - isLoadingStartTime.current; + startLoadingTimeout.current = undefined; + const loadingDuration = Date.now() - (isLoadingStartTime.current ?? 0); stopLoadingTimeout.current = setTimeout(() => { setIsLoading(false); + isLoadingStartTime.current = undefined; }, FLICKER_THRESHOLD - loadingDuration); } }, [pending, setIsLoading]); diff --git a/src/recipe/PhotoRecipeOverlay.tsx b/src/recipe/PhotoRecipeOverlay.tsx index a039fed3..af7f9493 100644 --- a/src/recipe/PhotoRecipeOverlay.tsx +++ b/src/recipe/PhotoRecipeOverlay.tsx @@ -17,9 +17,8 @@ import { } from '.'; import { TbChecklist } from 'react-icons/tb'; import CopyButton from '@/components/CopyButton'; -import { pathForRecipe } from '@/app/paths'; -import LinkWithStatus from '@/components/LinkWithStatus'; import { labelForFilm } from '@/film'; +import PhotoRecipe from './PhotoRecipe'; export default function PhotoRecipeOverlay({ ref, @@ -103,20 +102,23 @@ export default function PhotoRecipeOverlay({ 'backdrop-blur-xl saturate-[300%]', )} > -
-
+
+
{title - ? *>*>*]:text-black', + 'tracking-wide', )} - loadingClassName="bg-neutral-100/20" - > - {renderRecipeTitle} - + /> : renderRecipeTitle}
- } - onClick={onClose} - className={clsx( - 'link p-0 m-0 h-4!', - 'text-black/40 active:text-black/75', - 'translate-y-[2.5px]', - )} - /> + + } + onClick={onClose} + className={clsx( + 'link p-0 m-0', + 'text-black/40 active:text-black/75', + )} + /> +
{/* ROW */}