2020-08-17 15:07:16 -05:00
|
|
|
import React from 'react'
|
2020-08-17 15:59:29 -05:00
|
|
|
import PropTypes from 'prop-types'
|
2020-08-17 15:39:25 -05:00
|
|
|
import { connect } from 'react-redux'
|
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-12-02 23:22:51 -05:00
|
|
|
import {
|
|
|
|
CX,
|
|
|
|
MODAL_COMPOSE,
|
|
|
|
BREAKPOINT_EXTRA_SMALL,
|
|
|
|
} from '../constants'
|
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-08-17 15:07:16 -05:00
|
|
|
class FloatingActionButton extends React.PureComponent {
|
2020-05-14 16:45:39 -04:00
|
|
|
|
2019-08-07 01:02:36 -04:00
|
|
|
render() {
|
2021-01-08 00:15:53 -05:00
|
|
|
const { intl, onOpenCompose, state, width } = this.props
|
2020-04-23 02:13:29 -04:00
|
|
|
|
2020-05-14 16:45:39 -04:00
|
|
|
if (!me) return null
|
|
|
|
|
2020-12-02 23:22:51 -05:00
|
|
|
const isDesktop = width > BREAKPOINT_EXTRA_SMALL
|
2020-04-23 02:13:29 -04:00
|
|
|
const message = intl.formatMessage(messages.gab)
|
2020-03-25 23:11:32 -04:00
|
|
|
|
2020-05-15 18:49:54 -04:00
|
|
|
const containerClasses = CX({
|
|
|
|
posFixed: 1,
|
|
|
|
z3: 1,
|
|
|
|
mb15: 1,
|
|
|
|
mr15: 1,
|
|
|
|
right0: 1,
|
|
|
|
bottom55PX: !isDesktop,
|
|
|
|
bottom0: isDesktop,
|
|
|
|
pb15: isDesktop,
|
|
|
|
pr15: isDesktop,
|
|
|
|
})
|
|
|
|
|
2019-08-07 01:02:36 -04:00
|
|
|
return (
|
2020-05-14 17:47:33 -04:00
|
|
|
<div
|
2020-05-15 18:49:54 -04:00
|
|
|
className={containerClasses}
|
2020-05-14 17:47:33 -04:00
|
|
|
>
|
|
|
|
<Button
|
2020-05-15 18:49:54 -04:00
|
|
|
to={isDesktop ? undefined : '/compose'}
|
|
|
|
onClick={isDesktop ? onOpenCompose : undefined}
|
2020-08-18 15:43:06 -05:00
|
|
|
className={[_s.py15, _s.h60PX, _s.saveAreaInsetMR, _s.saveAreaInsetMB, _s.w60PX, _s.jcCenter, _s.aiCenter].join(' ')}
|
2020-05-14 17:47:33 -04:00
|
|
|
title={message}
|
|
|
|
aria-label={message}
|
|
|
|
icon='pencil'
|
|
|
|
iconSize='20px'
|
|
|
|
/>
|
|
|
|
</div>
|
2019-08-07 01:02:36 -04:00
|
|
|
)
|
|
|
|
}
|
2020-05-14 16:45:39 -04:00
|
|
|
|
2020-08-17 19:57:35 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
const messages = defineMessages({
|
|
|
|
gab: { id: 'gab', defaultMessage: 'Gab' },
|
|
|
|
})
|
|
|
|
|
2021-01-08 00:15:53 -05:00
|
|
|
const mapStateToProps = (state) => ({
|
|
|
|
width: state.getIn(['settings', 'window_dimensions', 'width']),
|
|
|
|
})
|
|
|
|
|
2020-08-17 19:57:35 -05:00
|
|
|
const mapDispatchToProps = (dispatch) => ({
|
2020-12-02 23:22:51 -05:00
|
|
|
onOpenCompose: () => dispatch(openModal(MODAL_COMPOSE)),
|
2020-08-17 19:57:35 -05:00
|
|
|
})
|
|
|
|
|
|
|
|
FloatingActionButton.propTypes = {
|
|
|
|
intl: PropTypes.object.isRequired,
|
|
|
|
onOpenCompose: PropTypes.func.isRequired,
|
|
|
|
}
|
|
|
|
|
2021-01-08 00:15:53 -05:00
|
|
|
export default injectIntl(connect(mapStateToProps, mapDispatchToProps)(FloatingActionButton))
|