Skip to content

Commit bc5c1ca

Browse files
afonsojramossetchy
andauthored
style: toggle on row click & action buttons order (#1248)
* feat: toggle repository notification * feat: toggle repository notification * style: toggle on row click & action buttons order * chore: update snapshots * fix: restore `gap` in account spacing --------- Co-authored-by: Adam Setch <[email protected]>
1 parent 867555d commit bc5c1ca

File tree

8 files changed

+429
-430
lines changed

8 files changed

+429
-430
lines changed

biome.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
"noUnusedFunctionParameters": "error",
1212
"useDefaultSwitchClause": "error"
1313
},
14+
"a11y": {
15+
"useKeyWithClickEvents": "off"
16+
},
1417
"correctness": {
1518
"useExhaustiveDependencies": {
1619
"level": "warn",

src/components/AccountNotifications.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,11 @@ export const AccountNotifications = (props: IProps) => {
5555
return (
5656
<>
5757
{showAccountHostname && (
58-
<div className="group flex items-center justify-between bg-gray-300 px-3 py-2 text-sm font-semibold dark:bg-gray-darkest dark:text-white">
59-
<div>
58+
<div
59+
className="group flex items-center justify-between bg-gray-300 px-3 py-2 text-sm font-semibold dark:bg-gray-darkest dark:text-white"
60+
onClick={toggleAccountNotifications}
61+
>
62+
<div className="flex gap-3">
6063
<PlatformIcon type={account.platform} size={16} />
6164
<button
6265
type="button"
@@ -74,7 +77,7 @@ export const AccountNotifications = (props: IProps) => {
7477
title={toggleAccountNotificationsLabel}
7578
onClick={toggleAccountNotifications}
7679
>
77-
<ChevronIcon size={20} />
80+
<ChevronIcon size={14} />
7881
</button>
7982
</div>
8083
</div>

src/components/NotificationRow.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ describe('components/NotificationRow.tsx', () => {
399399
</AppContext.Provider>,
400400
);
401401

402-
fireEvent.keyDown(screen.getByRole('main'));
402+
fireEvent.click(screen.getByRole('main'));
403403
expect(links.openNotification).toHaveBeenCalledTimes(1);
404404
expect(removeNotificationFromState).toHaveBeenCalledTimes(1);
405405
});

src/components/NotificationRow.tsx

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,6 @@ export const NotificationRow: FC<IProps> = ({ notification }) => {
118118
<div
119119
className="flex-1 overflow-hidden overflow-ellipsis whitespace-nowrap"
120120
onClick={() => handleNotification()}
121-
onKeyDown={() => handleNotification()}
122121
>
123122
<div
124123
className="mb-1 cursor-pointer truncate text-sm"
@@ -230,15 +229,6 @@ export const NotificationRow: FC<IProps> = ({ notification }) => {
230229
<CheckIcon size={16} aria-label="Mark as Done" />
231230
</button>
232231

233-
<button
234-
type="button"
235-
className="h-full hover:text-red-500 focus:outline-none"
236-
title="Unsubscribe from Thread"
237-
onClick={unsubscribeFromThread}
238-
>
239-
<BellSlashIcon size={14} aria-label="Unsubscribe from Thread" />
240-
</button>
241-
242232
<button
243233
type="button"
244234
className="h-full hover:text-green-500 focus:outline-none"
@@ -251,6 +241,15 @@ export const NotificationRow: FC<IProps> = ({ notification }) => {
251241
>
252242
<ReadIcon size={14} aria-label="Mark as Read" />
253243
</button>
244+
245+
<button
246+
type="button"
247+
className="h-full hover:text-red-500 focus:outline-none"
248+
title="Unsubscribe from Thread"
249+
onClick={unsubscribeFromThread}
250+
>
251+
<BellSlashIcon size={14} aria-label="Unsubscribe from Thread" />
252+
</button>
254253
</div>
255254
</div>
256255
);

src/components/Repository.tsx

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,10 @@ export const RepositoryNotifications: FC<IProps> = ({
5151

5252
return (
5353
<>
54-
<div className="group flex items-center justify-between bg-gray-100 px-3 py-2 dark:bg-gray-darker dark:text-white">
54+
<div
55+
className="group flex items-center justify-between bg-gray-100 px-3 py-2 dark:bg-gray-darker dark:text-white"
56+
onClick={toggleRepositoryNotifications}
57+
>
5558
<div className="mt-0 flex flex-1 space-x-3 overflow-hidden overflow-ellipsis whitespace-nowrap text-sm font-medium">
5659
{avatarUrl ? (
5760
<img
@@ -65,21 +68,12 @@ export const RepositoryNotifications: FC<IProps> = ({
6568
<span
6669
className="cursor-pointer truncate opacity-90"
6770
onClick={() => openRepository(repoNotifications[0].repository)}
68-
onKeyDown={() => openRepository(repoNotifications[0].repository)}
6971
>
7072
{repoName}
7173
</span>
7274
</div>
7375

7476
<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>
8377
<button
8478
type="button"
8579
className="h-full hover:text-green-500 focus:outline-none"
@@ -89,8 +83,6 @@ export const RepositoryNotifications: FC<IProps> = ({
8983
<CheckIcon size={16} aria-label="Mark Repository as Done" />
9084
</button>
9185

92-
<div className="w-[14px]" />
93-
9486
<button
9587
type="button"
9688
className="h-full hover:text-green-500 focus:outline-none"
@@ -99,6 +91,15 @@ export const RepositoryNotifications: FC<IProps> = ({
9991
>
10092
<ReadIcon size={14} aria-label="Mark Repository as Read" />
10193
</button>
94+
95+
<button
96+
type="button"
97+
className="h-full hover:text-green-500 focus:outline-none"
98+
title={toggleRepositoryNotificationsLabel}
99+
onClick={toggleRepositoryNotifications}
100+
>
101+
<ChevronIcon size={14} />
102+
</button>
102103
</div>
103104
</div>
104105

src/components/__snapshots__/AccountNotifications.test.tsx.snap

Lines changed: 45 additions & 31 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)