/
UserBlock.tsx
138 lines (123 loc) · 3.25 KB
/
UserBlock.tsx
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
import { RouterProps, withRouter } from 'next/router';
import { darken, lighten } from 'polished';
import { Component } from 'react';
import CreatePost from '../../components/CreatePost';
import Profile from '../../components/Profile';
import styled from '../../theme';
import { Button } from '../../ui/Button';
import { Icon } from '../../ui/Icon';
import { Modal, ModalFull } from '../../ui/Modal';
import { humanNumbers } from '../../utils/count';
import { changeURLParams } from '../../utils/url';
import Avatar from '../Avatar';
import Menu from './Menu';
const Box = styled.div`
display: flex;
height: 100%;
align-items: center;
`;
const UserDataBox = styled.div`
padding: 0 10px;
display: flex;
cursor: pointer;
align-items: center;
height: 100%;
`;
const AvatarBox = styled.div`
padding-left: 14px;
`;
const UserPoints = styled.div`
display: flex;
align-items: center;
margin: 0 20px;
font-size: 13px;
background: radial-gradient(
${({ theme }) => lighten(0.02, theme.dark2Color)},
${({ theme }) => darken(0.02, theme.dark2Color)}
);
padding: 0 10px;
border-radius: 5px;
height: 32px;
@media (max-width: 700px) {
display: none;
}
`;
const UserPointsIcon = styled.div`
height: 18px;
width: 18px;
border-radius: 100%;
background: transparent;
border: 2px solid #a48b3f;
margin: 0 10px 0 5px;
font-size: 10px;
display: flex;
align-items: center;
justify-content: center;
color: ${() => lighten(0.3, '#a48b3f')};
`;
const UserPointsCount = styled.div`
color: ${({ theme }) => lighten(0.4, theme.main1Color)};
font-size: 12px;
font-weight: 500;
`;
const UserNameBox = styled.div`
display: flex;
align-items: center;
font-size: 13px;
color: ${({ theme }) => lighten(0.4, theme.main1Color)};
@media (max-width: 700px) {
display: none;
}
`;
const UserCaratBox = styled.div`
height: 100%;
padding: 0 6px;
display: flex;
align-items: center;
font-size: 17px;
`;
interface IProps {
router: RouterProps;
user: any;
}
class UserBlockWithoutRouter extends Component<IProps> {
constructor(props) {
super(props);
}
public render() {
const { user, router } = this.props;
return (
<Box>
<Button onClick={() => changeURLParams({ set: { newPost: 1 } })}>
Закинуть клип
</Button>
<Modal
title="Новый пост"
isOpen={router.query.newPost === '1'}
onClose={() => changeURLParams({ remove: ['newPost'] })}
>
<CreatePost />
</Modal>
<UserPoints>
<UserPointsIcon>$</UserPointsIcon>
<UserPointsCount>{humanNumbers(user.points)}</UserPointsCount>
</UserPoints>
<Menu user={user}>
<UserDataBox>
<UserNameBox>{user.mainProfile.name}</UserNameBox>
<AvatarBox>
<Avatar avatar={user.mainProfile.avatar} />
</AvatarBox>
<UserCaratBox>
<Icon type="caret-down" />
</UserCaratBox>
</UserDataBox>
</Menu>
<ModalFull isOpen={router.query.profile === '1'}>
<Profile onClose={() => changeURLParams({ remove: ['profile'] })} />
</ModalFull>
</Box>
);
}
}
export default withRouter(UserBlockWithoutRouter);