Skip to content

Commit

Permalink
fix: merge two button components into one
Browse files Browse the repository at this point in the history
  • Loading branch information
satnaing committed Dec 14, 2024
1 parent ca66e8e commit e053f08
Show file tree
Hide file tree
Showing 30 changed files with 46 additions and 152 deletions.
99 changes: 0 additions & 99 deletions src/components/button.tsx

This file was deleted.

4 changes: 2 additions & 2 deletions src/components/layout/top-nav.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { Link } from '@tanstack/react-router'
import { IconMenu } from '@tabler/icons-react'
import { cn } from '@/lib/utils'
import { Button } from '@/components/ui/button'
import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuTrigger,
} from '@/components/ui/dropdown-menu'
import { Button } from '@/components/button'

interface TopNavProps extends React.HTMLAttributes<HTMLElement> {
links: {
Expand All @@ -22,7 +22,7 @@ export function TopNav({ className, links, ...props }: TopNavProps) {
return (
<>
<div className='md:hidden'>
<DropdownMenu>
<DropdownMenu modal={false}>
<DropdownMenuTrigger asChild>
<Button size='icon' variant='outline'>
<IconMenu />
Expand Down
2 changes: 1 addition & 1 deletion src/components/password-input.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as React from 'react'
import { IconEye, IconEyeOff } from '@tabler/icons-react'
import { cn } from '@/lib/utils'
import { Button } from './button'
import { Button } from './ui/button'

type PasswordInputProps = Omit<
React.InputHTMLAttributes<HTMLInputElement>,
Expand Down
4 changes: 2 additions & 2 deletions src/components/profile-dropdown.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar'
import { Button } from '@/components/ui/button'
import {
DropdownMenu,
DropdownMenuContent,
Expand All @@ -9,11 +10,10 @@ import {
DropdownMenuShortcut,
DropdownMenuTrigger,
} from '@/components/ui/dropdown-menu'
import { Button } from '@/components/button'

export function ProfileDropdown() {
return (
<DropdownMenu>
<DropdownMenu modal={false}>
<DropdownMenuTrigger asChild>
<Button variant='ghost' className='relative h-8 w-8 rounded-full'>
<Avatar className='h-8 w-8'>
Expand Down
4 changes: 2 additions & 2 deletions src/components/theme-switch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import { useEffect } from 'react'
import { IconCheck, IconMoon, IconSun } from '@tabler/icons-react'
import { cn } from '@/lib/utils'
import { useTheme } from '@/context/theme-context'
import { Button } from '@/components/ui/button'
import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuTrigger,
} from '@/components/ui/dropdown-menu'
import { Button } from '@/components/button'

export function ThemeSwitch() {
const { theme, setTheme } = useTheme()
Expand All @@ -22,7 +22,7 @@ export function ThemeSwitch() {
}, [theme])

return (
<DropdownMenu>
<DropdownMenu modal={false}>
<DropdownMenuTrigger asChild>
<Button variant='ghost' size='icon' className='scale-95 rounded-full'>
<IconSun className='size-[1.2rem] rotate-0 scale-100 transition-all dark:-rotate-90 dark:scale-0' />
Expand Down
2 changes: 1 addition & 1 deletion src/features/apps/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
IconSortAscendingLetters,
IconSortDescendingLetters,
} from '@tabler/icons-react'
import { Button } from '@/components/ui/button'
import { Input } from '@/components/ui/input'
import {
Select,
Expand All @@ -13,7 +14,6 @@ import {
SelectValue,
} from '@/components/ui/select'
import { Separator } from '@/components/ui/separator'
import { Button } from '@/components/button'
import { Header } from '@/components/layout/header'
import { Main } from '@/components/layout/main'
import { ProfileDropdown } from '@/components/profile-dropdown'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { z } from 'zod'
import { useForm } from 'react-hook-form'
import { zodResolver } from '@hookform/resolvers/zod'
import { cn } from '@/lib/utils'
import { Button } from '@/components/ui/button'
import {
Form,
FormControl,
Expand All @@ -12,7 +13,6 @@ import {
FormMessage,
} from '@/components/ui/form'
import { Input } from '@/components/ui/input'
import { Button } from '@/components/button'

type ForgotFormProps = HTMLAttributes<HTMLDivElement>

Expand Down Expand Up @@ -59,7 +59,7 @@ export function ForgotForm({ className, ...props }: ForgotFormProps) {
</FormItem>
)}
/>
<Button className='mt-2' loading={isLoading}>
<Button className='mt-2' disabled={isLoading}>
Continue
</Button>
</div>
Expand Down
4 changes: 2 additions & 2 deletions src/features/auth/otp/components/otp-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { zodResolver } from '@hookform/resolvers/zod'
import { useNavigate } from '@tanstack/react-router'
import { cn } from '@/lib/utils'
import { toast } from '@/hooks/use-toast'
import { Button } from '@/components/ui/button'
import {
Form,
FormControl,
Expand All @@ -14,7 +15,6 @@ import {
} from '@/components/ui/form'
import { Input } from '@/components/ui/input'
import { Separator } from '@/components/ui/separator'
import { Button } from '@/components/button'
import { PinInput, PinInputField } from '@/components/pin-input'

type OtpFormProps = HTMLAttributes<HTMLDivElement>
Expand Down Expand Up @@ -84,7 +84,7 @@ export function OtpForm({ className, ...props }: OtpFormProps) {
</FormItem>
)}
/>
<Button className='mt-2' disabled={disabledBtn} loading={isLoading}>
<Button className='mt-2' disabled={disabledBtn || isLoading}>
Verify
</Button>
</div>
Expand Down
14 changes: 6 additions & 8 deletions src/features/auth/sign-in/components/user-auth-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { zodResolver } from '@hookform/resolvers/zod'
import { Link } from '@tanstack/react-router'
import { IconBrandFacebook, IconBrandGithub } from '@tabler/icons-react'
import { cn } from '@/lib/utils'
import { Button } from '@/components/ui/button'
import {
Form,
FormControl,
Expand All @@ -14,7 +15,6 @@ import {
FormMessage,
} from '@/components/ui/form'
import { Input } from '@/components/ui/input'
import { Button } from '@/components/button'
import { PasswordInput } from '@/components/password-input'

type UserAuthFormProps = HTMLAttributes<HTMLDivElement>
Expand Down Expand Up @@ -94,7 +94,7 @@ export function UserAuthForm({ className, ...props }: UserAuthFormProps) {
</FormItem>
)}
/>
<Button className='mt-2' loading={isLoading}>
<Button className='mt-2' disabled={isLoading}>
Login
</Button>

Expand All @@ -114,19 +114,17 @@ export function UserAuthForm({ className, ...props }: UserAuthFormProps) {
variant='outline'
className='w-full'
type='button'
loading={isLoading}
leftSection={<IconBrandGithub className='h-4 w-4' />}
disabled={isLoading}
>
GitHub
<IconBrandGithub className='h-4 w-4' /> GitHub
</Button>
<Button
variant='outline'
className='w-full'
type='button'
loading={isLoading}
leftSection={<IconBrandFacebook className='h-4 w-4' />}
disabled={isLoading}
>
Facebook
<IconBrandFacebook className='h-4 w-4' /> Facebook
</Button>
</div>
</div>
Expand Down
14 changes: 6 additions & 8 deletions src/features/auth/sign-up/components/sign-up-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { useForm } from 'react-hook-form'
import { zodResolver } from '@hookform/resolvers/zod'
import { IconBrandFacebook, IconBrandGithub } from '@tabler/icons-react'
import { cn } from '@/lib/utils'
import { Button } from '@/components/ui/button'
import {
Form,
FormControl,
Expand All @@ -13,7 +14,6 @@ import {
FormMessage,
} from '@/components/ui/form'
import { Input } from '@/components/ui/input'
import { Button } from '@/components/button'
import { PasswordInput } from '@/components/password-input'

type SignUpFormProps = HTMLAttributes<HTMLDivElement>
Expand Down Expand Up @@ -105,7 +105,7 @@ export function SignUpForm({ className, ...props }: SignUpFormProps) {
</FormItem>
)}
/>
<Button className='mt-2' loading={isLoading}>
<Button className='mt-2' disabled={isLoading}>
Create Account
</Button>

Expand All @@ -125,19 +125,17 @@ export function SignUpForm({ className, ...props }: SignUpFormProps) {
variant='outline'
className='w-full'
type='button'
loading={isLoading}
leftSection={<IconBrandGithub className='h-4 w-4' />}
disabled={isLoading}
>
GitHub
<IconBrandGithub className='h-4 w-4' /> GitHub
</Button>
<Button
variant='outline'
className='w-full'
type='button'
loading={isLoading}
leftSection={<IconBrandFacebook className='h-4 w-4' />}
disabled={isLoading}
>
Facebook
<IconBrandFacebook className='h-4 w-4' /> Facebook
</Button>
</div>
</div>
Expand Down
9 changes: 3 additions & 6 deletions src/features/chats/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ import {
} from '@tabler/icons-react'
import { cn } from '@/lib/utils'
import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar'
import { Button } from '@/components/ui/button'
import { ScrollArea } from '@/components/ui/scroll-area'
import { Separator } from '@/components/ui/separator'
import { Button } from '@/components/button'
import { Header } from '@/components/layout/header'
import { Main } from '@/components/layout/main'
import { ProfileDropdown } from '@/components/profile-dropdown'
Expand Down Expand Up @@ -291,11 +291,8 @@ export default function Chats() {
<IconSend size={20} />
</Button>
</div>
<Button
className='h-full sm:hidden'
rightSection={<IconSend size={18} />}
>
Send
<Button className='h-full sm:hidden'>
<IconSend size={18} /> Send
</Button>
</form>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/features/dashboard/index.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Button } from '@/components/ui/button'
import {
Card,
CardContent,
Expand All @@ -6,7 +7,6 @@ import {
CardTitle,
} from '@/components/ui/card'
import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs'
import { Button } from '@/components/button'
import { Header } from '@/components/layout/header'
import { Main } from '@/components/layout/main'
import { TopNav } from '@/components/layout/top-nav'
Expand Down
2 changes: 1 addition & 1 deletion src/features/errors/forbidden.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useNavigate, useRouter } from '@tanstack/react-router'
import { Button } from '@/components/button'
import { Button } from '@/components/ui/button'

export default function ForbiddenError() {
const navigate = useNavigate()
Expand Down
2 changes: 1 addition & 1 deletion src/features/errors/general-error.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useNavigate, useRouter } from '@tanstack/react-router'
import { cn } from '@/lib/utils'
import { Button } from '@/components/button'
import { Button } from '@/components/ui/button'

interface GeneralErrorProps extends React.HTMLAttributes<HTMLDivElement> {
minimal?: boolean
Expand Down
2 changes: 1 addition & 1 deletion src/features/errors/maintenance-error.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Button } from '@/components/button'
import { Button } from '@/components/ui/button'

export default function MaintenanceError() {
return (
Expand Down
Loading

0 comments on commit e053f08

Please sign in to comment.