started working on avatar upload

This commit is contained in:
Jori Lallo
2017-12-03 08:47:21 -08:00
parent cd1d2430bb
commit c2879c51b2
3 changed files with 54 additions and 2 deletions

View File

@@ -9,10 +9,11 @@ import { color, size } from 'shared/styles/constants';
import { client } from 'utils/ApiClient';
import AuthStore from 'stores/AuthStore';
import ErrorsStore from 'stores/ErrorsStore';
import Input from 'components/Input';
import Input, { LabelText } from 'components/Input';
import Button from 'components/Button';
import CenteredContent from 'components/CenteredContent';
import PageTitle from 'components/PageTitle';
import Flex from 'shared/components/Flex';
@observer
class Settings extends Component {
@@ -65,12 +66,21 @@ class Settings extends Component {
render() {
const { user } = this.props.auth;
if (!user) return null;
const avatarUrl = user.avatarUrl;
return (
<CenteredContent>
<PageTitle title="Profile" />
<h1>Profile</h1>
<ProfilePicture column>
<LabelText>Profile picture</LabelText>
<AvatarContainer>
<Avatar src={avatarUrl} />
<Flex auto align="center" justify="center">
Upload new image
</Flex>
</AvatarContainer>
</ProfilePicture>
<form onSubmit={this.handleSubmit}>
<Input
label="Name"
@@ -98,4 +108,41 @@ const SuccessMessage = styled.span`
transition: opacity 0.25s;
`;
const ProfilePicture = styled(Flex)`
margin-bottom: ${size.huge};
`;
const avatarStyles = `
width: 150px;
height: 150px;
border-radius: 50%;
`;
const AvatarContainer = styled(Flex)`
${avatarStyles};
position: relative;
div {
${avatarStyles};
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
opacity: 0;
cursor: pointer;
transition: all 250ms;
}
&:hover div {
opacity: 1;
background: rgba(0, 0, 0, 0.75);
color: #ffffff;
}
`;
const Avatar = styled.img`
${avatarStyles};
`;
export default inject('auth', 'errors', 'auth')(Settings);

View File

@@ -148,6 +148,7 @@
"react-dom": "^16.1.0",
"react-dropzone": "4.2.1",
"react-helmet": "^5.2.0",
"react-image-crop": "^3.0.7",
"react-keydown": "^1.7.3",
"react-markdown": "^3.0.2",
"react-medium-image-zoom": "^3.0.2",

View File

@@ -7415,6 +7415,10 @@ react-helmet@^5.2.0:
prop-types "^15.5.4"
react-side-effect "^1.1.0"
react-image-crop@^3.0.7:
version "3.0.7"
resolved "https://registry.yarnpkg.com/react-image-crop/-/react-image-crop-3.0.7.tgz#8f7f1f03031c76c8b6306d11f7d1b8bf3007ab8c"
react-immutable-proptypes@^2.1.0:
version "2.1.0"
resolved "https://registry.npmjs.org/react-immutable-proptypes/-/react-immutable-proptypes-2.1.0.tgz#023d6f39bb15c97c071e9e60d00d136eac5fa0b4"