Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
jami-jams
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
savoirfairelinux
jami-jams
Commits
1949c66e
Commit
1949c66e
authored
1 year ago
by
Léo Banno-Cloutier
Committed by
Sébastien Blin
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
jams-react-client: add CustomImgDropZone component
Change-Id: I215dfec7237746fcbcd28aeabecabc5e8701565d
parent
ad9a9fc9
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
jams-react-client/src/components/CustomImgDropZone/CustomImgDropZone.js
+80
-0
80 additions, 0 deletions
...ent/src/components/CustomImgDropZone/CustomImgDropZone.js
with
80 additions
and
0 deletions
jams-react-client/src/components/CustomImgDropZone/CustomImgDropZone.js
0 → 100644
+
80
−
0
View file @
1949c66e
import
React
from
"
react
"
;
import
{
makeStyles
}
from
"
@material-ui/core/styles
"
;
import
Dropzone
from
"
react-dropzone
"
;
import
UploadIcon
from
"
@material-ui/icons/CloudUpload
"
;
import
CloseIcon
from
"
@material-ui/icons/Close
"
;
const
useStyles
=
makeStyles
({
dropzoneStyle
:
{
display
:
"
flex
"
,
flexDirection
:
"
row
"
,
alignItems
:
"
center
"
,
justifyContent
:
"
center
"
,
padding
:
"
20px
"
,
background
:
"
#0000001A 0% 0% no-repeat padding-box
"
,
borderRadius
:
"
5px
"
,
opacity
:
"
1
"
,
outline
:
"
none
"
,
transition
:
"
border .24s ease-in-out
"
,
cursor
:
"
pointer
"
,
border
:
"
none
"
,
height
:
"
10px
"
,
width
:
"
max-content
"
,
},
uploadIconStyle
:
{
fontSize
:
"
35px
"
,
marginBottom
:
"
10px
"
,
marginRight
:
"
10px
"
,
},
deleteButton
:
{
backgroundColor
:
"
transparent
"
,
border
:
"
none
"
,
},
});
function
CustomImgDropZone
(
props
)
{
const
{
onDrop
,
accept
,
maxFiles
,
label
,
file
,
handleDelete
,
...
rest
}
=
props
;
const
classes
=
useStyles
();
const
handleDrop
=
(
acceptedFiles
)
=>
{
if
(
acceptedFiles
.
length
>
0
)
{
onDrop
(
acceptedFiles
);
}
};
return
(
<
Dropzone
onDrop
=
{
handleDrop
}
accept
=
{
accept
}
maxFiles
=
{
maxFiles
}
{...
rest
}
>
{({
getRootProps
,
getInputProps
})
=>
(
<
div
{...
getRootProps
()}
className
=
{
classes
.
dropzoneStyle
}
>
<
input
{...
getInputProps
()}
/
>
<
UploadIcon
className
=
{
classes
.
uploadIconStyle
}
/
>
{
file
?
(
<>
<
span
>
{
file
}
<
/span
>
<
button
onClick
=
{
handleDelete
}
className
=
{
classes
.
deleteButton
}
>
<
CloseIcon
style
=
{{
color
:
"
red
"
}}
/
>
<
/button
>
<
/
>
)
:
(
<
span
>
{
label
}
<
/span
>
)}
<
/div
>
)}
<
/Dropzone
>
);
}
CustomImgDropZone
.
defaultProps
=
{
accept
:
{
"
image/*
"
:
[
"
.png
"
,
"
.jpeg
"
,
"
.jpg
"
]
},
maxFiles
:
1
,
};
export
default
CustomImgDropZone
;
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment