MediaFolder.js
5 years ago
MediaItem.js
5 years ago
MediaPopup.js
3 years ago
MediaPopupTemplate.js
3 years ago
chunk-upload.js
5 years ago
styles.js
5 years ago
MediaItem.js
55 lines
| 1 | export default ({ item, onClick, className }) => { |
| 2 | function bytesToSize(bytes) { |
| 3 | var sizes = ["Bytes", "KB", "MB", "GB", "TB"]; |
| 4 | if (bytes == 0) return "0 Byte"; |
| 5 | var i = parseInt(Math.floor(Math.log(bytes) / Math.log(1024))); |
| 6 | return Math.round(bytes / Math.pow(1024, i), 2) + " " + sizes[i]; |
| 7 | } |
| 8 | |
| 9 | function formatDate(date) { |
| 10 | return new Date(date).toLocaleString(); |
| 11 | } |
| 12 | |
| 13 | const isEncoding = () => { |
| 14 | return !!item?.encodeProgress && item.encodeProgress !== 100; |
| 15 | }; |
| 16 | |
| 17 | return ( |
| 18 | <div |
| 19 | className={`presto-player__media-list-item ${className}`} |
| 20 | onClick={onClick} |
| 21 | > |
| 22 | <div className="presto-player__media-list-item-icon"> |
| 23 | <svg |
| 24 | xmlns="http://www.w3.org/2000/svg" |
| 25 | width="24" |
| 26 | height="24" |
| 27 | viewBox="0 0 24 24" |
| 28 | fill="none" |
| 29 | stroke="currentColor" |
| 30 | strokeWidth="2" |
| 31 | strokeLinecap="round" |
| 32 | strokeLinecap="round" |
| 33 | > |
| 34 | <polygon points="23 7 16 12 23 17 23 7"></polygon> |
| 35 | <rect x="1" y="5" width="15" height="14" rx="2" ry="2"></rect> |
| 36 | </svg> |
| 37 | </div> |
| 38 | <div className="presto-player__media-list-item-title">{item?.title}</div> |
| 39 | {isEncoding() && ( |
| 40 | <div className="presto-player__media-list-item-size">Encoding...</div> |
| 41 | )} |
| 42 | {!isEncoding() && ( |
| 43 | <div className="presto-player__media-list-item-size"> |
| 44 | {bytesToSize(item?.size)} |
| 45 | </div> |
| 46 | )} |
| 47 | {!isEncoding() && ( |
| 48 | <div className="presto-player__media-list-item-modified"> |
| 49 | {formatDate(item.updated_at)} |
| 50 | </div> |
| 51 | )} |
| 52 | </div> |
| 53 | ); |
| 54 | }; |
| 55 |