insomnia/app/ui/components/dropdowns/PreviewModeDropdown.js
2016-09-20 17:03:26 -07:00

36 lines
928 B
JavaScript

import React, {PropTypes} from 'react';
import Dropdown from '../base/Dropdown';
import {PREVIEW_MODES, getPreviewModeName} from 'backend/previewModes';
import {trackEvent} from 'backend/analytics';
const PreviewModeDropdown = ({updatePreviewMode}) => {
return (
<Dropdown>
<button className="tall">
<i className="fa fa-caret-down"></i>
</button>
<ul>
{PREVIEW_MODES.map(previewMode => (
<li key={previewMode}>
<button onClick={() => {
trackEvent('Changed Preview Mode', {previewMode});
updatePreviewMode(previewMode);
}}>{getPreviewModeName(previewMode)}</button>
</li>
))}
</ul>
</Dropdown>
)
};
PreviewModeDropdown.propTypes = {
// Functions
updatePreviewMode: PropTypes.func.isRequired,
// Required
previewMode: PropTypes.string.isRequired
};
export default PreviewModeDropdown;