UNPKG

@orfeas126/box-ui-elements

Version:
55 lines (54 loc) 1.95 kB
/** * * @file Preview Navigation * @author Box */ import * as React from 'react'; import { injectIntl } from 'react-intl'; import { Route } from 'react-router-dom'; import IconNavigateLeft from '../../icons/general/IconNavigateLeft'; import IconNavigateRight from '../../icons/general/IconNavigateRight'; import PlainButton from '../../components/plain-button/PlainButton'; import messages from '../common/messages'; const PreviewNavigation = ({ collection = [], currentIndex, intl, onNavigateLeft, onNavigateRight }) => { const hasLeftNavigation = collection.length > 1 && currentIndex > 0 && currentIndex < collection.length; const hasRightNavigation = collection.length > 1 && currentIndex > -1 && currentIndex < collection.length - 1; if (!hasLeftNavigation && !hasRightNavigation) { return null; } return /*#__PURE__*/React.createElement(Route, { path: ['/:activeTab/:deeplink', '/'] }, ({ match, history }) => /*#__PURE__*/React.createElement(React.Fragment, null, hasLeftNavigation && /*#__PURE__*/React.createElement(PlainButton, { className: "bcpr-navigate-left", onClick: () => { if (match.params.deeplink) { history.push(`/${match.params.activeTab}`); } onNavigateLeft(); }, title: intl.formatMessage(messages.previousFile), type: "button" }, /*#__PURE__*/React.createElement(IconNavigateLeft, null)), hasRightNavigation && /*#__PURE__*/React.createElement(PlainButton, { className: "bcpr-navigate-right", onClick: () => { if (match.params.deeplink) { history.push(`/${match.params.activeTab}`); } onNavigateRight(); }, title: intl.formatMessage(messages.nextFile), type: "button" }, /*#__PURE__*/React.createElement(IconNavigateRight, null)))); }; export { PreviewNavigation as PreviewNavigationComponent }; export default injectIntl(PreviewNavigation); //# sourceMappingURL=PreviewNavigation.js.map