Skip to content

feat: simplify icon colors and improve accessibility when in light-mode #857

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

Merged
merged 2 commits into from
Mar 5, 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
8 changes: 4 additions & 4 deletions src/utils/__snapshots__/github-api.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -120,24 +120,24 @@ exports[`getNotificationTypeIconColor should format the notification color for c

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

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

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

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

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

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

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

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

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

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

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

exports[`getNotificationTypeIconColor should format the notification color for state 10`] = `"text-gray-300"`;
exports[`getNotificationTypeIconColor should format the notification color for state 10`] = `"text-gray-500"`;
8 changes: 8 additions & 0 deletions src/utils/appearance.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
import { Appearance } from '../types';

export function getAppearance(): Appearance {
if (document.querySelector('html').classList.contains('dark')) {
return Appearance.DARK;
}

return Appearance.LIGHT;
}

export const setLightMode = () =>
document.querySelector('html').classList.remove('dark');

Expand Down
32 changes: 12 additions & 20 deletions src/utils/github-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ import {
XIcon,
} from '@primer/octicons-react';
import { Reason, Subject } from '../typesGithub';
import { Appearance } from '../types';
import { getAppearance } from './appearance';

// prettier-ignore
const DESCRIPTIONS = {
Expand Down Expand Up @@ -157,33 +159,23 @@ export function getNotificationTypeIcon(

export function getNotificationTypeIconColor(subject: Subject): string {
switch (subject.state) {
case 'open':
case 'reopened':
case 'ANSWERED':
case 'success':
return 'text-green-500';
case 'cancelled':
return 'text-gray-500';
case 'closed':
return 'text-red-500';
case 'completed':
return 'text-purple-500';
case 'draft':
return 'text-gray-600';
case 'failure':
return 'text-red-500';
case 'merged':
return 'text-purple-500';
case 'not_planned':
return 'text-gray-300';
case 'open':
return 'text-green-500';
case 'reopened':
return 'text-green-500';
case 'completed':
case 'RESOLVED':
case 'merged':
return 'text-purple-500';
case 'skipped':
return 'text-gray-500';
case 'success':
return 'text-green-500';
default:
return 'text-gray-300';
const appearance = getAppearance();
if (appearance == Appearance.DARK) {
return 'text-gray-300';
}
return 'text-gray-500';
}
}