2019-10-15 00:53:33 +02:00

27 lines
786 B
TypeScript

import React, { ComponentProps, memo } from 'react';
import { Separator } from '@storybook/components';
import { ToolBarControl } from './ToolBarControl';
import { ContextNode, FCNoChildren, SelectionState } from '../../shared/types.d';
type ToolBar = FCNoChildren<{
nodes: ContextNode[];
state: SelectionState;
setSelected: ComponentProps<typeof ToolBarControl>['setSelected'];
}>;
export const ToolBar: ToolBar = memo(({ nodes, state, setSelected }) =>
nodes.length ? (
<>
<Separator />
{nodes.map(({ components, ...forwardProps }) => (
<ToolBarControl
{...forwardProps}
setSelected={setSelected}
selected={state[forwardProps.nodeId] || ''}
key={forwardProps.nodeId}
/>
))}
</>
) : null
);