1
0
mirror of https://github.com/yldio/copilot.git synced 2024-11-15 15:50:06 +02:00
copilot/ui/src/components/list/description.js

62 lines
1.2 KiB
JavaScript
Raw Normal View History

2017-02-27 17:41:08 +02:00
import { Subscriber } from 'react-broadcast';
import { Baseline } from '../../shared/composers';
2017-02-27 17:41:08 +02:00
import { remcalc, is, isNot } from '../../shared/functions';
import styled from 'styled-components';
import Title from './title';
import React from 'react';
2017-01-09 14:13:12 +02:00
const StyledTitle = styled(Title)`
2017-02-27 17:41:08 +02:00
font-weight: normal;
flex-grow: 2;
${isNot('collapsed')`
position: absolute;
bottom: 0;
padding-bottom: ${remcalc(12)};
padding-top: 0;
`};
2017-01-09 14:13:12 +02:00
`;
const InnerDescription = styled.div`
justify-content: flex-start;
${is('collapsed')`
justify-content: flex-end;
2017-02-27 17:41:08 +02:00
margin-left: auto;
`};
2017-01-09 14:13:12 +02:00
`;
const Description = ({
children,
...props
2017-02-27 17:41:08 +02:00
}) => {
const render = ({
collapsed = false
}) => (
<StyledTitle
collapsed={collapsed}
name='list-item-description'
xs={collapsed ? 6 : 12}
>
<InnerDescription collapsed={collapsed}>
{children}
</InnerDescription>
</StyledTitle>
);
return (
<Subscriber channel='list-item'>
{render}
</Subscriber>
);
};
2017-01-09 14:13:12 +02:00
Description.propTypes = {
children: React.PropTypes.node,
collapsed: React.PropTypes.bool
};
export default Baseline(
2017-02-15 03:19:26 +02:00
Description
);