2017-02-27 17:41:08 +02:00
|
|
|
import { Subscriber } from 'react-broadcast';
|
2017-02-20 18:15:36 +02:00
|
|
|
import isString from 'lodash.isstring';
|
2017-05-18 21:21:33 +03:00
|
|
|
import typography from '../typography';
|
|
|
|
import Baseline from '../baseline';
|
|
|
|
import remcalc from 'remcalc';
|
|
|
|
import is from 'styled-is';
|
2017-02-20 18:15:36 +02:00
|
|
|
import styled from 'styled-components';
|
2017-05-18 21:21:33 +03:00
|
|
|
import PropTypes from 'prop-types';
|
2017-02-20 18:15:36 +02:00
|
|
|
import React from 'react';
|
2017-01-11 16:13:58 +02:00
|
|
|
|
2017-01-09 14:13:12 +02:00
|
|
|
const Container = styled.div`
|
2017-03-30 15:16:32 +03:00
|
|
|
font-size: ${remcalc(15)};
|
2017-01-09 14:13:12 +02:00
|
|
|
line-height: 1.5;
|
2017-05-18 21:21:33 +03:00
|
|
|
color: ${props => props.theme.secondary};
|
2017-01-09 14:13:12 +02:00
|
|
|
|
2017-05-18 21:21:33 +03:00
|
|
|
${typography.fontFamily};
|
|
|
|
${typography.semibold};
|
2017-02-27 17:41:08 +02:00
|
|
|
|
2017-01-09 14:13:12 +02:00
|
|
|
display: flex;
|
2017-02-20 18:15:36 +02:00
|
|
|
flex-direction: row;
|
|
|
|
justify-content: flex-start;
|
2017-01-09 14:13:12 +02:00
|
|
|
|
2017-02-20 18:15:36 +02:00
|
|
|
flex-grow: 2;
|
|
|
|
width: 100%;
|
2017-01-09 14:13:12 +02:00
|
|
|
|
2017-02-20 18:15:36 +02:00
|
|
|
padding: ${remcalc(12)} ${remcalc(18)} 0 ${remcalc(18)};
|
2017-01-09 14:13:12 +02:00
|
|
|
|
2017-02-27 17:41:08 +02:00
|
|
|
${is('fromHeader')`
|
2017-05-18 21:21:33 +03:00
|
|
|
color: ${props => props.theme.white};
|
2017-02-27 17:41:08 +02:00
|
|
|
`};
|
|
|
|
|
2017-02-20 18:15:36 +02:00
|
|
|
${is('collapsed')`
|
|
|
|
flex-grow: 0;
|
|
|
|
flex-direction: column;
|
|
|
|
width: auto;
|
|
|
|
justify-content: center;
|
|
|
|
padding: 0 ${remcalc(18)};
|
|
|
|
`};
|
|
|
|
`;
|
2017-01-11 16:13:58 +02:00
|
|
|
|
2017-01-09 14:13:12 +02:00
|
|
|
const Span = styled.span`
|
2017-02-20 18:15:36 +02:00
|
|
|
display: inline-block;
|
2017-01-09 14:13:12 +02:00
|
|
|
flex-direction: column;
|
|
|
|
justify-content: center;
|
2017-02-20 18:15:36 +02:00
|
|
|
|
|
|
|
${is('collapsed')`
|
|
|
|
display: flex;
|
|
|
|
`};
|
2017-01-09 14:13:12 +02:00
|
|
|
`;
|
|
|
|
|
2017-05-18 21:21:33 +03:00
|
|
|
const Title = ({ children, ...rest }) => {
|
|
|
|
const _children = isString(children) ? <Span>{children}</Span> : children;
|
2017-01-09 14:13:12 +02:00
|
|
|
|
2017-06-12 01:58:22 +03:00
|
|
|
const render = ({ collapsed = false, fromHeader = false }) =>
|
2017-01-09 14:13:12 +02:00
|
|
|
<Container
|
2017-02-20 18:15:36 +02:00
|
|
|
collapsed={collapsed}
|
2017-02-27 17:41:08 +02:00
|
|
|
fromHeader={fromHeader}
|
2017-05-18 21:21:33 +03:00
|
|
|
name="card-title"
|
2017-02-27 17:41:08 +02:00
|
|
|
xs={collapsed ? 6 : 12}
|
2017-05-18 21:21:33 +03:00
|
|
|
{...rest}
|
2017-01-09 14:13:12 +02:00
|
|
|
>
|
|
|
|
{_children}
|
2017-06-12 01:58:22 +03:00
|
|
|
</Container>;
|
2017-02-27 17:41:08 +02:00
|
|
|
|
|
|
|
return (
|
2017-05-18 21:21:33 +03:00
|
|
|
<Subscriber channel="card">
|
2017-02-27 17:41:08 +02:00
|
|
|
{render}
|
|
|
|
</Subscriber>
|
|
|
|
);
|
2017-01-09 14:13:12 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
Title.propTypes = {
|
2017-05-18 21:21:33 +03:00
|
|
|
children: PropTypes.node,
|
|
|
|
/**
|
|
|
|
* @ignore
|
|
|
|
*/
|
|
|
|
collapsed: PropTypes.bool,
|
|
|
|
/**
|
|
|
|
* @ignore
|
|
|
|
*/
|
|
|
|
fromHeader: PropTypes.bool
|
2017-01-09 14:13:12 +02:00
|
|
|
};
|
|
|
|
|
2017-05-18 21:21:33 +03:00
|
|
|
export default Baseline(Title);
|