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

64 lines
1.1 KiB
JavaScript
Raw Normal View History

2017-01-09 20:58:30 +02:00
const constants = require('../../shared/constants');
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-09 20:58:30 +02:00
const {
colors
} = constants;
2017-01-10 00:14:10 +02:00
const {
remcalc
} = fns;
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
2017-01-09 20:58:30 +02:00
const color = (props) => props.fromHeader
? colors.brandPrimaryColor
: '#646464';
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;
font-size: 14px;
2017-01-09 20:58:30 +02:00
color: ${color};
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
};
module.exports = Subtitle;