mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-11-14 21:57:55 +08:00
9d0ebe9423
- Rather than have a `showing` prop on the fixed popover, I just remove it and put a span in it's place when it's gone. This means we always get componentDidMount when the popover appears and simplifies when to focus it's content. - The fixed popover implements esc and blur behaviors itself - The fixed popover uses the background-secondary color and works in dark mode - The snooze items have hover and active states
41 lines
1.2 KiB
JavaScript
41 lines
1.2 KiB
JavaScript
import React, {Component, PropTypes} from 'react';
|
|
import {Actions, FocusedPerspectiveStore} from 'nylas-exports';
|
|
import SnoozePopoverBody from './snooze-popover-body';
|
|
|
|
|
|
class QuickActionSnoozeButton extends Component {
|
|
static displayName = 'QuickActionSnoozeButton';
|
|
|
|
static propTypes = {
|
|
thread: PropTypes.object,
|
|
};
|
|
|
|
onClick = (event)=> {
|
|
event.stopPropagation()
|
|
const {thread} = this.props;
|
|
|
|
// Grab the parent node because of the zoom applied to this button. If we
|
|
// took this element directly, we'd have to divide everything by 2
|
|
const element = React.findDOMNode(this).parentNode;
|
|
const {height, width, top, bottom, left, right} = element.getBoundingClientRect()
|
|
|
|
// The parent node is a bit too much to the left, lets adjust this.
|
|
const rect = {height, width, top, bottom, right, left: left + 5}
|
|
Actions.openPopover(
|
|
<SnoozePopoverBody threads={[thread]} closePopover={Actions.closePopover}/>,
|
|
rect,
|
|
"left"
|
|
);
|
|
};
|
|
|
|
static containerRequired = false;
|
|
|
|
render() {
|
|
if (!FocusedPerspectiveStore.current().isInbox()) {
|
|
return <span />;
|
|
}
|
|
return <div title="Snooze" className="btn action action-snooze" onClick={this.onClick}/>
|
|
}
|
|
}
|
|
|
|
export default QuickActionSnoozeButton
|