copyDialog.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. const html = require('choo/html');
  2. const { copyToClipboard } = require('../utils');
  3. module.exports = function(name, url) {
  4. const dialog = function(state, emit, close) {
  5. return html`
  6. <send-copy-dialog
  7. class="flex flex-col items-center text-center p-4 max-w-sm m-auto"
  8. >
  9. <h1 class="text-3xl font-bold my-4">
  10. ${state.translate('notifyUploadEncryptDone')}
  11. </h1>
  12. <p class="font-normal leading-normal text-grey-80 dark:text-grey-40">
  13. ${state.translate('copyLinkDescription')} <br />
  14. <span class="word-break-all">${name}</span>
  15. </p>
  16. <input
  17. type="text"
  18. id="share-url"
  19. class="w-full my-4 border rounded-lg leading-loose h-12 px-2 py-1 dark:bg-grey-80"
  20. value="${url}"
  21. readonly="true"
  22. />
  23. <button
  24. class="btn rounded-lg w-full flex-shrink-0 focus:outline"
  25. onclick="${copy}"
  26. title="${state.translate('copyLinkButton')}"
  27. >
  28. ${state.translate('copyLinkButton')}
  29. </button>
  30. <button
  31. class="link-blue my-4 font-medium cursor-pointer focus:outline"
  32. onclick="${close}"
  33. title="${state.translate('okButton')}"
  34. >
  35. ${state.translate('okButton')}
  36. </button>
  37. </send-copy-dialog>
  38. `;
  39. function copy(event) {
  40. event.stopPropagation();
  41. copyToClipboard(url);
  42. event.target.textContent = state.translate('copiedUrl');
  43. setTimeout(close, 1000);
  44. }
  45. };
  46. dialog.type = 'copy';
  47. return dialog;
  48. };