Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ui): add smooth toggle transition for reposity issues list #199

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions components/RepositoryItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand All @@ -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 (
<div className="repo-item">
<div id={`repo-${repository.id}`} onClick={() => setIsIssueOpen(!isIssueOpen)}>
<div>
<div id={`repo-${repository.id}`}>
<div onClick={() => setIsIssueOpen(!isIssueOpen)}>
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moved onClick to this line so the IssuesList will be only closed if user clicked on the top-bar section of repo-item

<RepositoryItemTopBar
isIssueOpen={isIssueOpen}
repositoryHasNewIssues={repository.has_new_issues}
Expand All @@ -50,7 +61,9 @@ export const RepositoryItem = ({ repository }: RepositoryItemProps) => {
/>
</div>
</div>
{isIssueOpen && <IssuesList issues={repository.issues} />}
<div className={`repo-item__issues-warper ${isIssueOpen ? 'open' : ''}`}>
{isIssuesListVisible && <IssuesList issues={repository.issues} />}
</div>
</div>
</div>
);
Expand Down
13 changes: 13 additions & 0 deletions styles/globals.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down