diff --git a/components/RepositoryItem.tsx b/components/RepositoryItem.tsx index e01c709..6b41bb9 100644 --- a/components/RepositoryItem.tsx +++ b/components/RepositoryItem.tsx @@ -14,6 +14,7 @@ type RepositoryItemProps = { export const RepositoryItem = ({ repository }: RepositoryItemProps) => { const [isIssueOpen, setIsIssueOpen] = useState(false); + const [isIssuesListVisible, setIsIssuesListVisible] = useState(false); dayjs.extend(relativeTime); const useLastModified = (date: string) => { @@ -25,10 +26,20 @@ export const RepositoryItem = ({ repository }: RepositoryItemProps) => { }; const lastModified = useLastModified(repository.last_modified); + useEffect(() => { + if (isIssueOpen) { + setIsIssuesListVisible(true); + } else { + // Delay unmounting to allow close animation to complete + const timer = setTimeout(() => setIsIssuesListVisible(false), 300); + return () => clearTimeout(timer); + } + }, [isIssueOpen]); + return (
-
setIsIssueOpen(!isIssueOpen)}> -
+
+
setIsIssueOpen(!isIssueOpen)}> { />
- {isIssueOpen && } +
+ {isIssuesListVisible && } +
); diff --git a/styles/globals.scss b/styles/globals.scss index f10c3ac..71566c9 100644 --- a/styles/globals.scss +++ b/styles/globals.scss @@ -170,6 +170,19 @@ base, html { } } +.repo-item__issues-warper { + overflow: hidden; + transition: all 0.3s ease-in-out; + max-height: 0; + opacity: 0; + visibility: hidden; + &.open { + max-height: 1000px; + opacity: 1; + visibility: visible; + } +} + .repo-item__issue-list { display: flex; flex-direction: column;