Skip to content

Commit a005c13

Browse files
committed
replace clsx with twJoin from tailwind-merge
1 parent f66e84a commit a005c13

File tree

5 files changed

+21
-22
lines changed

5 files changed

+21
-22
lines changed

src/components/Button.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import clsx from 'clsx';
21
import { ReactNode } from 'react';
2+
import { twJoin } from 'tailwind-merge';
33

44
type ButtonType = {
55
type?: 'button' | 'submit' | 'reset' | undefined;
@@ -23,7 +23,7 @@ const Button = ({
2323
type={type}
2424
onClick={onClick}
2525
disabled={disabled}
26-
className={clsx(
26+
className={twJoin(
2727
`rounded-lg px-5 py-2 font-medium text-white transition`,
2828
fullWidth && 'w-full',
2929
buttonType === 'secondary' && 'bg-slate-500 hover:bg-slate-400',

src/components/Container.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import clsx from 'clsx';
21
import { ReactNode } from 'react';
2+
import { twJoin } from 'tailwind-merge';
33

44
const Container = ({
55
children,
@@ -10,7 +10,7 @@ const Container = ({
1010
}) => {
1111
return (
1212
<div
13-
className={clsx(
13+
className={twJoin(
1414
`max-w-[90rem]`,
1515
fullWidth && 'w-full',
1616
!fullWidth && 'w-[96%]',

src/components/NavigationMenu.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import clsx from 'clsx';
21
import { MouseEvent } from 'react';
32
import { Link } from 'react-router-dom';
3+
import { twJoin } from 'tailwind-merge';
44

55
import Button from './Button';
66
import ThemeSwitcher from './ThemeSwitcher';
@@ -73,7 +73,7 @@ const NavigationMenu = ({ openState }: { openState: boolean }) => {
7373
{openState && (
7474
<>
7575
<ul
76-
className={clsx(
76+
className={twJoin(
7777
`mt-1 flex flex-col gap-1 py-6 transition-all duration-500`,
7878
!openState && 'h-0 w-0 scale-y-0',
7979
openState && 'h-full w-full origin-top scale-y-100',

src/components/ProjectCard.tsx

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { faGithub } from '@fortawesome/free-brands-svg-icons';
22
import { faEye } from '@fortawesome/free-solid-svg-icons';
33
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
44
import { useState } from 'react';
5-
import { twJoin } from 'tailwind-merge';
65

76
import { ProjectType } from '../data/Projects';
87
import ImageModal from './ImageModal';
@@ -48,19 +47,19 @@ const ProjectCard = ({ project }: { project: ProjectType }) => {
4847
.map((el, i) => (
4948
<span
5049
key={i}
51-
className={twJoin(
52-
'inline-block rounded',
53-
el == 'react' && 'bg-[hsl(224,96%,80%)]/80',
54-
el == 'nextjs' && 'bg-[hsl(220,6%,18%)]/80 text-white',
55-
el == 'typescript' && 'bg-[hsl(186,96%,80%)]/80',
56-
el == 'redux' && 'bg-[hsl(263,96%,80%)]/80',
57-
el == 'MUI' && 'bg-[hsl(203,96%,80%)]/80',
58-
el == 'prisma' && 'bg-[hsl(225,22%,30%)]/80 text-white',
59-
el == 'postgreSQL' && 'bg-[hsl(350,96%,80%)]/80',
60-
'px-3 py-1 text-[12px] capitalize',
61-
)}
50+
style={{
51+
display: 'inline-block',
52+
borderRadius: '4px',
53+
backgroundColor: `hsl(${Math.floor(
54+
Math.random() * 360,
55+
)},96%,80%)`,
56+
paddingInline: '10px',
57+
paddingBlock: '4px',
58+
fontSize: '12px',
59+
fontWeight: '500',
60+
}}
6261
>
63-
{el}
62+
#{el}
6463
</span>
6564
))}
6665
</div>

src/components/ToggleButton.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { faMoon, faSun } from '@fortawesome/free-solid-svg-icons';
22
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
3-
import clsx from 'clsx';
3+
import { twJoin } from 'tailwind-merge';
44

55
const ToggleButton = ({
66
isDarkMode,
@@ -11,7 +11,7 @@ const ToggleButton = ({
1111
}) => {
1212
return (
1313
<div
14-
className={clsx(
14+
className={twJoin(
1515
'relative flex h-[27px] w-[54px] cursor-pointer items-center justify-between rounded-full border-2 px-1 transition-colors duration-300 ease-linear',
1616
isDarkMode
1717
? 'border-blue-700 bg-blue-300'
@@ -21,7 +21,7 @@ const ToggleButton = ({
2121
>
2222
<FontAwesomeIcon icon={faMoon} className="h-4 w-4 text-dark-900" />
2323
<span
24-
className={clsx(
24+
className={twJoin(
2525
`absolute top-1/2 h-5 w-5 -translate-y-1/2 rounded-full bg-blue-600 shadow-md transition-all duration-300 ease-linear`,
2626
!isDarkMode ? 'left-[3px]' : 'left-[28px]',
2727
)}

0 commit comments

Comments
 (0)