Conversation
ericawright
left a comment
There was a problem hiding this comment.
The delete popup could use some more styling work - you could add it to a separate PR if you wanted. "delete" and "nevermind" both look like the same button. Need:
- a noticeable hover effect on each
- click away from the popup and it closes
frontend/src/upload.js
Outdated
| btn.addEventListener('click', e => { | ||
|
|
||
| // delete file | ||
| console.log($popupText.first()); |
There was a problem hiding this comment.
nit: remove the console.logs
frontend/src/upload.js
Outdated
| localStorage.getItem(info.fileId) | ||
| ).then(() => { | ||
| e.target.parentNode.parentNode.remove(); | ||
| e.target.parentNode.parentNode.parentNode.parentNode.remove(); |
There was a problem hiding this comment.
With jQuery you could try $(e.target).parents('tr')
with vanilla JS e.target.closest('tr')
frontend/src/upload.js
Outdated
| // hide popup | ||
| $popupText.find('.nvm').click(e => { | ||
| $popupText.toggleClass('show'); | ||
| }); |
There was a problem hiding this comment.
these two have the same fn after the click event, perhaps we name the fn and reuse it?
views/index.handlebars
Outdated
| <th width=7%>Delete</th> | ||
| </tr> | ||
| <div data-role="popup" id="popupArrow" data-arrow="true"> | ||
| <!-- <div class="popup"> |
There was a problem hiding this comment.
nit: remove commented code
frontend/src/upload.js
Outdated
| } else { | ||
| file = event.target.files[0]; | ||
| } | ||
| let fileList = $('#uploaded-files'); |
There was a problem hiding this comment.
nit $ in front to follow jquery convention
| z-index: 1; | ||
| bottom: 125%; | ||
| left: 50%; | ||
| margin-left: -80px; |
There was a problem hiding this comment.
do you need both left and margin-left here?
public/main.css
Outdated
| /* Toggle this class when clicking on the popup container (hide and show the popup) */ | ||
| .popup .show { | ||
| visibility: visible; | ||
| -webkit-animation: fadeIn 1s; |
There was a problem hiding this comment.
shouldn't need -webkit, it's old syntax
Can we change this to a transition, my understanding is that it is more efficient than a keyframes animation.
| event.preventDefault(); | ||
| let file = ''; | ||
| if (event.type == 'drop') { | ||
| file = event.dataTransfer.files[0]; |
There was a problem hiding this comment.
Does this work if I drop multiple files on the drop target from Finder? Or will it only handle the first image?
There was a problem hiding this comment.
Good question. If it doesn't we can follow up with a solution in another PR
There was a problem hiding this comment.
Spoiler alert: It doesn't.
But it looks like we can do Array.from().forEach() (or just a regular for loop) on the FileList as a workaround. But that exposes another dull edge case where you're dragging 2-3 files onto the app and it returns you a single share URL that you can copy to your clipboard.
window.onUpload = event => {
event.preventDefault();
let fileList = $('#uploaded-files');
let files = [];
if (event.type === 'drop') {
files = event.dataTransfer.files;
} else {
files = event.target.files;
}
Array.from(files).forEach(file => { ... });
dannycoates
left a comment
There was a problem hiding this comment.
I've got no additional changes
| .then(err => { | ||
| if (!err) { | ||
| console.log('Deleted.'); | ||
| res.sendStatus(200); |
| event.preventDefault(); | ||
| let file = ''; | ||
| if (event.type == 'drop') { | ||
| file = event.dataTransfer.files[0]; |
There was a problem hiding this comment.
Good question. If it doesn't we can follow up with a solution in another PR
frontend/src/upload.js
Outdated
| toggleShow(); | ||
| }); | ||
| // hide popup | ||
| $popupText.find('.nvm').click(e => { |
There was a problem hiding this comment.
btn.addEventListener('click', toggleShow);
$popupText.find('.nvm').click(toggleShow);
|
just the one more nit and then I think we're good to merge :) |
Added drag & drop as well as a delete file confirmation.
Closes #61