YesPlayMusic/packages/web/components/Button.tsx

48 lines
1.0 KiB
TypeScript
Raw Normal View History

2022-03-13 14:40:38 +08:00
import { ReactNode } from 'react'
2022-05-12 02:45:43 +08:00
import cx from 'classnames'
2022-03-13 14:40:38 +08:00
export enum Color {
Primary = 'primary',
Gray = 'gray',
}
export enum Shape {
Default = 'default',
Square = 'square',
}
const Button = ({
children,
onClick,
color = Color.Primary,
iconColor = Color.Primary,
isSkelton = false,
}: {
children: ReactNode
onClick: () => void
color?: Color
iconColor?: Color
isSkelton?: boolean
}) => {
return (
<button
onClick={onClick}
2022-05-12 02:45:43 +08:00
className={cx(
2022-03-21 02:03:25 +08:00
'btn-pressed-animation flex cursor-default items-center rounded-lg px-4 py-1.5 text-lg font-medium',
2022-03-13 14:40:38 +08:00
{
2022-03-17 14:45:04 +08:00
'bg-brand-100 dark:bg-brand-600': color === Color.Primary,
2022-03-13 14:40:38 +08:00
'text-brand-500 dark:text-white': iconColor === Color.Primary,
'bg-gray-100 dark:bg-gray-700': color === Color.Gray,
2022-03-23 01:21:22 +08:00
'text-gray-600 dark:text-gray-400': iconColor === Color.Gray,
2022-03-17 14:45:04 +08:00
'animate-pulse bg-gray-100 !text-transparent dark:bg-gray-800':
2022-03-13 14:40:38 +08:00
isSkelton,
}
)}
>
{children}
</button>
)
}
export default Button