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

73 lines
1.3 KiB
JavaScript
Raw Normal View History

2017-02-15 03:19:26 +02:00
const composers = require('../../shared/composers');
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 {
remcalc
} = fns;
2017-02-15 03:19:26 +02:00
const {
Baseline
} = composers;
const {
default: styled,
css
2017-01-09 14:13:12 +02:00
} = Styled;
const margin = (props) => props.collapsed ? `
margin-left: auto;
` : '';
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)`
${collapsed`
position: absolute;
bottom: 0;
padding-bottom: ${remcalc(12)};
padding-top: 0;
`}
font-weight: normal;
2017-01-09 14:13:12 +02:00
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
};
2017-02-15 03:19:26 +02:00
module.exports = Baseline(
Description
);