2015-06-12 02:52:49 +08:00
|
|
|
path = require 'path'
|
|
|
|
React = require 'react'
|
|
|
|
AttachmentComponent = require './attachment-component'
|
2015-06-16 09:48:17 +08:00
|
|
|
{Spinner, DraggableImg} = require 'nylas-component-kit'
|
2015-06-12 02:52:49 +08:00
|
|
|
|
|
|
|
class ImageAttachmentComponent extends AttachmentComponent
|
|
|
|
@displayName: 'ImageAttachmentComponent'
|
|
|
|
|
|
|
|
render: =>
|
2015-06-16 09:48:17 +08:00
|
|
|
<div className={"attachment-inner-wrap " + @props.download?.state ? ""}>
|
2015-06-12 02:52:49 +08:00
|
|
|
<span className="attachment-download-bar-wrap">
|
|
|
|
<span className="attachment-bar-bg"></span>
|
|
|
|
<span className="attachment-download-progress" style={@_downloadProgressStyle()}></span>
|
|
|
|
</span>
|
|
|
|
|
|
|
|
<span className="attachment-file-actions">
|
|
|
|
{@_fileActions()}
|
|
|
|
</span>
|
|
|
|
|
|
|
|
<div className="attachment-preview" onClick={@_onClickView}>
|
2015-06-16 09:48:17 +08:00
|
|
|
{@_imgOrLoader()}
|
2015-06-12 02:52:49 +08:00
|
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
2015-06-16 09:48:17 +08:00
|
|
|
_canAbortDownload: -> false
|
|
|
|
|
|
|
|
_imgOrLoader: ->
|
|
|
|
if @props.download
|
|
|
|
if @props.download.percent <= 5
|
|
|
|
<div style={width: "100%", height: "100px"}>
|
|
|
|
<Spinner visible={true} />
|
|
|
|
</div>
|
|
|
|
else
|
|
|
|
<DraggableImg src={"#{@props.targetPath}?percent=#{@props.download.percent}"} />
|
|
|
|
else
|
|
|
|
<DraggableImg src={@props.targetPath} />
|
|
|
|
|
2015-06-12 02:52:49 +08:00
|
|
|
module.exports = ImageAttachmentComponent
|