Skip to content

Commit be22e75

Browse files
authored
fix: merge two button components into one (#60)
1 parent ca66e8e commit be22e75

30 files changed

+46
-152
lines changed

src/components/button.tsx

Lines changed: 0 additions & 99 deletions
This file was deleted.

src/components/layout/top-nav.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import { Link } from '@tanstack/react-router'
22
import { IconMenu } from '@tabler/icons-react'
33
import { cn } from '@/lib/utils'
4+
import { Button } from '@/components/ui/button'
45
import {
56
DropdownMenu,
67
DropdownMenuContent,
78
DropdownMenuItem,
89
DropdownMenuTrigger,
910
} from '@/components/ui/dropdown-menu'
10-
import { Button } from '@/components/button'
1111

1212
interface TopNavProps extends React.HTMLAttributes<HTMLElement> {
1313
links: {
@@ -22,7 +22,7 @@ export function TopNav({ className, links, ...props }: TopNavProps) {
2222
return (
2323
<>
2424
<div className='md:hidden'>
25-
<DropdownMenu>
25+
<DropdownMenu modal={false}>
2626
<DropdownMenuTrigger asChild>
2727
<Button size='icon' variant='outline'>
2828
<IconMenu />

src/components/password-input.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as React from 'react'
22
import { IconEye, IconEyeOff } from '@tabler/icons-react'
33
import { cn } from '@/lib/utils'
4-
import { Button } from './button'
4+
import { Button } from './ui/button'
55

66
type PasswordInputProps = Omit<
77
React.InputHTMLAttributes<HTMLInputElement>,

src/components/profile-dropdown.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar'
2+
import { Button } from '@/components/ui/button'
23
import {
34
DropdownMenu,
45
DropdownMenuContent,
@@ -9,11 +10,10 @@ import {
910
DropdownMenuShortcut,
1011
DropdownMenuTrigger,
1112
} from '@/components/ui/dropdown-menu'
12-
import { Button } from '@/components/button'
1313

1414
export function ProfileDropdown() {
1515
return (
16-
<DropdownMenu>
16+
<DropdownMenu modal={false}>
1717
<DropdownMenuTrigger asChild>
1818
<Button variant='ghost' className='relative h-8 w-8 rounded-full'>
1919
<Avatar className='h-8 w-8'>

src/components/theme-switch.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ import { useEffect } from 'react'
22
import { IconCheck, IconMoon, IconSun } from '@tabler/icons-react'
33
import { cn } from '@/lib/utils'
44
import { useTheme } from '@/context/theme-context'
5+
import { Button } from '@/components/ui/button'
56
import {
67
DropdownMenu,
78
DropdownMenuContent,
89
DropdownMenuItem,
910
DropdownMenuTrigger,
1011
} from '@/components/ui/dropdown-menu'
11-
import { Button } from '@/components/button'
1212

1313
export function ThemeSwitch() {
1414
const { theme, setTheme } = useTheme()
@@ -22,7 +22,7 @@ export function ThemeSwitch() {
2222
}, [theme])
2323

2424
return (
25-
<DropdownMenu>
25+
<DropdownMenu modal={false}>
2626
<DropdownMenuTrigger asChild>
2727
<Button variant='ghost' size='icon' className='scale-95 rounded-full'>
2828
<IconSun className='size-[1.2rem] rotate-0 scale-100 transition-all dark:-rotate-90 dark:scale-0' />

src/features/apps/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
IconSortAscendingLetters,
55
IconSortDescendingLetters,
66
} from '@tabler/icons-react'
7+
import { Button } from '@/components/ui/button'
78
import { Input } from '@/components/ui/input'
89
import {
910
Select,
@@ -13,7 +14,6 @@ import {
1314
SelectValue,
1415
} from '@/components/ui/select'
1516
import { Separator } from '@/components/ui/separator'
16-
import { Button } from '@/components/button'
1717
import { Header } from '@/components/layout/header'
1818
import { Main } from '@/components/layout/main'
1919
import { ProfileDropdown } from '@/components/profile-dropdown'

src/features/auth/forgot-password/components/forgot-password-form.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { z } from 'zod'
33
import { useForm } from 'react-hook-form'
44
import { zodResolver } from '@hookform/resolvers/zod'
55
import { cn } from '@/lib/utils'
6+
import { Button } from '@/components/ui/button'
67
import {
78
Form,
89
FormControl,
@@ -12,7 +13,6 @@ import {
1213
FormMessage,
1314
} from '@/components/ui/form'
1415
import { Input } from '@/components/ui/input'
15-
import { Button } from '@/components/button'
1616

1717
type ForgotFormProps = HTMLAttributes<HTMLDivElement>
1818

@@ -59,7 +59,7 @@ export function ForgotForm({ className, ...props }: ForgotFormProps) {
5959
</FormItem>
6060
)}
6161
/>
62-
<Button className='mt-2' loading={isLoading}>
62+
<Button className='mt-2' disabled={isLoading}>
6363
Continue
6464
</Button>
6565
</div>

src/features/auth/otp/components/otp-form.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { zodResolver } from '@hookform/resolvers/zod'
55
import { useNavigate } from '@tanstack/react-router'
66
import { cn } from '@/lib/utils'
77
import { toast } from '@/hooks/use-toast'
8+
import { Button } from '@/components/ui/button'
89
import {
910
Form,
1011
FormControl,
@@ -14,7 +15,6 @@ import {
1415
} from '@/components/ui/form'
1516
import { Input } from '@/components/ui/input'
1617
import { Separator } from '@/components/ui/separator'
17-
import { Button } from '@/components/button'
1818
import { PinInput, PinInputField } from '@/components/pin-input'
1919

2020
type OtpFormProps = HTMLAttributes<HTMLDivElement>
@@ -84,7 +84,7 @@ export function OtpForm({ className, ...props }: OtpFormProps) {
8484
</FormItem>
8585
)}
8686
/>
87-
<Button className='mt-2' disabled={disabledBtn} loading={isLoading}>
87+
<Button className='mt-2' disabled={disabledBtn || isLoading}>
8888
Verify
8989
</Button>
9090
</div>

src/features/auth/sign-in/components/user-auth-form.tsx

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { zodResolver } from '@hookform/resolvers/zod'
55
import { Link } from '@tanstack/react-router'
66
import { IconBrandFacebook, IconBrandGithub } from '@tabler/icons-react'
77
import { cn } from '@/lib/utils'
8+
import { Button } from '@/components/ui/button'
89
import {
910
Form,
1011
FormControl,
@@ -14,7 +15,6 @@ import {
1415
FormMessage,
1516
} from '@/components/ui/form'
1617
import { Input } from '@/components/ui/input'
17-
import { Button } from '@/components/button'
1818
import { PasswordInput } from '@/components/password-input'
1919

2020
type UserAuthFormProps = HTMLAttributes<HTMLDivElement>
@@ -94,7 +94,7 @@ export function UserAuthForm({ className, ...props }: UserAuthFormProps) {
9494
</FormItem>
9595
)}
9696
/>
97-
<Button className='mt-2' loading={isLoading}>
97+
<Button className='mt-2' disabled={isLoading}>
9898
Login
9999
</Button>
100100

@@ -114,19 +114,17 @@ export function UserAuthForm({ className, ...props }: UserAuthFormProps) {
114114
variant='outline'
115115
className='w-full'
116116
type='button'
117-
loading={isLoading}
118-
leftSection={<IconBrandGithub className='h-4 w-4' />}
117+
disabled={isLoading}
119118
>
120-
GitHub
119+
<IconBrandGithub className='h-4 w-4' /> GitHub
121120
</Button>
122121
<Button
123122
variant='outline'
124123
className='w-full'
125124
type='button'
126-
loading={isLoading}
127-
leftSection={<IconBrandFacebook className='h-4 w-4' />}
125+
disabled={isLoading}
128126
>
129-
Facebook
127+
<IconBrandFacebook className='h-4 w-4' /> Facebook
130128
</Button>
131129
</div>
132130
</div>

src/features/auth/sign-up/components/sign-up-form.tsx

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { useForm } from 'react-hook-form'
44
import { zodResolver } from '@hookform/resolvers/zod'
55
import { IconBrandFacebook, IconBrandGithub } from '@tabler/icons-react'
66
import { cn } from '@/lib/utils'
7+
import { Button } from '@/components/ui/button'
78
import {
89
Form,
910
FormControl,
@@ -13,7 +14,6 @@ import {
1314
FormMessage,
1415
} from '@/components/ui/form'
1516
import { Input } from '@/components/ui/input'
16-
import { Button } from '@/components/button'
1717
import { PasswordInput } from '@/components/password-input'
1818

1919
type SignUpFormProps = HTMLAttributes<HTMLDivElement>
@@ -105,7 +105,7 @@ export function SignUpForm({ className, ...props }: SignUpFormProps) {
105105
</FormItem>
106106
)}
107107
/>
108-
<Button className='mt-2' loading={isLoading}>
108+
<Button className='mt-2' disabled={isLoading}>
109109
Create Account
110110
</Button>
111111

@@ -125,19 +125,17 @@ export function SignUpForm({ className, ...props }: SignUpFormProps) {
125125
variant='outline'
126126
className='w-full'
127127
type='button'
128-
loading={isLoading}
129-
leftSection={<IconBrandGithub className='h-4 w-4' />}
128+
disabled={isLoading}
130129
>
131-
GitHub
130+
<IconBrandGithub className='h-4 w-4' /> GitHub
132131
</Button>
133132
<Button
134133
variant='outline'
135134
className='w-full'
136135
type='button'
137-
loading={isLoading}
138-
leftSection={<IconBrandFacebook className='h-4 w-4' />}
136+
disabled={isLoading}
139137
>
140-
Facebook
138+
<IconBrandFacebook className='h-4 w-4' /> Facebook
141139
</Button>
142140
</div>
143141
</div>

0 commit comments

Comments
 (0)