Spaces:
Running
Running
File size: 1,541 Bytes
f2bee8a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
import classNames from 'classnames';
import {connect} from 'react-redux';
import PropTypes from 'prop-types';
import React from 'react';
import {defineMessages, intlShape, injectIntl} from 'react-intl';
import {setProjectTitle} from '../../reducers/project-title';
import BufferedInputHOC from '../forms/buffered-input-hoc.jsx';
import Input from '../forms/input.jsx';
const BufferedInput = BufferedInputHOC(Input);
import styles from './project-title-input.css';
const messages = defineMessages({
projectTitlePlaceholder: {
id: 'gui.gui.projectTitlePlaceholder',
description: 'Placeholder for project title when blank',
defaultMessage: 'Project title here'
}
});
const ProjectTitleInput = ({
className,
intl,
onSubmit,
projectTitle
}) => (
<BufferedInput
className={classNames(styles.titleField, className)}
maxLength="100"
placeholder={intl.formatMessage(messages.projectTitlePlaceholder)}
tabIndex="0"
type="text"
value={projectTitle}
onSubmit={onSubmit}
/>
);
ProjectTitleInput.propTypes = {
className: PropTypes.string,
intl: intlShape.isRequired,
onSubmit: PropTypes.func,
projectTitle: PropTypes.string
};
const mapStateToProps = state => ({
projectTitle: state.scratchGui.projectTitle
});
const mapDispatchToProps = dispatch => ({
onSubmit: title => dispatch(setProjectTitle(title))
});
export default injectIntl(connect(
mapStateToProps,
mapDispatchToProps
)(ProjectTitleInput));
|