2018-07-06 18:56:28 -04:00
|
|
|
import React from 'react';
|
|
|
|
import styled from 'react-emotion';
|
|
|
|
import Icon from './Icon';
|
2018-07-24 17:13:48 -04:00
|
|
|
import { colors, lengths, buttons } from './styles';
|
|
|
|
|
|
|
|
const TopBar = styled.div`
|
|
|
|
display: flex;
|
|
|
|
justify-content: space-between;
|
|
|
|
height: 26px;
|
|
|
|
border-radius: ${lengths.borderRadius} ${lengths.borderRadius} 0 0;
|
|
|
|
position: relative;
|
2018-08-07 14:46:54 -06:00
|
|
|
`;
|
2018-07-06 18:56:28 -04:00
|
|
|
|
|
|
|
const TopBarButton = styled.button`
|
2018-07-24 17:13:48 -04:00
|
|
|
${buttons.button};
|
2018-07-06 18:56:28 -04:00
|
|
|
color: ${colors.controlLabel};
|
|
|
|
background: transparent;
|
|
|
|
font-size: 16px;
|
|
|
|
line-height: 1;
|
|
|
|
padding: 0;
|
|
|
|
width: 32px;
|
|
|
|
text-align: center;
|
|
|
|
cursor: pointer;
|
|
|
|
display: flex;
|
|
|
|
justify-content: center;
|
|
|
|
align-items: center;
|
2018-08-07 14:46:54 -06:00
|
|
|
`;
|
2018-07-06 18:56:28 -04:00
|
|
|
|
|
|
|
const TopBarButtonSpan = TopBarButton.withComponent('span');
|
|
|
|
|
2018-08-24 17:39:35 -04:00
|
|
|
const DragIconContainer = styled(TopBarButtonSpan)`
|
2018-07-06 18:56:28 -04:00
|
|
|
width: 100%;
|
|
|
|
cursor: move;
|
2018-08-07 14:46:54 -06:00
|
|
|
`;
|
2018-07-06 18:56:28 -04:00
|
|
|
|
2018-08-24 17:39:35 -04:00
|
|
|
const ListItemTopBar = ({ className, collapsed, onCollapseToggle, onRemove, dragHandleHOC }) => {
|
|
|
|
const DragHandle = dragHandleHOC(() => (
|
|
|
|
<DragIconContainer>
|
|
|
|
<Icon type="drag-handle" size="small" />
|
|
|
|
</DragIconContainer>
|
|
|
|
));
|
|
|
|
|
|
|
|
return (
|
|
|
|
<TopBar className={className}>
|
|
|
|
{onCollapseToggle ? (
|
|
|
|
<TopBarButton onClick={onCollapseToggle}>
|
|
|
|
<Icon type="chevron" size="small" direction={collapsed ? 'right' : 'down'} />
|
|
|
|
</TopBarButton>
|
|
|
|
) : null}
|
|
|
|
{dragHandleHOC ? <DragHandle dragHandleHOC={dragHandleHOC} /> : null}
|
|
|
|
{onRemove ? (
|
|
|
|
<TopBarButton onClick={onRemove}>
|
|
|
|
<Icon type="close" size="small" />
|
|
|
|
</TopBarButton>
|
|
|
|
) : null}
|
|
|
|
</TopBar>
|
|
|
|
);
|
|
|
|
};
|
2018-07-06 18:56:28 -04:00
|
|
|
|
|
|
|
const StyledListItemTopBar = styled(ListItemTopBar)`
|
|
|
|
display: flex;
|
|
|
|
justify-content: space-between;
|
|
|
|
height: 26px;
|
|
|
|
border-radius: ${lengths.borderRadius} ${lengths.borderRadius} 0 0;
|
|
|
|
position: relative;
|
2018-08-07 14:46:54 -06:00
|
|
|
`;
|
2018-07-06 18:56:28 -04:00
|
|
|
|
|
|
|
export default StyledListItemTopBar;
|