FileItemProgress.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536
  1. const { h } = require('preact')
  2. // http://codepen.io/Harkko/pen/rVxvNM
  3. // https://css-tricks.com/svg-line-animation-works/
  4. // https://gist.github.com/eswak/ad4ea57bcd5ff7aa5d42
  5. // circle length equals 2 * PI * R
  6. const circleLength = 2 * Math.PI * 15
  7. // stroke-dashoffset is a percentage of the progress from circleLength,
  8. // substracted from circleLength, because its an offset
  9. module.exports = (props) => {
  10. return (
  11. <svg width="70" height="70" viewBox="0 0 36 36" class="UppyIcon UppyIcon-progressCircle">
  12. <g class="progress-group">
  13. <circle class="bg" r="15" cx="18" cy="18" stroke-width="2" fill="none" />
  14. <circle class="progress" r="15" cx="18" cy="18" transform="rotate(-90, 18, 18)" stroke-width="2" fill="none"
  15. stroke-dasharray={circleLength}
  16. stroke-dashoffset={circleLength - (circleLength / 100 * props.progress)}
  17. />
  18. </g>
  19. {!props.hidePauseResumeCancelButtons ? (
  20. <g>
  21. <polygon class="play" transform="translate(3, 3)" points="12 20 12 10 20 15" />
  22. <g class="pause" transform="translate(14.5, 13)">
  23. <rect x="0" y="0" width="2" height="10" rx="0" />
  24. <rect x="5" y="0" width="2" height="10" rx="0" />
  25. </g>
  26. <polygon class="cancel" transform="translate(2, 2)" points="19.8856516 11.0625 16 14.9481516 12.1019737 11.0625 11.0625 12.1143484 14.9481516 16 11.0625 19.8980263 12.1019737 20.9375 16 17.0518484 19.8856516 20.9375 20.9375 19.8980263 17.0518484 16 20.9375 12" />
  27. </g>
  28. ) : null
  29. }
  30. <polygon class="check" transform="translate(2, 3)" points="14 22.5 7 15.2457065 8.99985857 13.1732815 14 18.3547104 22.9729883 9 25 11.1005634" />
  31. </svg>
  32. )
  33. }