Skip to content

Commit 1db9553

Browse files
authored
feat: simplify icon colors and improve accessibility when in light-mode (#857)
* feat: simplify icon colors and improve accessibility when in light-mode * feat: change gray color based on theme
1 parent 473e152 commit 1db9553

File tree

3 files changed

+24
-24
lines changed

3 files changed

+24
-24
lines changed

src/utils/__snapshots__/github-api.test.ts.snap

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,24 +120,24 @@ exports[`getNotificationTypeIconColor should format the notification color for c
120120

121121
exports[`getNotificationTypeIconColor should format the notification color for check suite 4`] = `"text-green-500"`;
122122

123-
exports[`getNotificationTypeIconColor should format the notification color for check suite 5`] = `"text-gray-300"`;
123+
exports[`getNotificationTypeIconColor should format the notification color for check suite 5`] = `"text-gray-500"`;
124124

125125
exports[`getNotificationTypeIconColor should format the notification color for state 1`] = `"text-green-500"`;
126126

127127
exports[`getNotificationTypeIconColor should format the notification color for state 2`] = `"text-red-500"`;
128128

129129
exports[`getNotificationTypeIconColor should format the notification color for state 3`] = `"text-purple-500"`;
130130

131-
exports[`getNotificationTypeIconColor should format the notification color for state 4`] = `"text-gray-600"`;
131+
exports[`getNotificationTypeIconColor should format the notification color for state 4`] = `"text-gray-500"`;
132132

133133
exports[`getNotificationTypeIconColor should format the notification color for state 5`] = `"text-purple-500"`;
134134

135-
exports[`getNotificationTypeIconColor should format the notification color for state 6`] = `"text-gray-300"`;
135+
exports[`getNotificationTypeIconColor should format the notification color for state 6`] = `"text-gray-500"`;
136136

137137
exports[`getNotificationTypeIconColor should format the notification color for state 7`] = `"text-green-500"`;
138138

139139
exports[`getNotificationTypeIconColor should format the notification color for state 8`] = `"text-green-500"`;
140140

141141
exports[`getNotificationTypeIconColor should format the notification color for state 9`] = `"text-purple-500"`;
142142

143-
exports[`getNotificationTypeIconColor should format the notification color for state 10`] = `"text-gray-300"`;
143+
exports[`getNotificationTypeIconColor should format the notification color for state 10`] = `"text-gray-500"`;

src/utils/appearance.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
import { Appearance } from '../types';
22

3+
export function getAppearance(): Appearance {
4+
if (document.querySelector('html').classList.contains('dark')) {
5+
return Appearance.DARK;
6+
}
7+
8+
return Appearance.LIGHT;
9+
}
10+
311
export const setLightMode = () =>
412
document.querySelector('html').classList.remove('dark');
513

src/utils/github-api.ts

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ import {
2525
XIcon,
2626
} from '@primer/octicons-react';
2727
import { Reason, Subject } from '../typesGithub';
28+
import { Appearance } from '../types';
29+
import { getAppearance } from './appearance';
2830

2931
// prettier-ignore
3032
const DESCRIPTIONS = {
@@ -157,33 +159,23 @@ export function getNotificationTypeIcon(
157159

158160
export function getNotificationTypeIconColor(subject: Subject): string {
159161
switch (subject.state) {
162+
case 'open':
163+
case 'reopened':
160164
case 'ANSWERED':
165+
case 'success':
161166
return 'text-green-500';
162-
case 'cancelled':
163-
return 'text-gray-500';
164167
case 'closed':
165-
return 'text-red-500';
166-
case 'completed':
167-
return 'text-purple-500';
168-
case 'draft':
169-
return 'text-gray-600';
170168
case 'failure':
171169
return 'text-red-500';
172-
case 'merged':
173-
return 'text-purple-500';
174-
case 'not_planned':
175-
return 'text-gray-300';
176-
case 'open':
177-
return 'text-green-500';
178-
case 'reopened':
179-
return 'text-green-500';
170+
case 'completed':
180171
case 'RESOLVED':
172+
case 'merged':
181173
return 'text-purple-500';
182-
case 'skipped':
183-
return 'text-gray-500';
184-
case 'success':
185-
return 'text-green-500';
186174
default:
187-
return 'text-gray-300';
175+
const appearance = getAppearance();
176+
if (appearance == Appearance.DARK) {
177+
return 'text-gray-300';
178+
}
179+
return 'text-gray-500';
188180
}
189181
}

0 commit comments

Comments
 (0)