|
|
@@ -1,6 +1,5 @@
|
|
|
import React from 'react';
|
|
|
import PropTypes from 'prop-types';
|
|
|
-import Modal from 'react-bootstrap/es/Modal';
|
|
|
import { withTranslation } from 'react-i18next';
|
|
|
|
|
|
import ReactCrop from 'react-image-crop';
|
|
|
@@ -20,7 +19,6 @@ class ProfileImageUploader extends React.Component {
|
|
|
unit: '%',
|
|
|
width: 30,
|
|
|
aspect: 1,
|
|
|
- show: true,
|
|
|
},
|
|
|
};
|
|
|
|
|
|
@@ -31,7 +29,6 @@ class ProfileImageUploader extends React.Component {
|
|
|
this.makeClientCrop = this.makeClientCrop.bind(this);
|
|
|
this.getCroppedImg = this.getCroppedImg.bind(this);
|
|
|
this.hanndleSubmit = this.handleSubmit.bind(this);
|
|
|
- this.cancel = this.cancel.bind(this);
|
|
|
}
|
|
|
|
|
|
onSelectFile(e) {
|
|
|
@@ -40,7 +37,6 @@ class ProfileImageUploader extends React.Component {
|
|
|
reader.addEventListener('load', () => this.setState({ src: reader.result }));
|
|
|
reader.readAsDataURL(e.target.files[0]);
|
|
|
}
|
|
|
- this.show();
|
|
|
}
|
|
|
|
|
|
// If you setState the crop in here you should return false.
|
|
|
@@ -98,57 +94,29 @@ class ProfileImageUploader extends React.Component {
|
|
|
// の処理を node で記述
|
|
|
}
|
|
|
|
|
|
- show() {
|
|
|
- this.setState({ show: true });
|
|
|
- }
|
|
|
-
|
|
|
- hide() {
|
|
|
- this.setState({ show: false });
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- cancel() {
|
|
|
- this.hide();
|
|
|
- }
|
|
|
-
|
|
|
render() {
|
|
|
- const { t } = this.props;
|
|
|
const { crop, src } = this.state;
|
|
|
|
|
|
return (
|
|
|
- <div className="ProfileImageUploader">
|
|
|
- <div className="form-group">
|
|
|
- <label htmlFfor="" className="col-sm-4 control-label">
|
|
|
- {t('Upload new image')}
|
|
|
- </label>
|
|
|
- </div>
|
|
|
+ <div className="App">
|
|
|
<input type="file" onChange={this.onSelectFile} name="profileImage" accept="image/*" />
|
|
|
{src
|
|
|
&& (
|
|
|
- <Modal show={this.state.show} onHide={this.cancel}>
|
|
|
- <Modal.Header closeButton>
|
|
|
- <Modal.Title>Modal heading</Modal.Title>
|
|
|
- </Modal.Header>
|
|
|
- <Modal.Body className="my-5">
|
|
|
- <ReactCrop
|
|
|
- src={src}
|
|
|
- crop={crop}
|
|
|
- circularCrop
|
|
|
- onImageLoaded={this.onImageLoaded}
|
|
|
- onComplete={this.onCropComplete}
|
|
|
- onChange={this.onCropChange}
|
|
|
- />
|
|
|
- <button
|
|
|
- type="button"
|
|
|
- onClick={this.handleSubmit}
|
|
|
- className="my-3"
|
|
|
- >
|
|
|
- 完了
|
|
|
- </button>
|
|
|
- </Modal.Body>
|
|
|
- <Modal.Footer>
|
|
|
- </Modal.Footer>
|
|
|
- </Modal>
|
|
|
+ <div>
|
|
|
+ <ReactCrop
|
|
|
+ src={src}
|
|
|
+ crop={crop}
|
|
|
+ onImageLoaded={this.onImageLoaded}
|
|
|
+ onComplete={this.onCropComplete}
|
|
|
+ onChange={this.onCropChange}
|
|
|
+ />
|
|
|
+ <button
|
|
|
+ type="button"
|
|
|
+ onClick={this.handleSubmit}
|
|
|
+ >
|
|
|
+ 完了
|
|
|
+ </button>
|
|
|
+ </div>
|
|
|
)}
|
|
|
</div>
|
|
|
);
|
|
|
@@ -164,7 +132,6 @@ const ProfileImageFormWrapper = (props) => {
|
|
|
};
|
|
|
|
|
|
ProfileImageUploader.propTypes = {
|
|
|
- t: PropTypes.func.isRequired, // i18next
|
|
|
appContainer: PropTypes.instanceOf(AppContainer).isRequired,
|
|
|
};
|
|
|
|