Skip to content
Merged
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
16 changes: 8 additions & 8 deletions src/components/AccountNotifications.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ import { AppContext } from '../context/App';
import { type Account, Size } from '../types';
import type { Notification } from '../typesGitHub';
import { openAccountProfile } from '../utils/links';
import { HoverGroup } from './HoverGroup';
import { NotificationRow } from './NotificationRow';
import { RepositoryNotifications } from './RepositoryNotifications';
import { InteractionButton } from './buttons/InteractionButton';
import { PlatformIcon } from './icons/PlatformIcon';

interface IAccountNotifications {
Expand Down Expand Up @@ -82,16 +84,14 @@ export const AccountNotifications: FC<IAccountNotifications> = (
@{account.user.login}
</button>
</div>
<div className="opacity-0 transition-opacity group-hover:opacity-80">
<button
type="button"
className="h-full hover:text-green-500 focus:outline-none"
<HoverGroup>
<InteractionButton
title={toggleAccountNotificationsLabel}
icon={ChevronIcon}
size={Size.SMALL}
onClick={toggleAccountNotifications}
>
<ChevronIcon size={Size.SMALL} />
</button>
</div>
/>
</HoverGroup>
</div>
)}

Expand Down
9 changes: 9 additions & 0 deletions src/components/HoverGroup.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { render } from '@testing-library/react';
import { HoverGroup } from './HoverGroup';

describe('components/HoverGroup.tsx', () => {
it('should render', () => {
const tree = render(<HoverGroup>Hover Group</HoverGroup>);
expect(tree).toMatchSnapshot();
});
});
13 changes: 13 additions & 0 deletions src/components/HoverGroup.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import type { FC, ReactNode } from 'react';

interface IHoverGroup {
children: ReactNode;
}

export const HoverGroup: FC<IHoverGroup> = ({ children }: IHoverGroup) => {
return (
<div className="flex items-center justify-center gap-2 opacity-0 transition-opacity group-hover:opacity-80">
{children}
</div>
);
};
41 changes: 16 additions & 25 deletions src/components/NotificationRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ import {
openUserProfile,
} from '../utils/links';
import { formatReason } from '../utils/reason';
import { HoverGroup } from './HoverGroup';
import { InteractionButton } from './buttons/InteractionButton';
import { PillButton } from './buttons/PillButton';
import { AvatarIcon } from './icons/AvatarIcon';

Expand Down Expand Up @@ -255,45 +257,34 @@ export const NotificationRow: FC<INotificationRow> = ({
</div>
</div>

<div className="flex items-center justify-center gap-2 opacity-0 transition-opacity group-hover:opacity-80">
<button
type="button"
className="h-full hover:text-green-500 focus:outline-none"
<HoverGroup>
<InteractionButton
title="Mark as Done"
icon={CheckIcon}
size={Size.MEDIUM}
onClick={() => {
setAnimateExit(!settings.delayNotificationState);
setShowAsRead(settings.delayNotificationState);
markNotificationDone(notification);
}}
>
<CheckIcon size={Size.MEDIUM} aria-label="Mark as Done" />
</button>

<button
type="button"
className="h-full hover:text-green-500 focus:outline-none"
/>
<InteractionButton
title="Mark as Read"
icon={ReadIcon}
size={Size.SMALL}
onClick={() => {
setAnimateExit(!settings.delayNotificationState);
setShowAsRead(settings.delayNotificationState);
markNotificationRead(notification);
}}
>
<ReadIcon size={Size.SMALL} aria-label="Mark as Read" />
</button>

<button
type="button"
className="h-full hover:text-red-500 focus:outline-none"
/>
<InteractionButton
title="Unsubscribe from Thread"
icon={BellSlashIcon}
size={Size.SMALL}
onClick={unsubscribeFromThread}
>
<BellSlashIcon
size={Size.SMALL}
aria-label="Unsubscribe from Thread"
/>
</button>
</div>
/>
</HoverGroup>
</div>
);
};
41 changes: 16 additions & 25 deletions src/components/RepositoryNotifications.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ import { AppContext } from '../context/App';
import { Size } from '../types';
import type { Notification } from '../typesGitHub';
import { openRepository } from '../utils/links';
import { HoverGroup } from './HoverGroup';
import { NotificationRow } from './NotificationRow';
import { InteractionButton } from './buttons/InteractionButton';
import { AvatarIcon } from './icons/AvatarIcon';

interface IRepositoryNotifications {
Expand Down Expand Up @@ -81,37 +83,26 @@ export const RepositoryNotifications: FC<IRepositoryNotifications> = ({
</span>
</div>

<div className="flex items-center justify-center gap-2 opacity-0 transition-opacity group-hover:opacity-80">
<button
type="button"
className="h-full hover:text-green-500 focus:outline-none"
<HoverGroup>
<InteractionButton
title="Mark Repository as Done"
icon={CheckIcon}
size={Size.MEDIUM}
onClick={markRepoAsDone}
>
<CheckIcon
size={Size.MEDIUM}
aria-label="Mark Repository as Done"
/>
</button>

<button
type="button"
className="h-full hover:text-green-500 focus:outline-none"
/>
<InteractionButton
title="Mark Repository as Read"
icon={ReadIcon}
size={Size.SMALL}
onClick={markRepoAsRead}
>
<ReadIcon size={Size.SMALL} aria-label="Mark Repository as Read" />
</button>

<button
type="button"
className="h-full hover:text-green-500 focus:outline-none"
/>
<InteractionButton
title={toggleRepositoryNotificationsLabel}
icon={ChevronIcon}
size={Size.SMALL}
onClick={toggleRepositoryNotifications}
>
<ChevronIcon size={Size.SMALL} />
</button>
</div>
/>
</HoverGroup>
</div>

{showRepositoryNotifications &&
Expand Down
Loading