Skip to content

Commit

Permalink
refactor: move custom styles into class
Browse files Browse the repository at this point in the history
  • Loading branch information
setchy committed Jun 10, 2024
1 parent 4f4a983 commit 3e4f234
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 15 deletions.
12 changes: 6 additions & 6 deletions src/components/NotificationRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ import {
} from 'react';

import { AppContext } from '../context/App';
import { PILL_CLASS_NAME } from '../styles/gitify';
import { IconColor } from '../types';
import type { Notification } from '../typesGitHub';
import { openExternalLink } from '../utils/comms';
import Constants from '../utils/constants';
import {
formatForDisplay,
formatNotificationUpdatedAt,
Expand Down Expand Up @@ -156,7 +156,7 @@ export const NotificationRow: FC<IProps> = ({ notification, hostname }) => {
<div>
{notification.subject?.linkedIssues?.length > 0 && (
<span title={linkedIssuesPillDescription}>
<button type="button" className={Constants.PILL_CLASS_NAME}>
<button type="button" className={PILL_CLASS_NAME}>
<IssueClosedIcon
size={12}
className={`mr-1 ${IconColor.GREEN}`}
Expand All @@ -174,7 +174,7 @@ export const NotificationRow: FC<IProps> = ({ notification, hostname }) => {

return (
<span key={review.state} title={icon.description}>
<button type="button" className={Constants.PILL_CLASS_NAME}>
<button type="button" className={PILL_CLASS_NAME}>
<icon.type
size={12}
className={`mr-1 ${icon.color}`}
Expand All @@ -187,7 +187,7 @@ export const NotificationRow: FC<IProps> = ({ notification, hostname }) => {
})}
{notification.subject?.comments > 0 && (
<span title={commentsPillDescription}>
<button type="button" className={Constants.PILL_CLASS_NAME}>
<button type="button" className={PILL_CLASS_NAME}>
<CommentIcon
size={12}
className={`mr-1 ${IconColor.GRAY}`}
Expand All @@ -199,7 +199,7 @@ export const NotificationRow: FC<IProps> = ({ notification, hostname }) => {
)}
{notification.subject?.labels?.length > 0 && (
<span title={labelsPillDescription}>
<button type="button" className={Constants.PILL_CLASS_NAME}>
<button type="button" className={PILL_CLASS_NAME}>
<TagIcon
size={12}
className={`mr-1 ${IconColor.GRAY}`}
Expand All @@ -214,7 +214,7 @@ export const NotificationRow: FC<IProps> = ({ notification, hostname }) => {
className="ml-1"
title={notification.subject.milestone.title}
>
<button type="button" className={Constants.PILL_CLASS_NAME}>
<button type="button" className={PILL_CLASS_NAME}>
<MilestoneIcon
size={12}
className={
Expand Down
4 changes: 4 additions & 0 deletions src/styles/gitify.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export const READ_NOTIFICATION_CLASS_NAME = 'opacity-50 dark:opacity-50';

export const PILL_CLASS_NAME =
'rounded-full text-xss px-1 m-0.5 bg-gray-100 hover:bg-gray-200 dark:bg-gray-800 dark:hover:bg-gray-700';
5 changes: 0 additions & 5 deletions src/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,6 @@ export const Constants = {

FETCH_INTERVAL: 60000,

READ_CLASS_NAME: 'opacity-50 dark:opacity-50',

PILL_CLASS_NAME:
'rounded-full text-xss px-1 m-0.5 bg-gray-100 hover:bg-gray-200 dark:bg-gray-800 dark:hover:bg-gray-700',

// GitHub Docs
GITHUB_DOCS: {
OAUTH_URL:
Expand Down
4 changes: 2 additions & 2 deletions src/utils/remove-notification.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { mockSingleAccountNotifications } from '../__mocks__/notifications-mocks';
import { mockSettings } from '../__mocks__/state-mocks';
import { READ_NOTIFICATION_CLASS_NAME } from '../styles/gitify';
import { mockSingleNotification } from './api/__mocks__/response-mocks';
import Constants from './constants';
import { removeNotification } from './remove-notification';

describe('utils/remove-notification.ts', () => {
Expand Down Expand Up @@ -39,6 +39,6 @@ describe('utils/remove-notification.ts', () => {
expect(document.getElementById).toHaveBeenCalledWith(
mockSingleAccountNotifications[0].notifications[0].id,
);
expect(mockElement.className).toContain(Constants.READ_CLASS_NAME);
expect(mockElement.className).toContain(READ_NOTIFICATION_CLASS_NAME);
});
});
4 changes: 2 additions & 2 deletions src/utils/remove-notification.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { READ_NOTIFICATION_CLASS_NAME } from '../styles/gitify';
import type { AccountNotifications, SettingsState } from '../types';
import Constants from './constants';

export const removeNotification = (
settings: SettingsState,
Expand All @@ -9,7 +9,7 @@ export const removeNotification = (
): AccountNotifications[] => {
if (settings.delayNotificationState) {
const notificationRow = document.getElementById(id);
notificationRow.className += ` ${Constants.READ_CLASS_NAME}`;
notificationRow.className += ` ${READ_NOTIFICATION_CLASS_NAME}`;
return notifications;
}

Expand Down

0 comments on commit 3e4f234

Please sign in to comment.