2020-10-24 20:17:21 +01:00
|
|
|
import React from 'react'
|
|
|
|
import PropTypes from 'prop-types'
|
|
|
|
import ImmutablePropTypes from 'react-immutable-proptypes'
|
|
|
|
import ImmutablePureComponent from 'react-immutable-pure-component'
|
|
|
|
import { connect } from 'react-redux'
|
|
|
|
import { defineMessages, injectIntl } from 'react-intl'
|
|
|
|
import { openModal } from '../../actions/modal'
|
2020-12-16 00:31:30 +00:00
|
|
|
import { showToast } from '../../actions/toasts'
|
2020-10-24 20:17:21 +01:00
|
|
|
import { closePopover } from '../../actions/popover'
|
|
|
|
import PopoverLayout from './popover_layout'
|
2020-10-25 00:50:09 +01:00
|
|
|
import Button from '../button'
|
|
|
|
import Heading from '../heading'
|
|
|
|
import Text from '../text'
|
2020-10-24 20:17:21 +01:00
|
|
|
import List from '../list'
|
|
|
|
|
|
|
|
class StatusSharePopover extends ImmutablePureComponent {
|
|
|
|
|
|
|
|
handleCopy = () => {
|
|
|
|
const url = this.props.status.get('url')
|
|
|
|
const textarea = document.createElement('textarea')
|
|
|
|
|
|
|
|
textarea.textContent = url
|
|
|
|
textarea.style.position = 'fixed'
|
|
|
|
|
|
|
|
document.body.appendChild(textarea)
|
|
|
|
|
|
|
|
try {
|
|
|
|
textarea.select()
|
|
|
|
document.execCommand('copy')
|
|
|
|
} catch (e) {
|
|
|
|
//
|
|
|
|
}
|
|
|
|
|
|
|
|
document.body.removeChild(textarea)
|
2020-12-16 00:31:30 +00:00
|
|
|
this.props.onShowCopyToast()
|
2020-10-24 20:17:21 +01:00
|
|
|
this.handleClosePopover()
|
|
|
|
}
|
|
|
|
|
|
|
|
handleClosePopover = () => {
|
|
|
|
this.props.onClosePopover()
|
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
|
|
|
const { intl, status } = this.props
|
|
|
|
|
2020-10-25 02:58:48 +00:00
|
|
|
if (!status) return <div />
|
2020-10-24 20:17:21 +01:00
|
|
|
|
2020-10-25 02:58:48 +00:00
|
|
|
const encodedStatusUrl = encodeURIComponent(status.get('url'))
|
|
|
|
const mailToHref = `mailto:?subject=Gab&body=${encodedStatusUrl}`
|
|
|
|
const content = status.get('contentHtml')
|
2020-10-30 04:32:06 +00:00
|
|
|
const iconSize = '18px'
|
|
|
|
|
2020-10-24 20:17:21 +01:00
|
|
|
return (
|
2020-10-25 00:50:09 +01:00
|
|
|
<PopoverLayout
|
|
|
|
width={360}
|
|
|
|
>
|
|
|
|
<div className={[_s.d, _s.flexRow, _s.aiCenter, _s.jcCenter, _s.borderBottom1PX, _s.borderColorSecondary, _s.h53PX, _s.px15].join(' ')}>
|
|
|
|
<Heading size='h3'>
|
|
|
|
Share Gab
|
|
|
|
</Heading>
|
|
|
|
</div>
|
|
|
|
<div className={[_s.d, _s.w100PC, _s.px15, _s.py15, _s.flexRow, _s.noScrollbar, _s.aiCenter, _s.overflowXScroll, _s.borderBottom1PX, _s.borderColorSecondary].join(' ')}>
|
|
|
|
<Button
|
|
|
|
icon='copy'
|
2020-10-30 04:32:06 +00:00
|
|
|
iconSize={iconSize}
|
2020-10-25 00:50:09 +01:00
|
|
|
iconClassName={_s.inheritFill}
|
2020-10-30 04:32:06 +00:00
|
|
|
color='primary'
|
2020-10-25 00:50:09 +01:00
|
|
|
backgroundColor='secondary'
|
|
|
|
onClick={this.handleCopy}
|
2020-10-25 02:58:48 +00:00
|
|
|
title={intl.formatMessage(messages.copy)}
|
2020-10-30 04:32:06 +00:00
|
|
|
className={[_s.jcCenter, _s.aiCenter, _s.mr10, _s.px10].join(' ')}
|
2020-10-25 00:50:09 +01:00
|
|
|
/>
|
|
|
|
<Button
|
|
|
|
icon='sms'
|
2020-10-30 04:32:06 +00:00
|
|
|
iconSize={iconSize}
|
2020-10-25 00:50:09 +01:00
|
|
|
iconClassName={_s.inheritFill}
|
|
|
|
color='white'
|
|
|
|
backgroundColor='none'
|
2020-10-25 02:58:48 +00:00
|
|
|
href={`sms:+&body=${encodedStatusUrl}`}
|
2020-10-30 04:32:06 +00:00
|
|
|
target='_blank'
|
2020-10-25 02:58:48 +00:00
|
|
|
title='Share via text message'
|
2020-10-30 04:32:06 +00:00
|
|
|
className={[_s.jcCenter, _s.aiCenter, _s.mr10, _s.px10, _s.bgSMS].join(' ')}
|
2020-10-25 00:50:09 +01:00
|
|
|
/>
|
|
|
|
<Button
|
|
|
|
icon='facebook'
|
2020-10-30 04:32:06 +00:00
|
|
|
iconSize={iconSize}
|
2020-10-25 00:50:09 +01:00
|
|
|
iconClassName={_s.inheritFill}
|
|
|
|
color='white'
|
|
|
|
backgroundColor='none'
|
2020-10-25 02:58:48 +00:00
|
|
|
href={`https://www.facebook.com/sharer/sharer.php?u=${encodedStatusUrl}`}
|
2020-10-30 04:32:06 +00:00
|
|
|
target='_blank'
|
2020-10-25 02:58:48 +00:00
|
|
|
title='Share on Facebook'
|
2020-10-30 04:32:06 +00:00
|
|
|
className={[_s.jcCenter, _s.aiCenter, _s.mr10, _s.px10, _s.bgFacebook].join(' ')}
|
2020-10-25 00:50:09 +01:00
|
|
|
/>
|
|
|
|
<Button
|
|
|
|
icon='twitter'
|
2020-10-30 04:32:06 +00:00
|
|
|
iconSize={iconSize}
|
2020-10-25 00:50:09 +01:00
|
|
|
iconClassName={_s.inheritFill}
|
|
|
|
color='white'
|
|
|
|
backgroundColor='none'
|
2020-10-25 02:58:48 +00:00
|
|
|
href={`https://twitter.com/intent/tweet?url=${encodedStatusUrl}`}
|
2020-10-30 04:32:06 +00:00
|
|
|
target='_blank'
|
2020-10-25 02:58:48 +00:00
|
|
|
title='Share on Twitter'
|
2020-10-30 04:32:06 +00:00
|
|
|
className={[_s.jcCenter, _s.aiCenter, _s.mr10, _s.px10, _s.bgTwitter].join(' ')}
|
2020-10-25 00:50:09 +01:00
|
|
|
/>
|
|
|
|
<Button
|
|
|
|
icon='telegram'
|
2020-10-30 04:32:06 +00:00
|
|
|
iconSize={iconSize}
|
2020-10-25 00:50:09 +01:00
|
|
|
iconClassName={_s.inheritFill}
|
|
|
|
color='white'
|
|
|
|
backgroundColor='none'
|
2020-10-25 02:58:48 +00:00
|
|
|
href={`https://telegram.me/share/?url=${encodedStatusUrl}`}
|
2020-10-30 04:32:06 +00:00
|
|
|
target='_blank'
|
2020-10-25 02:58:48 +00:00
|
|
|
title='Share on Telegram'
|
2020-10-30 04:32:06 +00:00
|
|
|
className={[_s.jcCenter, _s.aiCenter, _s.mr10, _s.px10, _s.bgTelegram].join(' ')}
|
2020-10-25 00:50:09 +01:00
|
|
|
/>
|
|
|
|
<Button
|
|
|
|
icon='reddit'
|
2020-10-30 04:32:06 +00:00
|
|
|
iconSize={iconSize}
|
2020-10-25 00:50:09 +01:00
|
|
|
iconClassName={_s.inheritFill}
|
|
|
|
color='white'
|
|
|
|
backgroundColor='none'
|
2020-10-25 02:58:48 +00:00
|
|
|
href={`http://www.reddit.com/submit?url=${encodedStatusUrl}&title=Gab`}
|
|
|
|
title='Share on Reddit'
|
2020-10-30 04:32:06 +00:00
|
|
|
target='_blank'
|
|
|
|
className={[_s.jcCenter, _s.aiCenter, _s.px10, _s.mr10, _s.bgReddit].join(' ')}
|
2020-10-25 00:50:09 +01:00
|
|
|
/>
|
|
|
|
<Button
|
|
|
|
icon='email'
|
2020-10-30 04:32:06 +00:00
|
|
|
iconSize={iconSize}
|
2020-10-25 00:50:09 +01:00
|
|
|
iconClassName={_s.inheritFill}
|
|
|
|
color='white'
|
|
|
|
backgroundColor='black'
|
2020-10-25 02:58:48 +00:00
|
|
|
href={mailToHref}
|
2020-10-30 04:32:06 +00:00
|
|
|
target='_blank'
|
2020-10-25 02:58:48 +00:00
|
|
|
title='Share via email'
|
2020-10-25 00:50:09 +01:00
|
|
|
className={[_s.jcCenter, _s.aiCenter, _s.mr10, _s.px10].join(' ')}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
<div className={[_s.d, _s.w100PC, _s.px15, _s.py15].join(' ')}>
|
|
|
|
<Button
|
|
|
|
color='primary'
|
|
|
|
backgroundColor='tertiary'
|
|
|
|
onClick={this.handleClosePopover}
|
|
|
|
className={[_s.jcCenter, _s.aiCenter].join(' ')}
|
|
|
|
>
|
|
|
|
<Text color='inherit'>Cancel</Text>
|
|
|
|
</Button>
|
|
|
|
</div>
|
2020-10-24 20:17:21 +01:00
|
|
|
</PopoverLayout>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const messages = defineMessages({
|
|
|
|
email: { id: 'status.email', defaultMessage: 'Email this gab' },
|
|
|
|
copy: { id: 'status.copy', defaultMessage: 'Copy link to status' },
|
|
|
|
})
|
|
|
|
|
|
|
|
const mapDispatchToProps = (dispatch) => ({
|
|
|
|
onClosePopover: () => dispatch(closePopover()),
|
2020-12-16 00:31:30 +00:00
|
|
|
onShowCopyToast() {
|
|
|
|
dispatch(showToast())
|
|
|
|
},
|
2020-10-24 20:17:21 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
StatusSharePopover.propTypes = {
|
|
|
|
intl: PropTypes.object.isRequired,
|
|
|
|
onClosePopover: PropTypes.func.isRequired,
|
|
|
|
status: ImmutablePropTypes.map.isRequired,
|
|
|
|
}
|
|
|
|
|
|
|
|
export default injectIntl(connect(null, mapDispatchToProps)(StatusSharePopover))
|