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

style: toggle on row click & action buttons order #1248

Merged
merged 6 commits into from
Jun 16, 2024
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
3 changes: 3 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
"noUnusedFunctionParameters": "error",
"useDefaultSwitchClause": "error"
},
"a11y": {
"useKeyWithClickEvents": "off"
},
"correctness": {
"useExhaustiveDependencies": {
"level": "warn",
Expand Down
9 changes: 6 additions & 3 deletions src/components/AccountNotifications.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,11 @@ export const AccountNotifications = (props: IProps) => {
return (
<>
{showAccountHostname && (
<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">
<div>
<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"
onClick={toggleAccountNotifications}
>
<div className="flex gap-3">
<PlatformIcon type={account.platform} size={16} />
<button
type="button"
Expand All @@ -74,7 +77,7 @@ export const AccountNotifications = (props: IProps) => {
title={toggleAccountNotificationsLabel}
onClick={toggleAccountNotifications}
>
<ChevronIcon size={20} />
<ChevronIcon size={14} />
</button>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/components/NotificationRow.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ describe('components/NotificationRow.tsx', () => {
</AppContext.Provider>,
);

fireEvent.keyDown(screen.getByRole('main'));
fireEvent.click(screen.getByRole('main'));
expect(links.openNotification).toHaveBeenCalledTimes(1);
expect(removeNotificationFromState).toHaveBeenCalledTimes(1);
});
Expand Down
19 changes: 9 additions & 10 deletions src/components/NotificationRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ export const NotificationRow: FC<IProps> = ({ notification }) => {
<div
className="flex-1 overflow-hidden overflow-ellipsis whitespace-nowrap"
onClick={() => handleNotification()}
onKeyDown={() => handleNotification()}
>
<div
className="mb-1 cursor-pointer truncate text-sm"
Expand Down Expand Up @@ -230,15 +229,6 @@ export const NotificationRow: FC<IProps> = ({ notification }) => {
<CheckIcon size={16} aria-label="Mark as Done" />
</button>

<button
type="button"
className="h-full hover:text-red-500 focus:outline-none"
title="Unsubscribe from Thread"
onClick={unsubscribeFromThread}
>
<BellSlashIcon size={14} aria-label="Unsubscribe from Thread" />
</button>

<button
type="button"
className="h-full hover:text-green-500 focus:outline-none"
Expand All @@ -251,6 +241,15 @@ export const NotificationRow: FC<IProps> = ({ notification }) => {
>
<ReadIcon size={14} aria-label="Mark as Read" />
</button>

<button
type="button"
className="h-full hover:text-red-500 focus:outline-none"
title="Unsubscribe from Thread"
onClick={unsubscribeFromThread}
>
<BellSlashIcon size={14} aria-label="Unsubscribe from Thread" />
</button>
</div>
</div>
);
Expand Down
25 changes: 13 additions & 12 deletions src/components/Repository.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,10 @@ export const RepositoryNotifications: FC<IProps> = ({

return (
<>
<div className="group flex items-center justify-between bg-gray-100 px-3 py-2 dark:bg-gray-darker dark:text-white">
<div
className="group flex items-center justify-between bg-gray-100 px-3 py-2 dark:bg-gray-darker dark:text-white"
onClick={toggleRepositoryNotifications}
>
<div className="mt-0 flex flex-1 space-x-3 overflow-hidden overflow-ellipsis whitespace-nowrap text-sm font-medium">
{avatarUrl ? (
<img
Expand All @@ -65,21 +68,12 @@ export const RepositoryNotifications: FC<IProps> = ({
<span
className="cursor-pointer truncate opacity-90"
onClick={() => openRepository(repoNotifications[0].repository)}
onKeyDown={() => openRepository(repoNotifications[0].repository)}
>
{repoName}
</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"
title={toggleRepositoryNotificationsLabel}
onClick={toggleRepositoryNotifications}
>
<ChevronIcon size={16} />
</button>
<button
type="button"
className="h-full hover:text-green-500 focus:outline-none"
Expand All @@ -89,8 +83,6 @@ export const RepositoryNotifications: FC<IProps> = ({
<CheckIcon size={16} aria-label="Mark Repository as Done" />
</button>

<div className="w-[14px]" />

<button
type="button"
className="h-full hover:text-green-500 focus:outline-none"
Expand All @@ -99,6 +91,15 @@ export const RepositoryNotifications: FC<IProps> = ({
>
<ReadIcon size={14} aria-label="Mark Repository as Read" />
</button>

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

Expand Down
76 changes: 45 additions & 31 deletions src/components/__snapshots__/AccountNotifications.test.tsx.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading