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';
|
2017-08-14 13:21:45 +03:00
|
|
|
import is, { isNot } 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;
|
2017-08-14 13:21:45 +03:00
|
|
|
flex-basis: ${remcalc(90)};
|
2017-02-20 18:15:36 +02:00
|
|
|
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')`
|
2017-08-14 13:21:45 +03:00
|
|
|
flex-grow: 6;
|
2017-02-20 18:15:36 +02:00
|
|
|
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 }) => {
|
2017-08-28 22:21:08 +03:00
|
|
|
const _children = isString(children) ? <Span>{children}</Span> : children;
|
2017-01-09 14:13:12 +02:00
|
|
|
|
2017-08-28 22:21:08 +03:00
|
|
|
const render = ({ collapsed = false, active = true, 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-08-14 13:21:45 +03:00
|
|
|
active={active}
|
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-08-28 22:21:08 +03:00
|
|
|
name="container"
|
2017-01-09 14:13:12 +02:00
|
|
|
>
|
|
|
|
{_children}
|
2017-08-28 22:21:08 +03:00
|
|
|
</Container>
|
2017-02-27 17:41:08 +02:00
|
|
|
);
|
2017-08-28 22:21:08 +03:00
|
|
|
|
|
|
|
return <Subscriber channel="card">{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);
|