insomnia/app/ui/components/dropdowns/PreviewModeDropdown.js

36 lines
928 B
JavaScript
Raw Normal View History

import React, {PropTypes} from 'react';
2016-04-30 05:01:57 +00:00
import Dropdown from '../base/Dropdown';
2016-09-21 00:03:26 +00:00
import {PREVIEW_MODES, getPreviewModeName} from 'backend/previewModes';
import {trackEvent} from 'backend/analytics';
2016-04-30 05:01:57 +00:00
const PreviewModeDropdown = ({updatePreviewMode}) => {
return (
<Dropdown>
2016-06-12 00:00:52 +00:00
<button className="tall">
<i className="fa fa-caret-down"></i>
</button>
2016-04-30 05:01:57 +00:00
<ul>
{PREVIEW_MODES.map(previewMode => (
<li key={previewMode}>
<button onClick={() => {
trackEvent('Changed Preview Mode', {previewMode});
updatePreviewMode(previewMode);
}}>{getPreviewModeName(previewMode)}</button>
2016-04-30 05:01:57 +00:00
</li>
))}
</ul>
</Dropdown>
)
};
PreviewModeDropdown.propTypes = {
// Functions
updatePreviewMode: PropTypes.func.isRequired,
2016-04-30 05:01:57 +00:00
// Required
previewMode: PropTypes.string.isRequired
};
export default PreviewModeDropdown;