2021-01-09 18:26:46 +01:00
|
|
|
import { h } from 'preact';
|
|
|
|
|
|
|
|
const noop = () => {};
|
|
|
|
|
2021-01-18 18:31:06 +01:00
|
|
|
const BUTTON_COLORS = {
|
|
|
|
blue: { normal: 'bg-blue-500', hover: 'hover:bg-blue-400' },
|
|
|
|
red: { normal: 'bg-red-500', hover: 'hover:bg-red-400' },
|
|
|
|
green: { normal: 'bg-green-500', hover: 'hover:bg-green-400' },
|
|
|
|
};
|
|
|
|
|
2021-01-15 21:29:30 +01:00
|
|
|
export default function Button({ children, className, color = 'blue', onClick, size, ...attrs }) {
|
2021-01-09 18:26:46 +01:00
|
|
|
return (
|
|
|
|
<div
|
|
|
|
role="button"
|
|
|
|
tabindex="0"
|
2021-01-18 18:31:06 +01:00
|
|
|
className={`rounded ${BUTTON_COLORS[color].normal} text-white pl-4 pr-4 pt-2 pb-2 font-bold shadow ${BUTTON_COLORS[color].hover} hover:shadow-lg cursor-pointer ${className}`}
|
2021-01-09 18:26:46 +01:00
|
|
|
onClick={onClick || noop}
|
2021-01-15 21:29:30 +01:00
|
|
|
{...attrs}
|
2021-01-09 18:26:46 +01:00
|
|
|
>
|
|
|
|
{children}
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|