-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
112 changed files
with
7,172 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import * as React from "react"; | ||
import { Dropzone, DropzoneArea } from "../../../mega-dropzone-ui/components/dropzone"; | ||
import { FileValidated } from "../../../mega-dropzone-ui/utils/file-validation/validation.types"; | ||
import { makeFileList } from "../makeFilelList"; | ||
|
||
const DropzoneAreaDemo = (props: any) => { | ||
const [filesValidated, setFilesValidated] = React.useState<FileValidated[]>([]); | ||
const handleChange = async(fileValidatedList: FileValidated[]) => { | ||
setFilesValidated(fileValidatedList); | ||
const myFileArray: File[] = fileValidatedList.map( | ||
(f: FileValidated) => f.file | ||
); | ||
//let otherFiles: FileList = new FileList(); | ||
//makeFileList(myFileArray) | ||
let myFileList: FileList = await makeFileList(myFileArray); | ||
console.log("FileList from Array of Files", myFileList); | ||
}; | ||
// .... more code | ||
|
||
return ( | ||
<div> | ||
<DropzoneArea value={filesValidated} onChange={handleChange}> | ||
Drag'drop files | ||
</DropzoneArea> | ||
<Dropzone> | ||
Dropzone | ||
</Dropzone> | ||
<ul> | ||
{filesValidated.map((f: FileValidated) => ( | ||
<li key={f.id}>{`${f.file.name} - ${f.valid}`}</li> | ||
))} | ||
</ul> | ||
</div> | ||
); | ||
}; | ||
export default DropzoneAreaDemo; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
export const makeFileList = (myFileArray) => { | ||
return new Promise((resolve, reject) => { | ||
const input = document.createElement("input"); | ||
input.style.display="none"; | ||
const label = document.createElement("label"); | ||
label.style.display="none"; | ||
const text = document.createTextNode("click to set files\n"); | ||
const form = document.createElement("form"); | ||
const data = myFileArray; | ||
// https://github.com/w3c/clipboard-apis/issues/33 | ||
class _DataTransfer { | ||
constructor() { | ||
return new ClipboardEvent("").clipboardData || new DataTransfer(); | ||
} | ||
} | ||
input.type = "file"; | ||
input.name = "files[]"; | ||
input.multiple = true; | ||
input.id = "files"; | ||
text.textContent = text.textContent.concat( | ||
data.map(({ name }) => name).join(", "), | ||
"\n" | ||
); | ||
|
||
label.appendChild(text); | ||
form.appendChild(label); | ||
form.appendChild(input); | ||
document.body.appendChild(form); | ||
// https://github.com/whatwg/html/issues/3222 | ||
// https://bugzilla.mozilla.org/show_bug.cgi?id=1416488 | ||
label.onclick = (e) => { | ||
const dt = new _DataTransfer(); | ||
for (let file of data) { | ||
dt.items.add(file); | ||
} | ||
if (dt.files.length) { | ||
input.files = dt.files; | ||
} | ||
const fd = new FormData(form); | ||
for (const file of input.files) { | ||
//console.log(file); // `File` objects set at `data` | ||
} | ||
for (const [key, prop] of fd) { | ||
// console.log(key, prop); | ||
} | ||
//console.log(input.files); | ||
resolve(input.files); | ||
}; | ||
// not dispatched at Firefox 57 when set using `input.files = dt.files` | ||
input.onchange = (e) => { | ||
console.log("onchange", e, input.files); | ||
//resolve("onchange", input.files); | ||
}; | ||
label.click(); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
export const makeFileList = (myFileArray) => { | ||
return new Promise((resolve, reject) => { | ||
const input = document.createElement("input"); | ||
input.style.display="none"; | ||
const label = document.createElement("label"); | ||
label.style.display="none"; | ||
const text = document.createTextNode("click to set files\n"); | ||
const form = document.createElement("form"); | ||
const data = myFileArray; | ||
// https://github.com/w3c/clipboard-apis/issues/33 | ||
class _DataTransfer { | ||
constructor() { | ||
return new ClipboardEvent("").clipboardData || new DataTransfer(); | ||
} | ||
} | ||
input.type = "file"; | ||
input.name = "files[]"; | ||
input.multiple = true; | ||
input.id = "files"; | ||
text.textContent = text.textContent.concat( | ||
data.map(({ name }) => name).join(", "), | ||
"\n" | ||
); | ||
|
||
label.appendChild(text); | ||
form.appendChild(label); | ||
form.appendChild(input); | ||
document.body.appendChild(form); | ||
// https://github.com/whatwg/html/issues/3222 | ||
// https://bugzilla.mozilla.org/show_bug.cgi?id=1416488 | ||
label.onclick = (e) => { | ||
const dt = new _DataTransfer(); | ||
for (let file of data) { | ||
dt.items.add(file); | ||
} | ||
if (dt.files.length) { | ||
input.files = dt.files; | ||
} | ||
const fd = new FormData(form); | ||
for (const file of input.files) { | ||
//console.log(file); // `File` objects set at `data` | ||
} | ||
for (const [key, prop] of fd) { | ||
// console.log(key, prop); | ||
} | ||
//console.log(input.files); | ||
resolve(input.files); | ||
}; | ||
// not dispatched at Firefox 57 when set using `input.files = dt.files` | ||
input.onchange = (e) => { | ||
console.log("onchange", e, input.files); | ||
//resolve("onchange", input.files); | ||
}; | ||
label.click(); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
140 changes: 140 additions & 0 deletions
140
src/dropzone-ui/components/dropzone/components/Dropzone/Dropzone.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
@import url("https://fonts.googleapis.com/css2?family=Roboto&display=swap"); | ||
@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@200&display=swap"); | ||
@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@400&display=swap"); | ||
|
||
.dropzone-ui { | ||
.dropzone-ui-ripple { | ||
position: absolute; | ||
width: 0%; | ||
height: 0%; | ||
//background-color: aqua; | ||
top: 0; | ||
left: 0; | ||
overflow: hidden; | ||
//padding-left: 15px; | ||
//z-index: -1; | ||
span.ripple { | ||
// width: 100%; | ||
//height: 100%; | ||
// overflow: hidden; | ||
position: absolute; | ||
border-radius: 50%; | ||
transform: scale(0); | ||
animation: ripple 500ms linear; | ||
background-color: rgba(255, 255, 255, 0.7); | ||
} | ||
|
||
@keyframes ripple { | ||
to { | ||
transform: scale(4); | ||
opacity: 0; | ||
} | ||
} | ||
} | ||
color: #646c7f; | ||
position: relative; | ||
min-height: 280px; | ||
border-radius: 4px; | ||
//margin: 4%; | ||
//width: calc(100% - 4px); | ||
width: calc(100% - 2px); | ||
//width: 100%; | ||
//min-width: 500px; | ||
background-color: white; | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
justify-content: center; | ||
//overflow: hidden; | ||
// padding: 24px 0; | ||
&.drag { | ||
border: none; | ||
} | ||
&.clickable { | ||
cursor: pointer; | ||
} | ||
/* span.ripple { | ||
// width: 100%; | ||
//height: 100%; | ||
// overflow: hidden; | ||
position: absolute; | ||
border-radius: 50%; | ||
transform: scale(0); | ||
animation: ripple 500ms linear; | ||
background-color: rgba(255, 255, 255, 0.7); | ||
} | ||
@keyframes ripple { | ||
to { | ||
transform: scale(4); | ||
opacity: 0; | ||
} | ||
} */ | ||
|
||
//verflow: hidden; | ||
.dz-ui-header { | ||
height: 22px; | ||
|
||
position: absolute; | ||
cursor: text; | ||
top: 0; | ||
display: flex; | ||
width: calc(100% - 10px); | ||
flex-direction: row; | ||
align-items: center; | ||
justify-content: flex-end; | ||
//height: 30px; | ||
//font-weight: 300; | ||
font-family: "Poppins", sans-serif; | ||
padding-right: 10px; | ||
//border-bottom: 1px dotted #646c7f; | ||
font-size: 0.9em; | ||
} | ||
.dz-ui-footer { | ||
//margin-left: 5px; | ||
height: 23px; | ||
position: absolute; | ||
cursor: text; | ||
bottom: 0; | ||
width: calc(100% - 10px); | ||
display: flex; | ||
flex-direction: column; | ||
align-items: flex-start; | ||
justify-content: center; | ||
border-top: 1px dotted grey; | ||
background-color: #80808021; | ||
//height: 30px; | ||
font-family: "Poppins", sans-serif; | ||
padding-left: 10px; | ||
font-size: 1em; | ||
} | ||
} | ||
|
||
.dropzone-ui-layer { | ||
width: 0%; | ||
height: 0%; | ||
z-index: 20; | ||
&.drag { | ||
position: absolute; | ||
left: 0; | ||
top: 0; | ||
//width: calc(100% - 4px); | ||
//height: calc(100% - 4px); | ||
width: 100%; | ||
height: 100%; | ||
} | ||
} | ||
.dz-ui-label { | ||
text-rendering: optimizeLegibility; | ||
font-size: 1.5em; | ||
font-family: "Poppins", sans-serif; | ||
text-align: center; | ||
font-weight: 500; | ||
letter-spacing: 0.02857em; | ||
@media (max-width: 600px) { | ||
font-size: 1.3em; | ||
} | ||
word-break: normal; | ||
//font-family: "Poppins", sans-serif; | ||
//font-weight: 600; | ||
} |
Oops, something went wrong.