mirror of
https://github.com/samuelcolvin/FastUI.git
synced 2023-12-01 22:22:11 +03:00
25 lines
582 B
TypeScript
25 lines
582 B
TypeScript
import { FC } from 'react'
|
|
|
|
import { ClassName, useClassName } from '../hooks/className'
|
|
import { useFireEvent, AnyEvent } from '../hooks/events'
|
|
|
|
export interface ButtonProps {
|
|
type: 'Button'
|
|
text: string
|
|
onClick?: AnyEvent
|
|
htmlType?: 'button' | 'submit' | 'reset'
|
|
className?: ClassName
|
|
}
|
|
|
|
export const ButtonComp: FC<ButtonProps> = (props) => {
|
|
const { text, onClick, htmlType } = props
|
|
|
|
const { fireEvent } = useFireEvent()
|
|
|
|
return (
|
|
<button className={useClassName(props)} type={htmlType} onClick={() => fireEvent(onClick)}>
|
|
{text}
|
|
</button>
|
|
)
|
|
}
|