1- import { CheckIcon , MarkGithubIcon , ReadIcon } from '@primer/octicons-react' ;
2- import { type FC , useCallback , useContext } from 'react' ;
1+ import {
2+ CheckIcon ,
3+ ChevronDownIcon ,
4+ ChevronUpIcon ,
5+ MarkGithubIcon ,
6+ ReadIcon ,
7+ } from '@primer/octicons-react' ;
8+ import { type FC , useCallback , useContext , useState } from 'react' ;
39import { AppContext } from '../context/App' ;
410import type { Notification } from '../typesGitHub' ;
511import { openRepository } from '../utils/links' ;
@@ -28,10 +34,25 @@ export const RepositoryNotifications: FC<IProps> = ({
2834 const avatarUrl = repoNotifications [ 0 ] . repository . owner . avatar_url ;
2935 const repoSlug = repoNotifications [ 0 ] . repository . full_name ;
3036
37+ const [ showRepositoryNotifications , setShowRepositoryNotifications ] =
38+ useState ( true ) ;
39+
40+ const toggleRepositoryNotifications = ( ) => {
41+ setShowRepositoryNotifications ( ! showRepositoryNotifications ) ;
42+ } ;
43+
44+ const ChevronIcon = showRepositoryNotifications
45+ ? ChevronDownIcon
46+ : ChevronUpIcon ;
47+
48+ const toggleRepositoryNotificationsLabel = showRepositoryNotifications
49+ ? 'Hide repository notifications'
50+ : 'Show repository notifications' ;
51+
3152 return (
3253 < >
33- < div className = "group flex bg-gray-100 px-3 py-2 dark:bg-gray-darker dark:text-white" >
34- < div className = "mt-0 flex flex-1 items-center space-x-3 overflow-hidden overflow-ellipsis whitespace-nowrap text-sm font-medium" >
54+ < div className = "group flex items-center justify-between bg-gray-100 px-3 py-2 dark:bg-gray-darker dark:text-white" >
55+ < div className = "mt-0 flex flex-1 space-x-3 overflow-hidden overflow-ellipsis whitespace-nowrap text-sm font-medium" >
3556 { avatarUrl ? (
3657 < img
3758 className = "size-5 rounded"
@@ -51,6 +72,14 @@ export const RepositoryNotifications: FC<IProps> = ({
5172 </ div >
5273
5374 < div className = "flex items-center justify-center gap-2 opacity-0 transition-opacity group-hover:opacity-80" >
75+ < button
76+ type = "button"
77+ className = "h-full hover:text-green-500 focus:outline-none"
78+ title = { toggleRepositoryNotificationsLabel }
79+ onClick = { toggleRepositoryNotifications }
80+ >
81+ < ChevronIcon size = { 16 } />
82+ </ button >
5483 < button
5584 type = "button"
5685 className = "h-full hover:text-green-500 focus:outline-none"
@@ -73,9 +102,10 @@ export const RepositoryNotifications: FC<IProps> = ({
73102 </ div >
74103 </ div >
75104
76- { repoNotifications . map ( ( obj ) => (
77- < NotificationRow key = { obj . id } notification = { obj } />
78- ) ) }
105+ { showRepositoryNotifications &&
106+ repoNotifications . map ( ( obj ) => (
107+ < NotificationRow key = { obj . id } notification = { obj } />
108+ ) ) }
79109 </ >
80110 ) ;
81111} ;
0 commit comments