2017-01-11 16:13:58 +02:00
|
|
|
const fns = require('../../shared/functions');
|
2017-01-09 14:13:12 +02:00
|
|
|
const React = require('react');
|
2017-01-09 20:58:30 +02:00
|
|
|
const Styled = require('styled-components');
|
|
|
|
const Title = require('./title');
|
2017-01-09 14:13:12 +02:00
|
|
|
|
|
|
|
const {
|
2017-01-11 16:13:58 +02:00
|
|
|
remcalc
|
|
|
|
} = fns;
|
|
|
|
|
|
|
|
const {
|
|
|
|
default: styled,
|
|
|
|
css
|
2017-01-09 14:13:12 +02:00
|
|
|
} = Styled;
|
|
|
|
|
|
|
|
const margin = (props) => props.collapsed ? `
|
|
|
|
margin-left: auto;
|
|
|
|
` : '';
|
|
|
|
|
2017-01-11 16:13:58 +02:00
|
|
|
const justify = (props) => props.collapsed
|
|
|
|
? 'flex-end'
|
|
|
|
: 'flex-start';
|
|
|
|
|
|
|
|
const xs = (props) => props.collapsed
|
|
|
|
? 6
|
|
|
|
: 12;
|
|
|
|
|
|
|
|
const collapsed = (...args) => (props) => !props.collapsed
|
|
|
|
? css(...args)
|
|
|
|
: css``;
|
2017-01-09 14:13:12 +02:00
|
|
|
|
|
|
|
const StyledTitle = styled(Title)`
|
2017-01-11 16:13:58 +02:00
|
|
|
${collapsed`
|
|
|
|
position: absolute;
|
|
|
|
bottom: 0;
|
|
|
|
padding-bottom: ${remcalc(12)};
|
|
|
|
padding-top: 0;
|
|
|
|
`}
|
|
|
|
|
2017-01-09 14:13:12 +02:00
|
|
|
font-weight: normal !important;
|
|
|
|
flex-grow: 2;
|
|
|
|
`;
|
|
|
|
|
|
|
|
const InnerDescription = styled.div`
|
|
|
|
${margin}
|
|
|
|
justify-content: ${justify};
|
|
|
|
`;
|
|
|
|
|
|
|
|
const Description = (props) => (
|
|
|
|
<StyledTitle
|
|
|
|
collapsed={props.collapsed}
|
|
|
|
name='list-item-description'
|
|
|
|
xs={xs(props)}
|
|
|
|
>
|
|
|
|
<InnerDescription collapsed={props.collapsed}>
|
|
|
|
{props.children}
|
|
|
|
</InnerDescription>
|
|
|
|
</StyledTitle>
|
|
|
|
);
|
|
|
|
|
|
|
|
Description.propTypes = {
|
|
|
|
children: React.PropTypes.node,
|
|
|
|
collapsed: React.PropTypes.bool
|
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = Description;
|