Mailspring/internal_packages/message-list/lib/thread-trash-button.cjsx
Ben Gotow f63b7e66e4 feat(swipe-to-*): Gesture support and animation in thread list
Summary:
This diff does two things:
- It adds a new SwipeContainer that makes it easy to implement swipe gestures. This is built into listTabular, so you can create a list and define onSwipeLeft/Right to enable gestures.

- It adds support for basic add/remove animations to the thread list. This works by adding a CSS transition to `top` and also leaving removed rows around for a specified time. (these times need to match.) Pretty much just cloned the core idea from TimeoutTransitionGroup.

Test Plan: No tests yet

Reviewers: evan, juan

Reviewed By: evan

Differential Revision: https://phab.nylas.com/D2581
2016-02-19 18:22:28 -08:00

38 lines
1 KiB
CoffeeScript

_ = require 'underscore'
React = require 'react'
{Actions,
DOMUtils,
TaskFactory,
FocusedPerspectiveStore} = require 'nylas-exports'
{RetinaImg} = require 'nylas-component-kit'
class ThreadTrashButton extends React.Component
@displayName: "ThreadTrashButton"
@containerRequired: false
@propTypes:
thread: React.PropTypes.object.isRequired
render: =>
focusedMailboxPerspective = FocusedPerspectiveStore.current()
return false unless focusedMailboxPerspective.canTrashThreads()
<button className="btn btn-toolbar"
style={order: -106}
title="Move to Trash"
onClick={@_onRemove}>
<RetinaImg name="toolbar-trash.png" mode={RetinaImg.Mode.ContentIsMask}/>
</button>
_onRemove: (e) =>
return unless DOMUtils.nodeIsVisible(e.currentTarget)
tasks = TaskFactory.tasksForMovingToTrash
threads: [@props.thread],
fromPerspective: FocusedPerspectiveStore.current()
Actions.queueTasks(tasks)
Actions.popSheet()
e.stopPropagation()
module.exports = ThreadTrashButton