1
0
mirror of https://github.com/yldio/copilot.git synced 2024-09-21 22:03:54 +03:00
copilot/ui/src/components/list/subtitle.js

62 lines
1.1 KiB
JavaScript
Raw Normal View History

2017-02-15 03:19:26 +02:00
const composers = require('../../shared/composers');
2017-01-10 00:14:10 +02:00
const fns = require('../../shared/functions');
2017-01-09 14:13:12 +02:00
const Title = require('./title');
const React = require('react');
const Styled = require('styled-components');
2017-01-10 00:14:10 +02:00
const {
remcalc
} = fns;
2017-02-15 03:19:26 +02:00
const {
Baseline
} = composers;
2017-01-09 14:13:12 +02:00
const {
default: styled
} = Styled;
2017-01-10 00:14:10 +02:00
const padding = (props) => !props.collapsed
? `0 ${remcalc(18)}`
2017-01-10 00:20:54 +02:00
: 0;
2017-01-10 00:14:10 +02:00
const display = (props) => !props.collapsed
? 'inline-block'
: 'flex';
2017-01-09 14:13:12 +02:00
const Span = styled.span`
display: ${display};
2017-01-09 14:13:12 +02:00
flex-direction: column;
font-weight: normal;
font-style: normal;
font-stretch: normal;
2017-01-12 21:04:52 +02:00
font-size: ${remcalc(14)};
2017-01-10 00:14:10 +02:00
justify-content: flex-end;
`;
const StyledTitle = styled(Title)`
display: ${display};
2017-01-10 00:14:10 +02:00
padding: ${padding};
2017-01-09 14:13:12 +02:00
`;
const Subtitle = (props) => (
2017-01-10 00:14:10 +02:00
<StyledTitle name='list-item-subtitle' {...props}>
2017-01-09 20:58:30 +02:00
<Span
fromHeader={props.fromHeader}
>
2017-01-09 14:13:12 +02:00
{props.children}
</Span>
2017-01-10 00:14:10 +02:00
</StyledTitle>
2017-01-09 14:13:12 +02:00
);
Subtitle.propTypes = {
2017-01-09 20:58:30 +02:00
children: React.PropTypes.node,
fromHeader: React.PropTypes.bool
2017-01-09 14:13:12 +02:00
};
2017-02-15 03:19:26 +02:00
module.exports = Baseline(
Subtitle
);