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

51 lines
1.3 KiB
JavaScript
Raw Normal View History

2020-04-23 02:13:29 -04:00
import { defineMessages, injectIntl } from 'react-intl'
2020-05-14 16:45:39 -04:00
import { me } from '../initial_state'
2020-04-23 02:13:29 -04:00
import { openModal } from '../actions/modal'
2020-02-24 16:56:07 -05:00
import Button from './button'
2020-01-27 17:20:07 -05:00
2020-04-23 02:13:29 -04: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 {
2020-05-14 16:45:39 -04:00
static propTypes = {
2020-04-23 02:13:29 -04:00
intl: PropTypes.object.isRequired,
onOpenCompose: PropTypes.func.isRequired,
2020-04-11 18:29:19 -04:00
}
2020-01-27 17:20:07 -05:00
shouldComponentUpdate(nextProps) {
2020-04-11 18:29:19 -04:00
return nextProps.message !== this.props.message
}
render() {
2020-04-23 02:13:29 -04:00
const { intl, onOpenCompose } = this.props
2020-05-14 16:45:39 -04:00
if (!me) return null
2020-04-23 02:13:29 -04:00
const message = intl.formatMessage(messages.gab)
2020-03-25 23:11:32 -04:00
return (
<div
className={[_s.posFixed, _s.z4, _s.mb15, _s.mr15, _s.bottom55PX, _s.right0].join(' ')}
>
<Button
2020-05-14 23:17:31 -04:00
to='/compose'
className={[_s.py15, _s.height60PX, _s.saveAreaInsetMR, _s.saveAreaInsetMB, _s.width60PX, _s.justifyContentCenter, _s.alignItemsCenter].join(' ')}
title={message}
aria-label={message}
icon='pencil'
iconSize='20px'
/>
</div>
)
}
2020-05-14 16:45:39 -04:00
}