import React, { FunctionComponent } from 'react'; import PropTypes from 'prop-types'; import { Action } from 'redux'; import { StylingFunction } from 'react-base16-styling'; import { Tab } from './ActionPreview'; interface Props> { tabs: Tab[]; styling: StylingFunction; inspectedPath: (string | number)[]; onInspectPath: (path: (string | number)[]) => void; tabName: string; onSelectTab: (tabName: string) => void; } const ActionPreviewHeader: FunctionComponent>> = ({ styling, inspectedPath, onInspectPath, tabName, onSelectTab, tabs }) => (
{tabs.map((tab) => (
onSelectTab(tab.name)} key={tab.name} {...styling( [ 'selectorButton', tab.name === tabName && 'selectorButtonSelected', ], tab.name === tabName )} > {tab.name}
))}
{inspectedPath.length ? ( onInspectPath([])} {...styling('inspectedPathKeyLink')} > {tabName} ) : ( tabName )} {inspectedPath.map((key, idx) => idx === inspectedPath.length - 1 ? ( {key} ) : ( onInspectPath(inspectedPath.slice(0, idx + 1))} {...styling('inspectedPathKeyLink')} > {key} ) )}
); ActionPreviewHeader.propTypes = { tabs: PropTypes.array.isRequired, styling: PropTypes.func.isRequired, inspectedPath: PropTypes.array.isRequired, onInspectPath: PropTypes.func.isRequired, tabName: PropTypes.string.isRequired, onSelectTab: PropTypes.func.isRequired, }; export default ActionPreviewHeader;