Skip to content

Commit f360e16

Browse files
authored
refactor: deprecate react-transition-group over tailwind animations (#1232)
1 parent dcef564 commit f360e16

File tree

6 files changed

+67
-118
lines changed

6 files changed

+67
-118
lines changed

package.json

-2
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,6 @@
120120
"react-dom": "18.3.1",
121121
"react-final-form": "6.5.9",
122122
"react-router-dom": "6.23.1",
123-
"react-transition-group": "4.4.5",
124123
"ts-loader": "9.5.1",
125124
"typescript": "5.4.5"
126125
},
@@ -133,7 +132,6 @@
133132
"@types/nprogress": "0.2.3",
134133
"@types/react": "18.3.3",
135134
"@types/react-router-dom": "5.3.3",
136-
"@types/react-transition-group": "4.4.10",
137135
"autoprefixer": "10.4.19",
138136
"css-loader": "7.1.2",
139137
"electron": "31.0.1",

pnpm-lock.yaml

-50
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/NotificationRow.tsx

+24-6
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,17 @@ import {
88
ReadIcon,
99
TagIcon,
1010
} from '@primer/octicons-react';
11-
import { type FC, type MouseEvent, useCallback, useContext } from 'react';
12-
11+
import {
12+
type FC,
13+
type MouseEvent,
14+
useCallback,
15+
useContext,
16+
useState,
17+
} from 'react';
1318
import { AppContext } from '../context/App';
1419
import { type Account, IconColor } from '../types';
1520
import type { Notification } from '../typesGitHub';
21+
import { cn } from '../utils/cn';
1622
import {
1723
formatForDisplay,
1824
formatNotificationUpdatedAt,
@@ -41,8 +47,10 @@ export const NotificationRow: FC<IProps> = ({ notification, account }) => {
4147
unsubscribeNotification,
4248
notifications,
4349
} = useContext(AppContext);
50+
const [animateExit, setAnimateExit] = useState(false);
4451

4552
const handleNotification = useCallback(() => {
53+
setAnimateExit(true);
4654
openNotification(notification);
4755

4856
if (settings.markAsDoneOnOpen) {
@@ -89,10 +97,14 @@ export const NotificationRow: FC<IProps> = ({ notification, account }) => {
8997
return (
9098
<div
9199
id={notification.id}
92-
className="flex py-2 px-3 bg-white dark:bg-gray-dark dark:text-white hover:bg-gray-100 dark:hover:bg-gray-darker border-b border-gray-100 dark:border-gray-darker group"
100+
className={cn(
101+
'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',
102+
animateExit &&
103+
'translate-x-full opacity-0 transition duration-[350ms] ease-in-out',
104+
)}
93105
>
94106
<div
95-
className={`flex justify-center items-center mr-3 w-5 ${iconColor}`}
107+
className={cn('flex justify-center items-center mr-3 w-5', iconColor)}
96108
title={notificationTitle}
97109
>
98110
<NotificationIcon size={18} aria-label={notification.subject.type} />
@@ -204,7 +216,10 @@ export const NotificationRow: FC<IProps> = ({ notification, account }) => {
204216
type="button"
205217
className="focus:outline-none h-full hover:text-green-500"
206218
title="Mark as Done"
207-
onClick={() => markNotificationDone(notification)}
219+
onClick={() => {
220+
setAnimateExit(true);
221+
markNotificationDone(notification);
222+
}}
208223
>
209224
<CheckIcon size={16} aria-label="Mark as Done" />
210225
</button>
@@ -222,7 +237,10 @@ export const NotificationRow: FC<IProps> = ({ notification, account }) => {
222237
type="button"
223238
className="focus:outline-none h-full hover:text-green-500"
224239
title="Mark as Read"
225-
onClick={() => markNotificationRead(notification)}
240+
onClick={() => {
241+
setAnimateExit(true);
242+
markNotificationRead(notification);
243+
}}
226244
>
227245
<ReadIcon size={14} aria-label="Mark as Read" />
228246
</button>

src/components/Repository.tsx

+3-12
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { CheckIcon, MarkGithubIcon, ReadIcon } from '@primer/octicons-react';
22
import { type FC, useCallback, useContext } from 'react';
3-
import { CSSTransition, TransitionGroup } from 'react-transition-group';
43
import { AppContext } from '../context/App';
54
import type { Account } from '../types';
65
import type { Notification } from '../typesGitHub';
@@ -77,17 +76,9 @@ export const RepositoryNotifications: FC<IProps> = ({
7776
</div>
7877
</div>
7978

80-
<TransitionGroup>
81-
{repoNotifications.map((obj) => (
82-
<CSSTransition key={obj.id} timeout={250} classNames="notification">
83-
<NotificationRow
84-
key={obj.id}
85-
account={account}
86-
notification={obj}
87-
/>
88-
</CSSTransition>
89-
))}
90-
</TransitionGroup>
79+
{repoNotifications.map((obj) => (
80+
<NotificationRow key={obj.id} account={account} notification={obj} />
81+
))}
9182
</>
9283
);
9384
};

0 commit comments

Comments
 (0)