Skip to content
This repository was archived by the owner on May 22, 2021. It is now read-only.

Drag & drop#71

Merged
dnarcese merged 8 commits intomasterfrom
ui
Jun 9, 2017
Merged

Drag & drop#71
dnarcese merged 8 commits intomasterfrom
ui

Conversation

@dnarcese
Copy link
Copy Markdown
Contributor

@dnarcese dnarcese commented Jun 8, 2017

Added drag & drop as well as a delete file confirmation.

Closes #61

Copy link
Copy Markdown
Contributor

@ericawright ericawright left a comment

Choose a reason for hiding this comment

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

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

btn.addEventListener('click', e => {

// delete file
console.log($popupText.first());
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: remove the console.logs

localStorage.getItem(info.fileId)
).then(() => {
e.target.parentNode.parentNode.remove();
e.target.parentNode.parentNode.parentNode.parentNode.remove();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

With jQuery you could try $(e.target).parents('tr')
with vanilla JS e.target.closest('tr')

// hide popup
$popupText.find('.nvm').click(e => {
$popupText.toggleClass('show');
});
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

these two have the same fn after the click event, perhaps we name the fn and reuse it?

<th width=7%>Delete</th>
</tr>
<div data-role="popup" id="popupArrow" data-arrow="true">
<!-- <div class="popup">
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: remove commented code

} else {
file = event.target.files[0];
}
let fileList = $('#uploaded-files');
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit $ in front to follow jquery convention

z-index: 1;
bottom: 125%;
left: 50%;
margin-left: -80px;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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];
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Does this work if I drop multiple files on the drop target from Finder? Or will it only handle the first image?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Good question. If it doesn't we can follow up with a solution in another PR

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 => { ... });

Copy link
Copy Markdown
Contributor

@dannycoates dannycoates left a comment

Choose a reason for hiding this comment

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

I've got no additional changes

.then(err => {
if (!err) {
console.log('Deleted.');
res.sendStatus(200);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nice catch :)

event.preventDefault();
let file = '';
if (event.type == 'drop') {
file = event.dataTransfer.files[0];
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Good question. If it doesn't we can follow up with a solution in another PR

toggleShow();
});
// hide popup
$popupText.find('.nvm').click(e => {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

  btn.addEventListener('click', toggleShow);

  $popupText.find('.nvm').click(toggleShow);

@ericawright
Copy link
Copy Markdown
Contributor

just the one more nit and then I think we're good to merge :)

@dnarcese dnarcese merged commit e077160 into master Jun 9, 2017
@pdehaan pdehaan mentioned this pull request Jun 9, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants