core/components/Button.tsx
SKINMAKER 606f3cbc82
deps: update next.js to 13 (#627)
* deps: update next.js to 13

* chore: migrate to new Link component

* chore: remove future option from next.config

* chore: update react-select

* chore: enable hideSourceMaps on sentry

* chore: assert type as string

* chore: make placeholder and value absolute

* feat: set timeout for redirect

* chore: ignore ts error

* chore: add generics

* chore:

* chore: add ts comment

* feat: use dnd-kit instead of react-sortable-hoc

* fix: give absolute position to placeholder
2023-09-28 23:22:46 +09:00

48 lines
1.4 KiB
TypeScript

import Link from 'next/link'
import { ReactNode } from 'react'
const Button: React.FC<ButtonProps> = ({
type = 'button',
className,
children,
href,
disabled=false,
onClick,
}) => {
return href ? <Link
href={!disabled && href}
className={`cursor-pointer rounded-md px-4 py-2 transition duration-300 ease select-none outline-none foucs:outline-none mr-1.5 ${className ??
'bg-discord-blurple hover:opacity-80 dark:bg-very-black dark:hover:bg-discord-dark-hover text-white'}`}>
{children}
</Link>
: onClick ? <button
type={disabled ? 'button' : type}
onClick={disabled ? null : onClick}
className={`cursor-pointer rounded-md px-4 py-2 transition duration-300 ease select-none outline-none foucs:outline-none mr-1.5 ${className ??
'bg-discord-blurple hover:opacity-80 dark:bg-very-black dark:hover:bg-discord-dark-hover text-white'}`}
>
{children}
</button>
:
<button
type={disabled ? 'button' : type}
className={`cursor-pointer rounded-md px-4 py-2 transition duration-300 ease select-none outline-none foucs:outline-none mr-1.5 ${className ??
'bg-discord-blurple hover:opacity-80 dark:bg-very-black dark:hover:bg-discord-dark-hover text-white'}`}
>
{children}
</button>
}
interface ButtonProps {
type?: 'button' | 'submit' | 'reset'
className?: string
children: ReactNode
href?: string
disabled?: boolean
onClick?: () => void
}
export default Button