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

78 lines
1.4 KiB
JavaScript
Raw Normal View History

2017-02-27 17:41:08 +02:00
import { Subscriber } from 'react-broadcast';
import styled from 'styled-components';
import { Baseline, typography } from '../../shared/composers';
import { remcalc, is } from '../../shared/functions';
2017-02-27 17:41:08 +02:00
import { colors } from '../../shared/constants';
import Title from './title';
import React from 'react';
2017-01-09 14:13:12 +02:00
const Span = styled.span`
display: inline-block;
2017-01-09 14:13:12 +02:00
flex-direction: column;
${typography.normal};
2017-01-09 14:13:12 +02:00
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;
${is('collapsed')`
display: flex;
`};
2017-02-27 17:41:08 +02:00
${is('fromHeader')`
color: ${colors.base.white};
`};
2017-01-10 00:14:10 +02:00
`;
const StyledTitle = styled(Title)`
display: inline-block;
padding: 0 ${remcalc(18)};
${typography.normal};
2017-02-27 17:41:08 +02:00
${is('collapsed')`
display: flex;
padding: 0;
`};
2017-01-09 14:13:12 +02:00
`;
const Subtitle = ({
children,
...props
2017-02-27 17:41:08 +02:00
}) => {
const render = ({
fromHeader = false,
collapsed = false
}) => (
<StyledTitle
name='list-item-subtitle'
fromHeader={fromHeader}
collapsed={collapsed}
{...props}
>
<Span fromHeader={fromHeader} collapsed={collapsed}>
{children}
</Span>
</StyledTitle>
);
return (
<Subscriber channel='list-item'>
{render}
</Subscriber>
);
};
2017-01-09 14:13:12 +02:00
Subtitle.propTypes = {
2017-01-09 20:58:30 +02:00
children: React.PropTypes.node,
2017-02-27 17:41:08 +02:00
collapsed: React.PropTypes.bool,
2017-01-09 20:58:30 +02:00
fromHeader: React.PropTypes.bool
2017-01-09 14:13:12 +02:00
};
export default Baseline(
2017-02-15 03:19:26 +02:00
Subtitle
);