quintodrome/ui/src/common/PlayButton.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

31 lines
666 B
JavaScript
Raw Normal View History

import React from 'react'
import PropTypes from 'prop-types'
import PlayArrowIcon from '@material-ui/icons/PlayArrow'
import { IconButton } from '@material-ui/core'
import { useDispatch } from 'react-redux'
const defaultIcon = <PlayArrowIcon fontSize="small" />
2020-02-07 12:38:01 -09:00
const PlayButton = ({ icon = defaultIcon, action, ...rest }) => {
const dispatch = useDispatch()
return (
2020-02-05 09:19:37 -09:00
<IconButton
onClick={(e) => {
e.stopPropagation()
2020-02-07 12:38:01 -09:00
dispatch(action)
}}
2020-02-05 09:19:37 -09:00
{...rest}
size={'small'}
>
{icon}
</IconButton>
)
}
PlayButton.propTypes = {
icon: PropTypes.element,
2020-02-07 12:38:01 -09:00
action: PropTypes.object,
}
export default PlayButton