redux-devtools/packages/redux-devtools-inspector/src/ActionListHeader.jsx

52 lines
1.3 KiB
React
Raw Normal View History

import React from 'react';
import RightSlider from './RightSlider';
const getActiveButtons = (hasSkippedActions) =>
[hasSkippedActions && 'Sweep', 'Commit'].filter((a) => a);
2019-01-10 21:51:14 +03:00
const ActionListHeader = ({
styling,
onSearch,
hasSkippedActions,
hasStagedActions,
onCommit,
onSweep,
hideMainButtons,
2019-01-10 21:51:14 +03:00
}) => (
<div {...styling('actionListHeader')}>
<input
{...styling('actionListHeaderSearch')}
onChange={(e) => onSearch(e.target.value)}
2019-01-10 21:51:14 +03:00
placeholder="filter..."
/>
{!hideMainButtons && (
<div {...styling('actionListHeaderWrapper')}>
<RightSlider shown={hasStagedActions} styling={styling}>
<div {...styling('actionListHeaderSelector')}>
{getActiveButtons(hasSkippedActions).map((btn) => (
2019-01-10 21:51:14 +03:00
<div
key={btn}
onClick={() =>
({
Commit: onCommit,
Sweep: onSweep,
2019-01-10 21:51:14 +03:00
}[btn]())
}
{...styling(
['selectorButton', 'selectorButtonSmall'],
false,
true
)}
>
{btn}
</div>
))}
</div>
</RightSlider>
</div>
)}
</div>
);
export default ActionListHeader;