gab-social/app/javascript/gabsocial/components/floating_action_button.js

41 lines
1012 B
JavaScript
Raw Normal View History

2020-04-23 07:13:29 +01:00
import { defineMessages, injectIntl } from 'react-intl'
import { openModal } from '../actions/modal'
2020-02-24 21:56:07 +00:00
import Button from './button'
2020-01-27 22:20:07 +00:00
2020-04-23 07:13:29 +01:00
const messages = defineMessages({
gab: { id: 'gab', defaultMessage: 'Gab' },
})
const mapDispatchToProps = (dispatch) => ({
onOpenCompose: () => dispatch(openModal('COMPOSE')),
})
export default
@injectIntl
@connect(null, mapDispatchToProps)
class FloatingActionButton extends PureComponent {
static propTypes = {
2020-04-23 07:13:29 +01:00
intl: PropTypes.object.isRequired,
onOpenCompose: PropTypes.func.isRequired,
2020-04-11 23:29:19 +01:00
}
2020-01-27 22:20:07 +00:00
shouldComponentUpdate(nextProps) {
2020-04-11 23:29:19 +01:00
return nextProps.message !== this.props.message
}
render() {
2020-04-23 07:13:29 +01:00
const { intl, onOpenCompose } = this.props
const message = intl.formatMessage(messages.gab)
2020-03-26 03:11:32 +00:00
return (
2020-03-26 03:11:32 +00:00
<Button
2020-04-23 07:13:29 +01:00
onClick={onOpenCompose}
2020-05-06 05:33:54 +01:00
className={[_s.posFixed, _s.z4, _s.py15, _s.mb15, _s.mr15, _s.bottom50PX, _s.right0].join(' ')}
2020-03-26 03:11:32 +00:00
title={message}
aria-label={message}
2020-04-09 20:18:14 +01:00
icon='pencil'
/>
)
}
}