Skip to content

Commit cfaf623

Browse files
authored
feat: update/move "unsubscribe" icon (#745)
* feat: add button to mark a notification as done * tests: add tests for `markNotificationDone()` * feat: update "mark notification as read" icon * tests: update snaps * fix: remove now obsolete `markOnClick` * feat: change & move unsubscribe icon * test: update snap
1 parent 16a3904 commit cfaf623

File tree

2 files changed

+56
-55
lines changed

2 files changed

+56
-55
lines changed

src/components/NotificationRow.tsx

+20-19
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, { useCallback, useContext } from 'react';
22
import { formatDistanceToNow, parseISO } from 'date-fns';
3-
import { CheckIcon, MuteIcon, ReadIcon } from '@primer/octicons-react';
3+
import { CheckIcon, BellSlashIcon, ReadIcon } from '@primer/octicons-react';
44

55
import {
66
formatReason,
@@ -72,21 +72,22 @@ export const NotificationRow: React.FC<IProps> = ({
7272
<div className="text-xs text-capitalize">
7373
<span title={reason.description}>{reason.type}</span> - Updated{' '}
7474
{updatedAt}
75-
<button
76-
className="border-0 bg-none float-right"
77-
title="Unsubscribe"
78-
onClick={unsubscribe}
79-
>
80-
<MuteIcon
81-
className="hover:text-red-500"
82-
size={13}
83-
aria-label="Unsubscribe"
84-
/>
85-
</button>
8675
</div>
8776
</div>
8877

8978
<div className="flex justify-center items-center gap-2">
79+
<button
80+
className="focus:outline-none"
81+
title="Mark as Done"
82+
onClick={() => markNotificationDone(notification.id, hostname)}
83+
>
84+
<CheckIcon
85+
className="hover:text-green-500"
86+
size={16}
87+
aria-label="Mark as Done"
88+
/>
89+
</button>
90+
9091
<button
9192
className="focus:outline-none"
9293
title="Mark as Read"
@@ -100,14 +101,14 @@ export const NotificationRow: React.FC<IProps> = ({
100101
</button>
101102

102103
<button
103-
className="focus:outline-none"
104-
title="Mark as Done"
105-
onClick={() => markNotificationDone(notification.id, hostname)}
104+
className="border-0 bg-none float-right"
105+
title="Unsubscribe"
106+
onClick={unsubscribe}
106107
>
107-
<CheckIcon
108-
className="hover:text-green-500"
109-
size={16}
110-
aria-label="Mark as Done"
108+
<BellSlashIcon
109+
className="hover:text-red-500"
110+
size={14}
111+
aria-label="Unsubscribe"
111112
/>
112113
</button>
113114
</div>

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

+36-36
Original file line numberDiff line numberDiff line change
@@ -55,40 +55,40 @@ exports[`components/Notification.js should render itself & its children 1`] = `
5555
- Updated
5656
5757
in over 3 years
58-
<button
59-
className="border-0 bg-none float-right"
60-
onClick={[Function]}
61-
title="Unsubscribe"
62-
>
63-
<svg
64-
aria-hidden="false"
65-
aria-label="Unsubscribe"
66-
className="hover:text-red-500"
67-
fill="currentColor"
68-
focusable="false"
69-
height={13}
70-
role="img"
71-
style={
72-
{
73-
"display": "inline-block",
74-
"overflow": "visible",
75-
"userSelect": "none",
76-
"verticalAlign": "text-bottom",
77-
}
78-
}
79-
viewBox="0 0 16 16"
80-
width={13}
81-
>
82-
<path
83-
d="M8 2.75v10.5a.751.751 0 0 1-1.238.57L3.473 11H1.75A1.75 1.75 0 0 1 0 9.25v-2.5C0 5.784.784 5 1.75 5h1.722l3.29-2.82A.75.75 0 0 1 8 2.75Zm3.28 2.47L13 6.94l1.72-1.72a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042L14.06 8l1.72 1.72a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215L13 9.06l-1.72 1.72a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L11.94 8l-1.72-1.72a.749.749 0 0 1 .326-1.275.749.749 0 0 1 .734.215Zm-7.042 1.1a.752.752 0 0 1-.488.18h-2a.25.25 0 0 0-.25.25v2.5c0 .138.112.25.25.25h2c.179 0 .352.064.488.18L6.5 11.62V4.38Z"
84-
/>
85-
</svg>
86-
</button>
8758
</div>
8859
</div>
8960
<div
9061
className="flex justify-center items-center gap-2"
9162
>
63+
<button
64+
className="focus:outline-none"
65+
onClick={[Function]}
66+
title="Mark as Done"
67+
>
68+
<svg
69+
aria-hidden="false"
70+
aria-label="Mark as Done"
71+
className="hover:text-green-500"
72+
fill="currentColor"
73+
focusable="false"
74+
height={16}
75+
role="img"
76+
style={
77+
{
78+
"display": "inline-block",
79+
"overflow": "visible",
80+
"userSelect": "none",
81+
"verticalAlign": "text-bottom",
82+
}
83+
}
84+
viewBox="0 0 16 16"
85+
width={16}
86+
>
87+
<path
88+
d="M13.78 4.22a.75.75 0 0 1 0 1.06l-7.25 7.25a.75.75 0 0 1-1.06 0L2.22 9.28a.751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018L6 10.94l6.72-6.72a.75.75 0 0 1 1.06 0Z"
89+
/>
90+
</svg>
91+
</button>
9292
<button
9393
className="focus:outline-none"
9494
onClick={[Function]}
@@ -119,17 +119,17 @@ exports[`components/Notification.js should render itself & its children 1`] = `
119119
</svg>
120120
</button>
121121
<button
122-
className="focus:outline-none"
122+
className="border-0 bg-none float-right"
123123
onClick={[Function]}
124-
title="Mark as Done"
124+
title="Unsubscribe"
125125
>
126126
<svg
127127
aria-hidden="false"
128-
aria-label="Mark as Done"
129-
className="hover:text-green-500"
128+
aria-label="Unsubscribe"
129+
className="hover:text-red-500"
130130
fill="currentColor"
131131
focusable="false"
132-
height={16}
132+
height={14}
133133
role="img"
134134
style={
135135
{
@@ -140,10 +140,10 @@ exports[`components/Notification.js should render itself & its children 1`] = `
140140
}
141141
}
142142
viewBox="0 0 16 16"
143-
width={16}
143+
width={14}
144144
>
145145
<path
146-
d="M13.78 4.22a.75.75 0 0 1 0 1.06l-7.25 7.25a.75.75 0 0 1-1.06 0L2.22 9.28a.751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018L6 10.94l6.72-6.72a.75.75 0 0 1 1.06 0Z"
146+
d="m4.182 4.31.016.011 10.104 7.316.013.01 1.375.996a.75.75 0 1 1-.88 1.214L13.626 13H2.518a1.516 1.516 0 0 1-1.263-2.36l1.703-2.554A.255.255 0 0 0 3 7.947V5.305L.31 3.357a.75.75 0 1 1 .88-1.214Zm7.373 7.19L4.5 6.391v1.556c0 .346-.102.683-.294.97l-1.703 2.556a.017.017 0 0 0-.003.01c0 .005.002.009.005.012l.006.004.007.001ZM8 1.5c-.997 0-1.895.416-2.534 1.086A.75.75 0 1 1 4.38 1.55 5 5 0 0 1 13 5v2.373a.75.75 0 0 1-1.5 0V5A3.5 3.5 0 0 0 8 1.5ZM8 16a2 2 0 0 1-1.985-1.75c-.017-.137.097-.25.235-.25h3.5c.138 0 .252.113.235.25A2 2 0 0 1 8 16Z"
147147
/>
148148
</svg>
149149
</button>

0 commit comments

Comments
 (0)