Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Add option to upload background image #15

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

diveresque
Copy link
Contributor

Using react-dropzone and FileReader to allow user to upload image from computer onto background-image of the banner #5

Using react-dropzone and FileReader to allow user to upload image from computer onto background-image of the banner christopherkade#5
@diveresque
Copy link
Contributor Author

Hi @christopherkade have done the basics for upload images, needs a bit of tweaking, but thought its good to get some feedback at this point.

Also the checks didnt work as you can see - the error says to run yarn add react-dropzone, is that correct?

@christopherkade
Copy link
Owner

christopherkade commented Aug 4, 2019

This is awesome work, I've been fiddling around with it and you did a great job.
Make sure to remove package-lock.json, we already have a yarn.lock 😄

I've done a code review, most of these changes are tiny so don't worry if you see so many comments !

christopherkade added a commit that referenced this pull request Aug 4, 2019
Add react-dropzone dep, removed unused props #15
padding: 20px;
`

const ImageInput = ({ image, setImage }) => {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The image prop is unused

const ImageInput = ({ image, setImage }) => {
const onDrop = useCallback(acceptedFiles => {
const file = acceptedFiles[0]
let reader = new FileReader();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indentation + declare reader as a constant

<>
<InputBlock>
<div {...getRootProps({className: 'dropzone'})}>
<input {...getInputProps()} />
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indentation (you can activate automatic formatting in VS Code in your settings, that will normally apply our eslint formatting to your whole file on each save)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the tip :) I havent been using VS Code but am trying it now - I added the Eslint plugin and checked 'Turns auto fix on save on or off' in settings, but it doesnt seem to fix the formatting on save - have I missed something?

<InputBlock>
<div {...getRootProps({className: 'dropzone'})}>
<input {...getInputProps()} />
<p>Drag 'n' drop some files here, or click to select files</p>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think of Chose a file or drag it here ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes sounds better

@@ -35,8 +37,8 @@ const Summary = styled.summary`
`

const InputWrapper = ({ values, setters }) => {
const { bgColor, title, titleSize, titleColor, borderColor, borderSize } = values
const { setBgColor, setTitle, setTitleSize, setTitleColor, setBorderColor, setBorderSize } = setters
const { bgColor, title, titleSize, titleColor, borderColor, borderSize, image } = values
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused image variable

@@ -56,6 +58,10 @@ const InputWrapper = ({ values, setters }) => {
<Summary>Sizes</Summary>
<SizeInput titleSize={titleSize} borderSize={borderSize} setTitleSize={setTitleSize} setBorderSize={setBorderSize} />
</Detail>
<Detail>
<Summary>Background Image</Summary>
<ImageInput image={image} setImage={setImage}/>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since image is not used in this component, remove it as a prop

@@ -13,6 +13,7 @@ const Wrapper = styled.div`
border: 1px solid #dbdbdb;
border: ${(props) => `${props.borderSize}px solid ${props.borderColor}`};
box-sizing: border-box;
background-image: url(${(props) => props.image});
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think of adding:

background-repeat: no-repeat;
background-size: cover;

?

@diveresque
Copy link
Contributor Author

Thanks for the feedback, I am going through these. Im happy about the many comments, its good to learn! :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants