forked from codesandbox/codesandbox-client
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEditing.js
More file actions
110 lines (107 loc) · 2.7 KB
/
Editing.js
File metadata and controls
110 lines (107 loc) · 2.7 KB
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
import React, { useState } from 'react';
import { format } from 'date-fns';
import Input, { TextArea } from '@codesandbox/common/lib/components/Input';
import calendar from '../../assets/calendar.svg';
import mail from '../../assets/mail.svg';
import twitterLogo from '../../assets/twitter.svg';
import { Social } from './_sidebar.elements';
export default ({
children,
bio,
twitter,
profile_email,
inserted_at,
editing,
changeBio,
changeTwitter,
changeEmail,
}) => {
const [biography, setBiography] = useState(bio);
const [tw, setTw] = useState(twitter);
const [email, setEmail] = useState(profile_email);
return (
<>
{editing ? (
<TextArea
fullWidth
placeholder="This is where you tell us all about you"
value={biography}
onChange={e => {
changeBio(e.target.value);
setBiography(e.target.value);
}}
/>
) : (
<p
css={`
display: -webkit-box;
-webkit-line-clamp: 8;
-webkit-box-orient: vertical;
max-height: 12rem;
overflow: hidden;
`}
>
{biography}
</p>
)}
{children}
{editing && (
<Social>
<img src={twitterLogo} alt="twitter logo" />
<Input
placeholder="Your Twitter"
fullWidth
value={tw}
onChange={e => {
changeTwitter(e.target.value);
setTw(e.target.value);
}}
/>
</Social>
)}
{twitter && !editing && (
<Social>
<img src={twitterLogo} alt="twitter logo" />
<a
href={`https://twitter.com/${twitter}`}
target="_blank"
rel="noopener noreferrer"
>
@{twitter.toLowerCase()}
</a>
</Social>
)}
{editing && (
<Social>
<img src={mail} alt="email" />
<Input
fullWidth
placeholder="Your Public Email"
value={email}
type="email"
onChange={e => {
changeEmail(e.target.value);
setEmail(e.target.value);
}}
/>
</Social>
)}
{profile_email && !editing && (
<Social>
<img src={mail} alt="email" />
<a
href={`mailto:${profile_email}`}
target="_blank"
rel="noopener noreferrer"
>
{profile_email.toLowerCase()}
</a>
</Social>
)}
<Social>
<img src={calendar} alt="User Since" />
<span>Joined {format(inserted_at, 'MMMM YYYY')}</span>
</Social>
</>
);
};