69 lines
1.7 KiB
JavaScript
Raw Normal View History

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-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-07-06 18:56:28 -04:00
const TopBarButtonSpan = TopBarButton.withComponent('span');
const DragIconContainer = styled(TopBarButtonSpan)`
2018-07-06 18:56:28 -04:00
width: 100%;
cursor: move;
`;
2018-07-06 18:56:28 -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-07-06 18:56:28 -04:00
export default StyledListItemTopBar;