From 81ef21a0c802f1d905f37a2a818544a8b400793c Mon Sep 17 00:00:00 2001 From: Renaud Chaput Date: Sat, 25 Feb 2023 14:34:32 +0100 Subject: [Glitch] Rename JSX files with proper `.jsx` extension Port 44a7d87cb1f5df953b6c14c16c59e2e4ead1bcb9 to glitch-soc Signed-off-by: Claire --- .../glitch/features/interaction_modal/index.js | 161 --------------------- .../glitch/features/interaction_modal/index.jsx | 161 +++++++++++++++++++++ 2 files changed, 161 insertions(+), 161 deletions(-) delete mode 100644 app/javascript/flavours/glitch/features/interaction_modal/index.js create mode 100644 app/javascript/flavours/glitch/features/interaction_modal/index.jsx (limited to 'app/javascript/flavours/glitch/features/interaction_modal') diff --git a/app/javascript/flavours/glitch/features/interaction_modal/index.js b/app/javascript/flavours/glitch/features/interaction_modal/index.js deleted file mode 100644 index 3a54105a3..000000000 --- a/app/javascript/flavours/glitch/features/interaction_modal/index.js +++ /dev/null @@ -1,161 +0,0 @@ -import React from 'react'; -import PropTypes from 'prop-types'; -import { FormattedMessage } from 'react-intl'; -import { registrationsOpen } from 'flavours/glitch/initial_state'; -import { connect } from 'react-redux'; -import Icon from 'flavours/glitch/components/icon'; -import classNames from 'classnames'; -import { openModal, closeModal } from 'flavours/glitch/actions/modal'; - -const mapStateToProps = (state, { accountId }) => ({ - displayNameHtml: state.getIn(['accounts', accountId, 'display_name_html']), -}); - -const mapDispatchToProps = (dispatch) => ({ - onSignupClick() { - dispatch(closeModal()); - dispatch(openModal('CLOSED_REGISTRATIONS')); - }, -}); - -class Copypaste extends React.PureComponent { - - static propTypes = { - value: PropTypes.string, - }; - - state = { - copied: false, - }; - - setRef = c => { - this.input = c; - }; - - handleInputClick = () => { - this.setState({ copied: false }); - this.input.focus(); - this.input.select(); - this.input.setSelectionRange(0, this.input.value.length); - }; - - handleButtonClick = () => { - const { value } = this.props; - navigator.clipboard.writeText(value); - this.input.blur(); - this.setState({ copied: true }); - this.timeout = setTimeout(() => this.setState({ copied: false }), 700); - }; - - componentWillUnmount () { - if (this.timeout) clearTimeout(this.timeout); - } - - render () { - const { value } = this.props; - const { copied } = this.state; - - return ( -
- - - -
- ); - } - -} - -export default @connect(mapStateToProps, mapDispatchToProps) -class InteractionModal extends React.PureComponent { - - static propTypes = { - displayNameHtml: PropTypes.string, - url: PropTypes.string, - type: PropTypes.oneOf(['reply', 'reblog', 'favourite', 'follow']), - onSignupClick: PropTypes.func.isRequired, - }; - - handleSignupClick = () => { - this.props.onSignupClick(); - }; - - render () { - const { url, type, displayNameHtml } = this.props; - - const name = ; - - let title, actionDescription, icon; - - switch(type) { - case 'reply': - icon = ; - title = ; - actionDescription = ; - break; - case 'reblog': - icon = ; - title = ; - actionDescription = ; - break; - case 'favourite': - icon = ; - title = ; - actionDescription = ; - break; - case 'follow': - icon = ; - title = ; - actionDescription = ; - break; - } - - let signupButton; - - if (registrationsOpen) { - signupButton = ( - - - - ); - } else { - signupButton = ( - - ); - } - - return ( -
-
-

{icon} {title}

-

{actionDescription}

-
- -
-
-

- - {signupButton} -
- -
-

-

- -
-
-
- ); - } - -} diff --git a/app/javascript/flavours/glitch/features/interaction_modal/index.jsx b/app/javascript/flavours/glitch/features/interaction_modal/index.jsx new file mode 100644 index 000000000..3a54105a3 --- /dev/null +++ b/app/javascript/flavours/glitch/features/interaction_modal/index.jsx @@ -0,0 +1,161 @@ +import React from 'react'; +import PropTypes from 'prop-types'; +import { FormattedMessage } from 'react-intl'; +import { registrationsOpen } from 'flavours/glitch/initial_state'; +import { connect } from 'react-redux'; +import Icon from 'flavours/glitch/components/icon'; +import classNames from 'classnames'; +import { openModal, closeModal } from 'flavours/glitch/actions/modal'; + +const mapStateToProps = (state, { accountId }) => ({ + displayNameHtml: state.getIn(['accounts', accountId, 'display_name_html']), +}); + +const mapDispatchToProps = (dispatch) => ({ + onSignupClick() { + dispatch(closeModal()); + dispatch(openModal('CLOSED_REGISTRATIONS')); + }, +}); + +class Copypaste extends React.PureComponent { + + static propTypes = { + value: PropTypes.string, + }; + + state = { + copied: false, + }; + + setRef = c => { + this.input = c; + }; + + handleInputClick = () => { + this.setState({ copied: false }); + this.input.focus(); + this.input.select(); + this.input.setSelectionRange(0, this.input.value.length); + }; + + handleButtonClick = () => { + const { value } = this.props; + navigator.clipboard.writeText(value); + this.input.blur(); + this.setState({ copied: true }); + this.timeout = setTimeout(() => this.setState({ copied: false }), 700); + }; + + componentWillUnmount () { + if (this.timeout) clearTimeout(this.timeout); + } + + render () { + const { value } = this.props; + const { copied } = this.state; + + return ( +
+ + + +
+ ); + } + +} + +export default @connect(mapStateToProps, mapDispatchToProps) +class InteractionModal extends React.PureComponent { + + static propTypes = { + displayNameHtml: PropTypes.string, + url: PropTypes.string, + type: PropTypes.oneOf(['reply', 'reblog', 'favourite', 'follow']), + onSignupClick: PropTypes.func.isRequired, + }; + + handleSignupClick = () => { + this.props.onSignupClick(); + }; + + render () { + const { url, type, displayNameHtml } = this.props; + + const name = ; + + let title, actionDescription, icon; + + switch(type) { + case 'reply': + icon = ; + title = ; + actionDescription = ; + break; + case 'reblog': + icon = ; + title = ; + actionDescription = ; + break; + case 'favourite': + icon = ; + title = ; + actionDescription = ; + break; + case 'follow': + icon = ; + title = ; + actionDescription = ; + break; + } + + let signupButton; + + if (registrationsOpen) { + signupButton = ( + + + + ); + } else { + signupButton = ( + + ); + } + + return ( +
+
+

{icon} {title}

+

{actionDescription}

+
+ +
+
+

+ + {signupButton} +
+ +
+

+

+ +
+
+
+ ); + } + +} -- cgit