digitransit-ui/app/component/itinerary-feedback.js
Juha-Matti Viertola d09ad06cf5 Merge branch 'master' into DT-2872
Conflicts:
	app/component/OriginDestinationBar.js
	app/component/TransitLeg.js
2019-02-08 13:21:31 +02:00

83 lines
2.2 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import React from 'react';
import cx from 'classnames';
import { intlShape, FormattedMessage } from 'react-intl';
import Icon from './Icon';
export default class ItineraryFeedback extends React.Component {
static contextTypes = {
intl: intlShape.isRequired,
};
state = {
feedbackFormOpen: false,
feedbackText: '',
};
sendFeedback = () => {
// Handle saving of feedback. Text is available in
// this.state.feedbackText,
this.setState({ feedbackText: '', feedbackFormOpen: false });
};
updateText = event => {
this.setState({ feedbackText: event.target.value });
};
toggleFeedbackForm = () => {
this.setState(prevState => ({
feedbackFormOpen: !prevState.feedbackFormOpen,
}));
};
render() {
const placeholder = this.context.intl.formatMessage({
id: 'itinerary-feedback-placeholder',
defaultMessage: 'Description (optional)',
});
const buttonText = this.context.intl.formatMessage({
id: 'itinerary-feedback-button',
defaultMessage: 'Send feedback',
});
return (
<span className="itinerary-feedback-container">
<button
className={cx('standalone-btn itinerary-feedback-btn', {
active: this.state.feedbackFormOpen,
})}
onClick={this.toggleFeedbackForm}
>
<Icon img="icon-icon_speech-bubble" />
</button>
<div
className={cx('form-container', {
open: this.state.feedbackFormOpen,
})}
>
<div className="form">
<div className="form-message">
<FormattedMessage
id="itinerary-feedback-message"
defaultMessage="Couldnt find what you were looking for?"
/>
</div>
<textarea
className="feedback-text"
placeholder={placeholder}
rows={3}
maxLength={200}
value={this.state.feedbackText}
onChange={this.updateText}
/>
<input
type="button"
className="standalone-btn"
value={buttonText}
onClick={this.sendFeedback}
/>
</div>
</div>
</span>
);
}
}