First Commit
This commit is contained in:
45
src/Button.tsx
Normal file
45
src/Button.tsx
Normal file
@ -0,0 +1,45 @@
|
||||
import { h, JSX } from "preact";
|
||||
|
||||
export enum ButtonFormats {
|
||||
DEFAULT,
|
||||
PRIMARY,
|
||||
SECONDARY,
|
||||
ERROR,
|
||||
SUCCESS
|
||||
}
|
||||
|
||||
export interface IButtonProps extends JSX.HTMLAttributes<HTMLButtonElement> {
|
||||
format: ButtonFormats;
|
||||
}
|
||||
|
||||
export default function Button({
|
||||
children,
|
||||
format,
|
||||
className,
|
||||
...props
|
||||
}: IButtonProps) {
|
||||
let cl = "ht-btn";
|
||||
|
||||
if (className) cl += " " + className;
|
||||
|
||||
switch (format) {
|
||||
case ButtonFormats.DEFAULT:
|
||||
break;
|
||||
case ButtonFormats.PRIMARY:
|
||||
cl += " ht-btn-primary";
|
||||
break;
|
||||
case ButtonFormats.SECONDARY:
|
||||
cl += " ht-btn-secondary";
|
||||
break;
|
||||
case ButtonFormats.ERROR:
|
||||
cl += " ht-btn-error";
|
||||
break;
|
||||
case ButtonFormats.SUCCESS:
|
||||
cl += " ht-btn-success";
|
||||
break;
|
||||
}
|
||||
|
||||
<button className={cl} {...props}>
|
||||
{children}
|
||||
</button>;
|
||||
}
|
Reference in New Issue
Block a user