mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-03-16 02:03:42 +08:00
* Initial commit * SVG-based graph components * Add histogram, pull data into graphs * Loading animation, timespan descriptions * Improvements to read receipt / link tracking section * Initial pass at subject line analysis * Fixes to subject-line stats * Fix theme `ui-variables` include paths * Add “Share this report” button * Add “Learn More” button * Make it more clear how to edit your shortcuts * Merge activity-list and new activity-dashboard, move in sidebar
39 lines
1.4 KiB
JavaScript
39 lines
1.4 KiB
JavaScript
import moment from 'moment';
|
|
import React from 'react';
|
|
import PropTypes from 'prop-types';
|
|
import { DropdownMenu, Menu } from 'mailspring-component-kit';
|
|
import { getTimespanOptions } from './timespan';
|
|
|
|
export default class TimespanSelector extends React.Component {
|
|
static propTypes = {
|
|
timespan: PropTypes.object,
|
|
onChange: PropTypes.func,
|
|
};
|
|
|
|
render() {
|
|
const { id, startDate, endDate } = this.props.timespan;
|
|
|
|
const options = getTimespanOptions();
|
|
const itemIdx = options.findIndex(item => item.id === id);
|
|
|
|
const longFormat = id.startsWith('month') ? 'MMMM Do, h:mmA' : 'dddd MMMM Do, h:mmA';
|
|
const endFormat = endDate.diff(moment(), 'days') === 0 ? 'Now' : endDate.format(longFormat);
|
|
return (
|
|
<div className="timespan-selector">
|
|
<div className="timespan-text">{`${startDate.format(longFormat)} - ${endFormat}`}</div>
|
|
<DropdownMenu
|
|
className="hidden-on-web"
|
|
attachment={DropdownMenu.Attachment.RightEdge}
|
|
intitialSelectionItem={options[itemIdx]}
|
|
defaultSelectedIndex={itemIdx}
|
|
headerComponents={[]}
|
|
footerComponents={[]}
|
|
items={options}
|
|
itemKey={item => item.id}
|
|
itemContent={item => (item.divider ? <Menu.Item key="divider" divider /> : item.name)}
|
|
onSelect={item => this.props.onChange(item.id)}
|
|
/>
|
|
</div>
|
|
);
|
|
}
|
|
}
|