Skip to content

Commit dcef564

Browse files
authored
feat: use clsx to merge classNames (#1231)
1 parent e30e5cf commit dcef564

File tree

14 files changed

+53
-21
lines changed

14 files changed

+53
-21
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@
110110
"@electron/remote": "2.1.2",
111111
"@primer/octicons-react": "19.9.0",
112112
"axios": "1.7.2",
113+
"clsx": "2.1.1",
113114
"date-fns": "3.6.0",
114115
"electron-updater": "6.2.1",
115116
"final-form": "4.20.10",

pnpm-lock.yaml

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/Sidebar.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { useLocation, useNavigate } from 'react-router-dom';
99
import { Logo } from '../components/Logo';
1010
import { AppContext } from '../context/App';
1111
import { BUTTON_SIDEBAR_CLASS_NAME } from '../styles/gitify';
12+
import { cn } from '../utils/cn';
1213
import { quitApp } from '../utils/comms';
1314
import { openGitHubNotifications, openGitifyRepository } from '../utils/links';
1415
import { getNotificationCount } from '../utils/notifications';
@@ -47,9 +48,10 @@ export const Sidebar: FC = () => {
4748

4849
<button
4950
type="button"
50-
className={`flex justify-around self-stretch items-center my-1 py-1 px-2 text-xs font-extrabold cursor-pointer ${
51-
notificationsCount > 0 ? 'text-green-500' : 'text-white'
52-
}`}
51+
className={cn(
52+
'flex justify-around self-stretch items-center my-1 py-1 px-2 text-xs font-extrabold cursor-pointer',
53+
notificationsCount > 0 ? 'text-green-500' : 'text-white',
54+
)}
5355
onClick={() => openGitHubNotifications()}
5456
title={`${notificationsCount} Unread Notifications`}
5557
>

src/components/buttons/PillButton.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type { Icon } from '@primer/octicons-react';
22
import type { FC } from 'react';
33
import type { IconColor } from '../../types';
4+
import { cn } from '../../utils/cn';
45

56
export interface IPillButton {
67
key?: string;
@@ -19,7 +20,7 @@ export const PillButton: FC<IPillButton> = (props: IPillButton) => {
1920
>
2021
<props.icon
2122
size={12}
22-
className={`mr-1 ${props.color}`}
23+
className={cn('mr-1', props.color)}
2324
aria-label={props.title}
2425
/>
2526
{props.metric}

src/components/fields/Button.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import type { Icon } from '@primer/octicons-react';
22
import type { FC } from 'react';
3+
import { cn } from '../../utils/cn';
34
import { openExternalLink } from '../../utils/comms';
45

56
export interface IButton {
67
name: string;
78
label: string;
8-
class?: string;
9+
className?: string;
910
icon?: Icon;
1011
size?: number;
1112
url?: string;
@@ -22,7 +23,7 @@ export const Button: FC<IButton> = (props: IButton) => {
2223
type={props.type ?? 'button'}
2324
title={props.label}
2425
aria-label={props.label}
25-
className={`${props.class} ${baseClass}`}
26+
className={cn(props.className, baseClass)}
2627
disabled={props.disabled}
2728
onClick={() => {
2829
if (props.url) {

src/components/fields/__snapshots__/Button.test.tsx.snap

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/routes/Login.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,14 @@ export const LoginRoute: FC = () => {
5252
name="Personal Access Token"
5353
icon={KeyIcon}
5454
label="Login with Personal Access Token"
55-
class="py-2 mt-2"
55+
className="py-2 mt-2"
5656
onClick={() => navigate('/login-personal-access-token')}
5757
/>
5858
<Button
5959
name="OAuth App"
6060
icon={PersonIcon}
6161
label="Login with OAuth App"
62-
class="py-2 mt-2"
62+
className="py-2 mt-2"
6363
onClick={() => navigate('/login-oauth-app')}
6464
/>
6565
</div>

src/routes/LoginWithOAuthApp.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ export const LoginWithOAuthApp: FC = () => {
9696
<Button
9797
name="Docs"
9898
label="GitHub Docs"
99-
class="mt-2"
99+
className="mt-2"
100100
icon={BookIcon}
101101
size={12}
102102
url={Constants.GITHUB_DOCS.OAUTH_URL}
@@ -105,7 +105,7 @@ export const LoginWithOAuthApp: FC = () => {
105105
<Button
106106
name="Login"
107107
label="Login"
108-
class="px-4 py-2 mt-2 !text-sm"
108+
className="px-4 py-2 mt-2 !text-sm"
109109
icon={SignInIcon}
110110
size={16}
111111
disabled={submitting || pristine}

src/routes/LoginWithPersonalAccessToken.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,15 +101,15 @@ export const LoginWithPersonalAccessToken: FC = () => {
101101
<Button
102102
name="Docs"
103103
label="GitHub Docs"
104-
class="mt-2"
104+
className="mt-2"
105105
icon={BookIcon}
106106
size={12}
107107
url={Constants.GITHUB_DOCS.PAT_URL}
108108
/>
109109
<Button
110110
name="Login"
111111
label="Login"
112-
class="px-4 py-2 mt-2 !text-sm"
112+
className="px-4 py-2 mt-2 !text-sm"
113113
icon={SignInIcon}
114114
size={16}
115115
disabled={submitting || pristine}

src/routes/__snapshots__/LoginWithOAuthApp.test.tsx.snap

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)