- Updated all solutions to solve a huge bug where after reviewing, it would reset the score
45 lines
2.0 KiB
TypeScript
45 lines
2.0 KiB
TypeScript
import clsx from "clsx";
|
|
import {ReactNode} from "react";
|
|
|
|
interface Props {
|
|
children: ReactNode;
|
|
color?: "rose" | "purple" | "red";
|
|
variant?: "outline" | "solid";
|
|
className?: string;
|
|
disabled?: boolean;
|
|
onClick?: () => void;
|
|
}
|
|
|
|
export default function Button({color = "purple", variant = "solid", disabled = false, className, children, onClick}: Props) {
|
|
const colorClassNames: {[key in typeof color]: {[key in typeof variant]: string}} = {
|
|
purple: {
|
|
solid: "bg-mti-purple-light text-white border border-mti-purple-light hover:bg-mti-purple disabled:text-mti-purple disabled:bg-mti-purple-ultralight selection:bg-mti-purple-dark",
|
|
outline:
|
|
"bg-transparent text-mti-purple-light border border-mti-purple-light hover:bg-mti-purple-light disabled:text-mti-purple disabled:bg-mti-purple-ultralight disabled:border-none selection:bg-mti-purple-dark hover:text-white selection:text-white",
|
|
},
|
|
red: {
|
|
solid: "bg-mti-red-light text-white border border-mti-red-light hover:bg-mti-red disabled:text-mti-red disabled:bg-mti-red-ultralight selection:bg-mti-red-dark",
|
|
outline:
|
|
"bg-transparent text-mti-red-light border border-mti-red-light hover:bg-mti-red-light disabled:text-mti-red disabled:bg-mti-red-ultralight disabled:border-none selection:bg-mti-red-dark hover:text-white selection:text-white",
|
|
},
|
|
rose: {
|
|
solid: "bg-mti-rose-light text-white border border-mti-rose-light hover:bg-mti-rose disabled:text-mti-rose disabled:bg-mti-rose-ultralight selection:bg-mti-rose-dark",
|
|
outline:
|
|
"bg-transparent text-mti-rose-light border border-mti-rose-light hover:bg-mti-rose-light disabled:text-mti-rose disabled:bg-mti-rose-ultralight disabled:border-none selection:bg-mti-rose-dark hover:text-white selection:text-white",
|
|
},
|
|
};
|
|
|
|
return (
|
|
<button
|
|
onClick={onClick}
|
|
className={clsx(
|
|
"py-4 px-6 rounded-full transition ease-in-out duration-300 disabled:cursor-not-allowed",
|
|
className,
|
|
colorClassNames[color][variant],
|
|
)}
|
|
disabled={disabled}>
|
|
{children}
|
|
</button>
|
|
);
|
|
}
|