Skip to content

Commit bd86d8a

Browse files
committed
replace all twJoin function with custom 'cn' lib function
1 parent 3b2eb9d commit bd86d8a

13 files changed

+35
-20
lines changed

src/components/Button.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { ReactNode } from 'react';
2-
import { twJoin } from 'tailwind-merge';
2+
3+
import { cn } from '#/lib/cn';
34

45
type ButtonType = {
56
type?: 'button' | 'submit' | 'reset' | undefined;
@@ -23,7 +24,7 @@ const Button = ({
2324
type={type}
2425
onClick={onClick}
2526
disabled={disabled}
26-
className={twJoin(
27+
className={cn(
2728
`transition-color flex items-center justify-center gap-4 rounded-lg px-5 py-2 font-medium duration-300 disabled:bg-dark-500 disabled:text-white-full`,
2829
fullWidth && 'w-full',
2930
buttonType === 'secondary' &&

src/components/ContactForm.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@ import { faPaperPlane } from '@fortawesome/free-solid-svg-icons';
33
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
44
import { ChangeEvent, FormEvent, useRef, useState } from 'react';
55
import { useDispatch, useSelector } from 'react-redux';
6-
import { twJoin } from 'tailwind-merge';
76
import validator from 'validator';
87

8+
import { cn } from '#/lib/cn';
99
import { setFormData, setFormStatus } from '#store/reducer/FormSlice';
1010
import { AppDispatch, RootState } from '#store/store';
11+
1112
import Button from './Button';
1213
import Spinner from './Spinner';
1314

@@ -92,7 +93,7 @@ const ContactForm = () => {
9293
/>
9394
<label
9495
htmlFor="name"
95-
className={twJoin(inputs.name.length > 0 && 'active')}
96+
className={cn(inputs.name.length > 0 && 'active')}
9697
>
9798
Enter your Name
9899
</label>
@@ -108,7 +109,7 @@ const ContactForm = () => {
108109
/>
109110
<label
110111
htmlFor="email"
111-
className={twJoin(inputs.email.length > 0 && 'active')}
112+
className={cn(inputs.email.length > 0 && 'active')}
112113
>
113114
Enter Your Email
114115
</label>
@@ -132,7 +133,7 @@ const ContactForm = () => {
132133
/>
133134
<label
134135
htmlFor="message"
135-
className={twJoin(inputs.message.length > 0 && 'active')}
136+
className={cn(inputs.message.length > 0 && 'active')}
136137
>
137138
Message
138139
</label>

src/components/Container.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { ReactNode } from 'react';
2-
import { twJoin } from 'tailwind-merge';
2+
3+
import { cn } from '#/lib/cn';
34

45
const Container = ({
56
children,
@@ -10,7 +11,7 @@ const Container = ({
1011
}) => {
1112
return (
1213
<div
13-
className={twJoin(
14+
className={cn(
1415
`max-w-[90rem]`,
1516
fullWidth && 'w-full',
1617
!fullWidth && 'w-[96%]',

src/components/Logo.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Link } from 'react-router-dom';
2-
import { twJoin } from 'tailwind-merge';
2+
3+
import { cn } from '#/lib/cn';
34

45
const Logo = ({
56
large,
@@ -13,7 +14,7 @@ const Logo = ({
1314
<svg
1415
viewBox="0 0 233.462 44.648"
1516
xmlns="http://www.w3.org/2000/svg"
16-
className={twJoin(
17+
className={cn(
1718
large ? 'w-48' : 'w-32',
1819
variant === 'dark' ? 'text-white' : 'text-dark dark:text-white',
1920
)}

src/components/NavigationMenu.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { MouseEvent } from 'react';
2-
import { twJoin } from 'tailwind-merge';
2+
3+
import { cn } from '#/lib/cn';
34

45
import CVDownloadButton from './CVDownloadButton';
56
import ThemeSwitcher from './ThemeSwitcher';
@@ -61,13 +62,13 @@ const NavigationMenu = ({ openState }: { openState: boolean }) => {
6162
</nav>
6263
{/* Mobile Navbar */}
6364
<nav
64-
className={twJoin(
65+
className={cn(
6566
'mt-3 grid w-full overflow-hidden rounded-md bg-white-full px-3 transition-[grid-template-rows] duration-300 ease-linear md:hidden dark:bg-dark-700',
6667
!openState ? 'grid-rows-[0fr]' : 'grid-rows-[1fr]',
6768
)}
6869
>
6970
<div
70-
className={twJoin(
71+
className={cn(
7172
'min-h-0 transition-[visibility] duration-300',
7273
!openState ? 'invisible' : 'visible',
7374
)}

src/components/ProjectCard.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
44
import { useState } from 'react';
55

66
import { ProjectType } from '#data/Projects';
7+
78
import ImageModal from './ImageModal';
89

910
const ProjectCard = ({ project }: { project: ProjectType }) => {

src/components/RecentWork.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import Projects from '#data/Projects';
2+
23
import ProjectCard from './ProjectCard';
34

45
const featuredProject = Projects.filter(project => project.featured);

src/components/SocialLinks.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
2-
import { twJoin } from 'tailwind-merge';
32

3+
import { cn } from '#/lib/cn';
44
import { SocialLink, socialLinks } from '#data/Social';
55

66
const SocialLinks = ({ inverted }: { inverted?: boolean }) => {
@@ -10,7 +10,7 @@ const SocialLinks = ({ inverted }: { inverted?: boolean }) => {
1010
<a href={link.url} key={link.id} target="_blank">
1111
<FontAwesomeIcon
1212
icon={link.icon}
13-
className={twJoin(
13+
className={cn(
1414
'h-8 w-8',
1515
inverted ? 'text-white-full' : 'text-dark',
1616
'shadow-sm transition-transform duration-300 ease-linear hover:-translate-y-1 hover:text-primary dark:text-white dark:hover:text-primary-400',

src/components/Spinner.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import { twJoin } from 'tailwind-merge';
1+
import { cn } from '#/lib/cn';
22

33
const Spinner = ({ size }: { size: number }) => {
44
return (
55
<div
6-
className={twJoin(
6+
className={cn(
77
'relative',
88
`w-${size} h-${size}`,
99
'animate-spin rounded-full border-4 border-secondary-400 border-t-white-full',

src/components/ThemeSwitcher.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { useDispatch, useSelector } from 'react-redux';
33

44
import { toggleTheme } from '#store/reducer/ThemeReducer';
55
import { RootState } from '#store/store';
6+
67
import ToggleButton from './ToggleButton';
78

89
const ThemeSwitcher = ({ className }: { className?: string }) => {

0 commit comments

Comments
 (0)