mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-06 05:41:06 +08:00
27 lines
786 B
TypeScript
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
|
|
);
|