diff --git a/apps/web/src/views/public/board/CardModal.tsx b/apps/web/src/views/public/board/CardModal.tsx index cbd74714..c7fce8e6 100644 --- a/apps/web/src/views/public/board/CardModal.tsx +++ b/apps/web/src/views/public/board/CardModal.tsx @@ -1,10 +1,13 @@ import { useRouter } from "next/router"; import { t } from "@lingui/core/macro"; +import { useEffect, useRef, useState } from "react"; import { HiXMark } from "react-icons/hi2"; import { authClient } from "@kan/auth/client"; +import Badge from "~/components/Badge"; import Editor from "~/components/Editor"; +import LabelIcon from "~/components/LabelIcon"; import { useModal } from "~/providers/modal"; import { api } from "~/utils/api"; import ActivityList from "~/views/card/components/ActivityList"; @@ -21,6 +24,9 @@ export function CardModal({ const router = useRouter(); const { closeModal, isOpen } = useModal(); const { data: session } = authClient.useSession(); + const [showFade, setShowFade] = useState(false); + const [showTopFade, setShowTopFade] = useState(false); + const scrollRef = useRef(null); const { data, isLoading } = api.card.byId.useQuery( { @@ -33,85 +39,115 @@ export function CardModal({ const labels = data?.labels ?? []; + const handleScroll = () => { + if (!scrollRef.current) return; + + const { scrollTop, scrollHeight, clientHeight } = scrollRef.current; + const isAtBottom = scrollTop + clientHeight >= scrollHeight - 5; + const isAtTop = scrollTop <= 5; + + setShowFade(!isAtBottom); + setShowTopFade(!isAtTop); + }; + + useEffect(() => { + const scrollElement = scrollRef.current; + if (!scrollElement) return; + + handleScroll(); + + scrollElement.addEventListener("scroll", handleScroll); + return () => scrollElement.removeEventListener("scroll", handleScroll); + }, [data]); + return (
-
-
- - {isLoading ? ( -
-
-
- ) : ( - <> -

- {data?.title} -

- - )} -
+
- {labels.map((label) => ( -
+
- ))} -
- - {data?.description && ( -
-
- -
-
- )} -
-

- {t`Activity`} -

-
- {cardPublicId && ( - + + {isLoading ? ( +
+
+
+ ) : ( + <> +

+ {data?.title} +

+ )}
+ {labels.length > 0 && ( +
+ {labels.map((label) => ( + } + /> + ))} +
+ )} +
+ +
+
+ {data?.description && ( +
+
+ +
+
+ )} +
+

+ {t`Activity`} +

+
+ {cardPublicId && ( + + )} +
+
+
+ {showTopFade && ( +
+ )} + {showFade && ( +
+ )}