allow avatar removal
This commit is contained in:
@@ -868,6 +868,7 @@ i.search {
|
|||||||
/* Styling of avatar upload control */
|
/* Styling of avatar upload control */
|
||||||
.avatar-upload {
|
.avatar-upload {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
position: relative;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
width: 7rem;
|
width: 7rem;
|
||||||
@@ -877,6 +878,19 @@ i.search {
|
|||||||
padding: 0;
|
padding: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.avatar-upload .clear-avatar {
|
||||||
|
position: absolute;
|
||||||
|
font-size: 1rem;
|
||||||
|
top: 0;
|
||||||
|
right: 0;
|
||||||
|
opacity: 0;
|
||||||
|
background-image: radial-gradient(#fff 40%, transparent 75%);
|
||||||
|
}
|
||||||
|
|
||||||
|
.avatar-upload:hover .clear-avatar {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
|
||||||
.avatar-upload .avatar-box {
|
.avatar-upload .avatar-box {
|
||||||
position: relative;
|
position: relative;
|
||||||
width: 7rem;
|
width: 7rem;
|
||||||
|
|||||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
@@ -14,6 +14,7 @@ export default class AvatarUpload extends React.Component {
|
|||||||
};
|
};
|
||||||
|
|
||||||
this.handleFileUpload = this.handleFileUpload.bind(this);
|
this.handleFileUpload = this.handleFileUpload.bind(this);
|
||||||
|
this.handleClear = this.handleClear.bind(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
static getDerivedStateFromProps(nextProps, prevState) {
|
static getDerivedStateFromProps(nextProps, prevState) {
|
||||||
@@ -41,12 +42,21 @@ export default class AvatarUpload extends React.Component {
|
|||||||
e.target.value = '';
|
e.target.value = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handleClear() {
|
||||||
|
this.props.onImageChanged(null);
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
// Randomize id value in case more than one AvatarUpload is shown
|
// Randomize id value in case more than one AvatarUpload is shown
|
||||||
// at the same time.
|
// at the same time.
|
||||||
var randId = "file-input-avatar-" + (Math.random() + '').substr(2);
|
var randId = "file-input-avatar-" + (Math.random() + '').substr(2);
|
||||||
return (
|
return (
|
||||||
<div className="avatar-upload">
|
<div className="avatar-upload">
|
||||||
|
{this.props.readOnly || !this.state.dataUrl ?
|
||||||
|
null :
|
||||||
|
<a href="javascript:;" className="clear-avatar" onClick={this.handleClear}>
|
||||||
|
<i className="material-icons">clear</i>
|
||||||
|
</a>}
|
||||||
{this.state.dataUrl ?
|
{this.state.dataUrl ?
|
||||||
<img src={this.state.dataUrl} className="preview" /> :
|
<img src={this.state.dataUrl} className="preview" /> :
|
||||||
this.props.readOnly && this.props.uid ?
|
this.props.readOnly && this.props.uid ?
|
||||||
|
|||||||
+14
-2
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+1
-1
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user