From 21a0c4d95c839ab0c25886d5cedb1df6382311ba Mon Sep 17 00:00:00 2001 From: Adam Setch Date: Thu, 20 Jun 2024 00:11:30 -0400 Subject: [PATCH 1/2] refactor: opacity --- src/components/AccountNotifications.tsx | 10 +- src/components/NotificationRow.tsx | 22 ++- src/components/RepositoryNotifications.tsx | 11 +- .../AccountNotifications.test.tsx.snap | 67 ++++--- .../NotificationRow.test.tsx.snap | 164 +++++++++--------- .../RepositoryNotifications.test.tsx.snap | 28 +-- src/types.ts | 7 + 7 files changed, 163 insertions(+), 146 deletions(-) diff --git a/src/components/AccountNotifications.tsx b/src/components/AccountNotifications.tsx index ad54f272d..86a3a5a4d 100644 --- a/src/components/AccountNotifications.tsx +++ b/src/components/AccountNotifications.tsx @@ -5,8 +5,9 @@ import { } from '@primer/octicons-react'; import { type FC, useContext, useState } from 'react'; import { AppContext } from '../context/App'; -import type { Account } from '../types'; +import { type Account, Opacity } from '../types'; import type { Notification } from '../typesGitHub'; +import { cn } from '../utils/cn'; import { openAccountProfile } from '../utils/links'; import { NotificationRow } from './NotificationRow'; import { RepositoryNotifications } from './RepositoryNotifications'; @@ -64,7 +65,11 @@ export const AccountNotifications: FC = ( <> {showAccountHostname && (
@@ -73,7 +78,6 @@ export const AccountNotifications: FC = ( type="button" title="Open Profile" onClick={() => openAccountProfile(account)} - className="opacity-80" > @{account.user.login} diff --git a/src/components/NotificationRow.tsx b/src/components/NotificationRow.tsx index 7a6d6f734..c4e77f407 100644 --- a/src/components/NotificationRow.tsx +++ b/src/components/NotificationRow.tsx @@ -17,7 +17,7 @@ import { useState, } from 'react'; import { AppContext } from '../context/App'; -import { IconColor } from '../types'; +import { IconColor, Opacity } from '../types'; import type { Notification } from '../typesGitHub'; import { cn } from '../utils/cn'; import { @@ -118,7 +118,7 @@ export const NotificationRow: FC = ({ 'group flex border-b border-gray-100 bg-white px-3 py-2 hover:bg-gray-100 dark:border-gray-darker dark:bg-gray-dark dark:text-white dark:hover:bg-gray-darker', animateExit && 'translate-x-full opacity-0 transition duration-[350ms] ease-in-out', - showAsRead && 'opacity-50 dark:opacity-50', + showAsRead && Opacity.READ, )} >
= ({
handleNotification()} > {!groupByRepository && (
@@ -158,14 +161,19 @@ export const NotificationRow: FC = ({ )}
{notification.subject.title}
-
+
{notification.subject.user ? (
gitify-app/notifications-test's avatar @@ -112,14 +111,14 @@ exports[`components/AccountNotifications.tsx should render itself (github.com wi
I am a robot and this is a test!
gitify-app/notifications-test's avatar @@ -308,14 +307,14 @@ exports[`components/AccountNotifications.tsx should render itself (github.com wi
Improve the UI
, "container":
gitify-app/notifications-test's avatar @@ -526,14 +524,14 @@ exports[`components/AccountNotifications.tsx should render itself (github.com wi
I am a robot and this is a test!
gitify-app/notifications-test's avatar @@ -722,14 +720,14 @@ exports[`components/AccountNotifications.tsx should render itself (github.com wi
Improve the UI
I am a robot and this is a test!
I am a robot and this is a test!
I am a robot and this is a test!
I am a robot and this is a test!
I am a robot and this is a test!
I am a robot and this is a test!
I am a robot and this is a test!
I am a robot and this is a test!
I am a robot and this is a test!
I am a robot and this is a test!
I am a robot and this is a test!
I am a robot and this is a test!
I am a robot and this is a test!
I am a robot and this is a test!
I am a robot and this is a test!
I am a robot and this is a test!
I am a robot and this is a test!
I am a robot and this is a test!
gitify-app/notifications-test's avatar @@ -4684,14 +4684,14 @@ exports[`components/NotificationRow.tsx should render itself & its children - gr
I am a robot and this is a test!
gitify-app/notifications-test's avatar @@ -4883,14 +4883,14 @@ exports[`components/NotificationRow.tsx should render itself & its children - gr
I am a robot and this is a test!
I am a robot and this is a test!
I am a robot and this is a test!
I am a robot and this is a test!
I am a robot and this is a test!
I am a robot and this is a test!
I am a robot and this is a test!
gitify-app/notifications-test's avatar gitify-app/notifications-test @@ -102,7 +102,7 @@ exports[`components/Repository.tsx should render itself & its children 1`] = ` class="group flex items-center justify-between bg-gray-100 px-3 py-2 dark:bg-gray-darker dark:text-white" >
gitify-app/notifications-test's avatar gitify-app/notifications-test @@ -252,7 +252,7 @@ exports[`components/Repository.tsx should toggle account notifications visibilit class="group flex items-center justify-between bg-gray-100 px-3 py-2 dark:bg-gray-darker dark:text-white" >
gitify-app/notifications-test @@ -347,7 +347,7 @@ exports[`components/Repository.tsx should toggle account notifications visibilit class="group flex items-center justify-between bg-gray-100 px-3 py-2 dark:bg-gray-darker dark:text-white" >
gitify-app/notifications-test @@ -449,7 +449,7 @@ exports[`components/Repository.tsx should toggle account notifications visibilit class="group flex items-center justify-between bg-gray-100 px-3 py-2 dark:bg-gray-darker dark:text-white" >
gitify-app/notifications-test @@ -608,7 +608,7 @@ exports[`components/Repository.tsx should use default repository icon when avata class="group flex items-center justify-between bg-gray-100 px-3 py-2 dark:bg-gray-darker dark:text-white" >
gitify-app/notifications-test @@ -710,7 +710,7 @@ exports[`components/Repository.tsx should use default repository icon when avata class="group flex items-center justify-between bg-gray-100 px-3 py-2 dark:bg-gray-darker dark:text-white" >
gitify-app/notifications-test diff --git a/src/types.ts b/src/types.ts index 71bd888a9..018104677 100644 --- a/src/types.ts +++ b/src/types.ts @@ -137,6 +137,13 @@ export enum IconColor { WHITE = 'text-white', } +export enum Opacity { + READ = 'opacity-50', + LOW = 'opacity-70', + MEDIUM = 'opacity-80', + HIGH = 'opacity-90', +} + export type PullRequestApprovalIcon = { type: FC; color: IconColor; From ae787c4ef4ec50ca458d0b898f27534dcdc5e72c Mon Sep 17 00:00:00 2001 From: Adam Setch Date: Thu, 20 Jun 2024 12:16:00 -0400 Subject: [PATCH 2/2] remove space --- src/components/RepositoryNotifications.tsx | 2 +- .../RepositoryNotifications.test.tsx.snap | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/components/RepositoryNotifications.tsx b/src/components/RepositoryNotifications.tsx index bc8ead0f2..6f917154a 100644 --- a/src/components/RepositoryNotifications.tsx +++ b/src/components/RepositoryNotifications.tsx @@ -70,7 +70,7 @@ export const RepositoryNotifications: FC = ({ defaultIcon={MarkGithubIcon} /> openRepository(repoNotifications[0].repository)} > {repoName} diff --git a/src/components/__snapshots__/RepositoryNotifications.test.tsx.snap b/src/components/__snapshots__/RepositoryNotifications.test.tsx.snap index e5751f957..bfc598eb6 100644 --- a/src/components/__snapshots__/RepositoryNotifications.test.tsx.snap +++ b/src/components/__snapshots__/RepositoryNotifications.test.tsx.snap @@ -17,7 +17,7 @@ exports[`components/Repository.tsx should render itself & its children 1`] = ` src="https://avatars.githubusercontent.com/u/133795385?s=200&v=4" /> gitify-app/notifications-test @@ -110,7 +110,7 @@ exports[`components/Repository.tsx should render itself & its children 1`] = ` src="https://avatars.githubusercontent.com/u/133795385?s=200&v=4" /> gitify-app/notifications-test @@ -269,7 +269,7 @@ exports[`components/Repository.tsx should toggle account notifications visibilit /> gitify-app/notifications-test @@ -364,7 +364,7 @@ exports[`components/Repository.tsx should toggle account notifications visibilit /> gitify-app/notifications-test @@ -466,7 +466,7 @@ exports[`components/Repository.tsx should toggle account notifications visibilit /> gitify-app/notifications-test @@ -625,7 +625,7 @@ exports[`components/Repository.tsx should use default repository icon when avata /> gitify-app/notifications-test @@ -727,7 +727,7 @@ exports[`components/Repository.tsx should use default repository icon when avata /> gitify-app/notifications-test