Skip to content

Commit 5591a2a

Browse files
Merge pull request #48 from EOS-uiux-Solutions/reply-file-upload
Added basic file upload for comment and comment Replies
2 parents 3a6fc5e + aaba223 commit 5591a2a

File tree

16 files changed

+348
-208
lines changed

16 files changed

+348
-208
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
.comment {
2+
&-form {
3+
margin: 16px 0px;
4+
}
5+
6+
&-input {
7+
align-items: flex-end;
8+
display: flex;
9+
margin-bottom: 5px;
10+
width: fit-content;
11+
12+
textarea {
13+
border: 0;
14+
box-shadow: 0 0 2px 0 $dark-color inset;
15+
resize: none;
16+
}
17+
}
18+
}
19+
20+
.file {
21+
height: 0.1px;
22+
opacity: 0;
23+
position: absolute;
24+
width: 0.1px;
25+
26+
&-input {
27+
background: $eos-white;
28+
border: 1px solid $light-gray;
29+
border-left: 0;
30+
display: flex;
31+
flex-direction: column-reverse;
32+
height: 82px;
33+
}
34+
35+
&-button-label {
36+
border-top: 0.2px solid $light-gray;
37+
display: block;
38+
height: 24px;
39+
position: relative;
40+
text-align: center;
41+
width: 35px;
42+
}
43+
44+
&-button-label:hover {
45+
cursor: pointer;
46+
}
47+
}

src/assets/scss/components/comments.scss

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,3 @@
2626
}
2727
}
2828
}
29-
30-
.comment-form {
31-
margin: 16px 0px;
32-
33-
textarea {
34-
resize: none;
35-
}
36-
}

src/assets/scss/components/dragdrop.scss

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -20,34 +20,3 @@
2020
.dropzone:focus {
2121
border-color: $primary;
2222
}
23-
24-
.preview-root {
25-
border: 1px solid #eaeaea;
26-
border-radius: 2px;
27-
box-sizing: border-box;
28-
display: inline-flex;
29-
height: 150px;
30-
margin-bottom: 8px;
31-
margin-right: 8px;
32-
padding: 4px;
33-
width: 150px;
34-
}
35-
36-
.preview-inner {
37-
display: flex;
38-
min-width: 0px;
39-
overflow: hidden;
40-
}
41-
42-
.preview-image {
43-
display: block;
44-
height: 100%;
45-
width: auto;
46-
}
47-
48-
.preview-container {
49-
display: flex;
50-
flex-direction: row;
51-
flex-wrap: wrap;
52-
margin-top: 16px;
53-
}

src/assets/scss/components/index.scss

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@
66
@import 'dragdrop';
77
@import 'timeline';
88
@import 'storiesList';
9+
@import 'commentForm';
910
@import 'comments';
1011
@import 'pagination';
1112
@import 'modal';
13+
@import 'mediaPreview';
1214
@import 'formError';
1315
@import 'dropdownOptions';
1416
@import 'vote';
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
.preview {
2+
&-root {
3+
border: 1px solid #eaeaea;
4+
border-radius: 2px;
5+
box-sizing: border-box;
6+
display: inline-flex;
7+
height: 150px;
8+
margin-bottom: 8px;
9+
margin-right: 8px;
10+
padding: 4px;
11+
position: relative;
12+
width: 150px;
13+
}
14+
15+
&-inner {
16+
display: flex;
17+
min-width: 0px;
18+
overflow: hidden;
19+
}
20+
21+
&-image {
22+
display: block;
23+
height: 100%;
24+
width: auto;
25+
}
26+
27+
&-container {
28+
display: flex;
29+
flex-direction: row;
30+
flex-wrap: wrap;
31+
margin-top: 16px;
32+
}
33+
34+
&-remove-button {
35+
background: $dark-gray-transparent;
36+
border: 0;
37+
border-radius: 50%;
38+
color: $eos-white;
39+
font-weight: $font-weight-600;
40+
height: 18px;
41+
padding: 0;
42+
position: absolute;
43+
right: 4px;
44+
top: 4px;
45+
width: 18px;
46+
}
47+
48+
&-remove-button:hover {
49+
cursor: pointer;
50+
}
51+
}

src/assets/scss/pages/page404.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
color: $dark-color;
99
font-family: $font-family-spartan;
1010
font-size: $font-size-heading-404;
11-
font-weight: $font-weight-404;
11+
font-weight: $font-weight-600;
1212
margin-bottom: 0;
1313
padding-left: 0.5em;
1414
}

src/assets/scss/variables/colors.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ $light-blue: $eos-cerulean-500;
44
$dark-color: #1A2A3A;
55
$gray-bg: #eaeaea;
66
$light-gray: #777777;
7+
$dark-gray-transparent: rgba(71, 71, 71, 0.808);
78
$border-gray: #EDEFF0;
89
$light-green: #66DC71;
910
$alert: #E6001A;

src/assets/scss/variables/type.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ $font-size-header-mobile: 26px;
1212
$font-size-small: 12px;
1313
$font-size-cookies-mobile: 13px;
1414
$font-size-heading-404: 10em;
15-
$font-weight-404: 600;
15+
$font-weight-600: 600;
1616
$font-weight: 300;
1717
$line-height: 1.5em;
1818
$color: #141823;

src/components/CommentForm.js

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
import React from 'react'
2+
import { useForm } from 'react-hook-form'
3+
4+
import Button from './Button'
5+
import FormError from './FormError'
6+
import MediaPreview from './MediaPreview'
7+
8+
const CommentForm = (props) => {
9+
const {
10+
id,
11+
attachments,
12+
setAttachments,
13+
addComment,
14+
comment,
15+
setComment,
16+
cta
17+
} = props
18+
19+
const { register, errors, handleSubmit } = useForm()
20+
21+
const handleFileChange = async (event) => {
22+
const newFiles = event.target.files
23+
const newFilesArray = []
24+
for (let i = 0; i < newFiles.length; i++) {
25+
newFilesArray.push(
26+
Object.assign(newFiles[i], {
27+
preview: URL.createObjectURL(newFiles[i])
28+
})
29+
)
30+
}
31+
setAttachments([...attachments, ...newFilesArray])
32+
}
33+
34+
return (
35+
<form className='comment-form' onSubmit={handleSubmit(addComment)}>
36+
<div className='comment-input'>
37+
<textarea
38+
rows='5'
39+
cols='25'
40+
name='Comments'
41+
value={comment}
42+
ref={register({ required: true })}
43+
onChange={(e) => setComment(e.target.value)}
44+
></textarea>
45+
<div className='file-input'>
46+
<input
47+
type='file'
48+
id={`file-${id}`}
49+
className='file'
50+
multiple={true}
51+
onChange={handleFileChange}
52+
/>
53+
<label htmlFor={`file-${id}`} className='file-button-label'>
54+
<i className='eos-icons'>attachment</i>
55+
</label>
56+
</div>
57+
</div>
58+
{errors.Comments && <FormError message='Reply cannot be empty' />}
59+
<MediaPreview attachments={attachments} setAttachments={setAttachments} />
60+
<Button className='btn btn-default'>{cta}</Button>
61+
</form>
62+
)
63+
}
64+
65+
export default CommentForm

0 commit comments

Comments
 (0)