accords-library.com/src/components/Button.tsx

40 lines
1.1 KiB
TypeScript
Raw Normal View History

2022-01-31 12:16:30 +00:00
import Link from "next/link";
import { MouseEventHandler } from "react";
2022-01-31 12:16:30 +00:00
type ButtonProps = {
id?: string;
className?: string;
2022-01-31 12:16:30 +00:00
href?: string;
children: React.ReactChild | React.ReactChild[];
active?: boolean;
locale?: string;
onClick?: MouseEventHandler<HTMLDivElement>;
};
export default function Button(props: ButtonProps): JSX.Element {
2022-01-31 12:16:30 +00:00
const button = (
<div
id={props.id}
onClick={props.onClick}
className={`grid place-content-center place-items-center border-[1px] border-dark text-dark rounded-full px-4 pt-[0.4rem] pb-[0.5rem] transition-all ${
props.className
} ${
props.active
? "text-light bg-black drop-shadow-black-lg !border-black cursor-not-allowed"
: "cursor-pointer hover:text-light hover:bg-dark hover:drop-shadow-shade-lg active:bg-black active:drop-shadow-black-lg active:border-black"
}`}
>
{props.children}
</div>
);
2022-01-31 12:16:30 +00:00
const result = props.href ? (
<Link href={props.href} locale={props.locale} passHref>
2022-01-31 12:16:30 +00:00
{button}
</Link>
) : (
button
);
return result;
}