Created
June 2, 2021 15:02
-
-
Save whisher/78a2e977cd42415c834a1196bf3589e1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { ReactNode } from 'react'; | |
export interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> { | |
children: ReactNode; | |
color: 'primary' | 'secondary'; | |
size: 'sm' | 'lg'; | |
} | |
const commons = | |
'inline-flex justify-center items-center w-auto py-0 font-sans font-semibold no-underline tracking-wide text-white cursor-pointer transition duration-300 ease select-none border border-solid rounded focus:outline-none focus:shadow'; | |
const colors = { | |
primary: 'border-primary bg-primary hover:bg-primary-dark', | |
secondary: 'border-secondary bg-secondary hover:bg-secondary-dark', | |
}; | |
const sizes = { | |
lg: 'h-10 px-6 text-lg', | |
sm: 'h-8 px-3 text-base', | |
}; | |
const Button = ({ children, color, size, ...buttonProps }: ButtonProps) => { | |
return ( | |
<button {...buttonProps} className={`${commons} ${colors[color]} ${sizes[size]}`}> | |
{children} | |
</button> | |
); | |
}; | |
export { Button }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment