Skip to content

Commit

Permalink
adjusted json scripts & server start messages
Browse files Browse the repository at this point in the history
  • Loading branch information
lainercoder committed Dec 19, 2019
1 parent 9488408 commit 01b2a42
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 173 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ typings/

# dotenv environment variables file
.env
.env.prod
.env.test

# parcel-bundler cache (https://parceljs.org/)
Expand Down
78 changes: 40 additions & 38 deletions client/components/Questions/AddModal/ImageUpload.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,46 +3,48 @@ import React, { useState } from 'react';
import ThumbnailGallery from '../ThumbnailGallery';

const ImageUpload = ({ updatePhotos }) => {
const [imagePreviews, setImagePreviews] = useState([]);
const [error, setError] = useState('');
const uploadImage = event => {
const files = Array.from(event.target.files);
if (!files) {
setError('Please select at least 1 image.');
} else if (files.length > 5) {
setError('Please choose only 5 images!');
} else {
const formData = new FormData();
files.forEach((file, i) => {
formData.append(i, file);
});
axios
.post('/img', formData)
.then(res => {
updatePhotos(res.data);
setImagePreviews(res.data);
setError('');
})
.catch(() => setError('An error occurred. Please try again.'));
}
};
const [imagePreviews, setImagePreviews] = useState([]);
const [error, setError] = useState('');
const uploadImage = event => {
const files = Array.from(event.target.files);
if (!files) {
setError('Please select at least 1 image.');
} else if (files.length > 5) {
setError('Please choose only 5 images!');
} else {
const formData = new FormData();
files.forEach((file, i) => {
formData.append(i, file);
});
axios
.post('/img', formData)
.then(res => {
updatePhotos(res.data);
setImagePreviews(res.data);
setError('');
})
.catch(() => setError('An error occurred. Please try again.'));
}
};

return (
<>
<label htmlFor="images">
Please upload up to 5 images of your product
return (
<>
<label htmlFor="images">
Please upload up to 5 images of your product
</label>
<input
id="file"
name="file"
type="file"
onChange={uploadImage}
multiple
/>
<ThumbnailGallery imageURLs={imagePreviews} />
{error !== '' ? <div className="form-error">{error}</div> : <></>}
</>
);
<input
id="file"
name="file"
type="file"
onChange={uploadImage}
multiple
/>
<ThumbnailGallery imageURLs={imagePreviews} />


{error !== '' ? <div className="form-error">{error}</div> : <></>}
</>
);
};

export default ImageUpload;
156 changes: 28 additions & 128 deletions dist/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -10,87 +10,7 @@
|/ \__/(_______/\_______)(_______/ )_( \_______)
*/

html,
body,
div,
span,
applet,
object,
iframe,
h1,
h2,
h3,
h4,
h5,
h6,
p,
blockquote,
pre,
a,
abbr,
acronym,
address,
big,
cite,
code,
del,
dfn,
em,
img,
ins,
kbd,
q,
s,
samp,
small,
strike,
strong,
sub,
sup,
tt,
var,
b,
u,
i,
center,
dl,
dt,
dd,
fieldset,
form,
label,
legend,
table,
caption,
tbody,
tfoot,
thead,
tr,
th,
td,
article,
aside,
canvas,
details,
embed,
figure,
figcaption,
footer,
header,
hgroup,
menu,
nav,
output,
ruby,
section,
summary,
time,
mark,
audio,
video,
input,
button,
span {
html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, canvas, details, embed, figure, figcaption, footer, header, hgroup, menu, nav, output, ruby, section, summary, time, mark, audio, video, input, button, span {
margin: 0;
padding: 0;
border: 0;
Expand All @@ -100,17 +20,7 @@ span {
font-family: 'Open Sans', sans-serif;
}

article,
aside,
details,
figcaption,
figure,
footer,
header,
hgroup,
menu,
nav,
section {
article, aside, details, figcaption, figure, footer, header, hgroup, menu, nav, section {
display: block;
}

Expand All @@ -119,20 +29,15 @@ body {
font-size: 1rem;
}

ol,
ul {
ol, ul {
list-style: none;
}

blockquote,
q {
blockquote, q {
quotes: none;
}

blockquote:before,
blockquote:after,
q:before,
q:after {
blockquote:before, blockquote:after, q:before, q:after {
content: '';
content: none;
}
Expand All @@ -159,8 +64,7 @@ a:focus {
text-decoration: none;
}

a:hover,
a:active {
a:hover, a:active {
text-decoration: none;
}

Expand Down Expand Up @@ -269,10 +173,17 @@ strong {

.thumbnail {
margin-right: 10px;
height: 15em;
height: 3em;
width: auto;
}

.upload-previews {
max-width: 50vw;
max-height: 10vh;
overflow-x: scroll;
overflow-y: hidden;
}

/*
_______ _______ _______ _______ _______
( ____ \( ___ )( ____ )( )( ____ \
Expand All @@ -295,11 +206,7 @@ label {
display: flex;
}

input[type='email'],
input[type='text'],
input[type='number'],
textarea,
select {
input[type='email'], input[type='text'], input[type='number'], textarea, select {
border: var(--color) 1px solid;
padding: 0.5em;
}
Expand Down Expand Up @@ -404,8 +311,7 @@ select {
margin: 5px 10px 10px 10px;
}

#left-description,
#right-description {
#left-description, #right-description {
text-align: left;
}

Expand Down Expand Up @@ -624,8 +530,7 @@ select {
position: relative;
}

#expanded-left,
#expanded-right {
#expanded-left, #expanded-right {
position: absolute;
top: 50%;
}
Expand Down Expand Up @@ -801,19 +706,19 @@ select {
margin: 10px 0px 0px 0px;
}

.answers > span > #first {
.answers>span>#first {
margin: 1em 0px;
}

.answers > span > #more {
.answers>span>#more {
margin: 2em 0px 0.7em 15px;
}

.answers > span > #answerer {
.answers>span>#answerer {
margin-left: 15px;
}

.answers > #load-more {
.answers>#load-more {
margin-top: 1.2em;
margin-left: 15px;
font-size: 0.8em;
Expand All @@ -827,8 +732,7 @@ select {
height: 50px;
}

#add-question-form > input,
#add-question-form > textarea {
#add-question-form>input, #add-question-form>textarea {
width: 400px;
}

Expand All @@ -853,14 +757,11 @@ img.uploadIcon {
*/

#size-rating-container,
#comfort-rating-container,
#star-stats-container {
#size-rating-container, #comfort-rating-container, #star-stats-container {
margin: 10px 5px 5px 10px;
}

#review-list-container,
#review-stats-container {
#review-list-container, #review-stats-container {
margin: 10px 5px 5px 10px;
}

Expand Down Expand Up @@ -1091,8 +992,7 @@ img.uploadIcon {
color: red;
}

#add-review-form > input,
#add-review-form > textarea {
#add-review-form>input, #add-review-form>textarea {
width: 400px;
}

Expand All @@ -1102,7 +1002,7 @@ img.uploadIcon {
align-items: center;
}

#sort-menu > select {
#sort-menu>select {
margin-left: 1%;
border: none;
background-color: white;
Expand All @@ -1111,11 +1011,11 @@ img.uploadIcon {
border-radius: 0;
}

#sort-menu > select:focus {
#sort-menu>select:focus {
outline: none;
}

.underline-clickable {
text-decoration: underline;
cursor: pointer;
}
}
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
"verbose": true
},
"scripts": {
"test": "jest",
"test_coverage": "jest --coverage",
"test_start": "node server/index.js && jest",
"start": "nodemon server/index.js",
"build": "webpack --mode=production",
"test": "node server/index.js && jest",
"start": "node server",
"build-dev": "webpack -d --watch",
"build-prod": "webpack --mode=production"
"test-coverage": "jest --coverage",
"start-dev": "nodemon server/index.js"
},
"repository": {
"type": "git",
Expand Down Expand Up @@ -76,4 +76,4 @@
"webpack": "^4.41.2",
"webpack-cli": "^3.3.10"
}
}
}
Loading

0 comments on commit 01b2a42

Please sign in to comment.