Skip to content

Commit

Permalink
test shadcn button
Browse files Browse the repository at this point in the history
  • Loading branch information
dEdmishka committed Jan 21, 2024
1 parent c893331 commit a6203b2
Show file tree
Hide file tree
Showing 4 changed files with 100 additions and 5 deletions.
44 changes: 40 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"cspell": "cspell --show-suggestions --show-context --gitignore ."
},
"dependencies": {
"@radix-ui/react-slot": "^1.0.2",
"class-variance-authority": "^0.7.0",
"clsx": "^2.1.0",
"lucide-react": "^0.312.0",
Expand Down
5 changes: 4 additions & 1 deletion src/components/Pages/Auth/FormAuth.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
'use client'

import { Button } from '@/ui/button'
import Form from '@/ui/form/Form'
import FormCheckbox from '@/ui/form/FormCheckbox'
import FormControl from '@/ui/form/FormControl'
import FormInput from '@/ui/form/FormInput'
import FormLabel from '@/ui/form/FormLabel'
import Button from '@/ui/index/Button'
import { FC, FormEvent } from 'react'

const AuthForm: FC = () => {
Expand All @@ -28,6 +28,9 @@ const AuthForm: FC = () => {
<Button className="mt-3 w-full" type="submit">
Next
</Button>
{/* <Button className="mt-3 w-full" type="submit">
Next
</Button> */}
</Form>
)
}
Expand Down
55 changes: 55 additions & 0 deletions src/components/UI/button.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import { cn } from '@/lib/utils'
import { Slot } from '@radix-ui/react-slot'
import { type VariantProps, cva } from 'class-variance-authority'
import * as React from 'react'

const buttonVariants = cva(
'inline-block text-center text-base-white rounded-2xl bg-gradient-purple-blue',
{
defaultVariants: {
size: 'default',
variant: 'default',
},
variants: {
size: {
default: 'py-3.5 px-5',
icon: 'h-10 w-10',
lg: 'h-11 rounded-md px-8',
sm: 'h-9 rounded-md px-3',
},
variant: {
default: 'bg-gradient-purple-blue',
destructive:
'bg-destructive text-destructive-foreground hover:bg-destructive/90',
ghost: 'hover:bg-accent hover:text-accent-foreground',
link: 'text-primary underline-offset-4 hover:underline',
outline:
'border border-input bg-background hover:bg-accent hover:text-accent-foreground',
secondary:
'bg-secondary text-secondary-foreground hover:bg-secondary/80',
},
},
}
)

export interface ButtonProps
extends React.ButtonHTMLAttributes<HTMLButtonElement>,
VariantProps<typeof buttonVariants> {
asChild?: boolean
}

const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
({ asChild = false, className, size, variant, ...props }, ref) => {
const Comp = asChild ? Slot : 'button'
return (
<Comp
className={cn(buttonVariants({ className, size, variant }))}
ref={ref}
{...props}
/>
)
}
)
Button.displayName = 'Button'

export { Button, buttonVariants }

0 comments on commit a6203b2

Please sign in to comment.