2017-02-27 17:41:08 +02:00
|
|
|
import { Subscriber } from 'react-broadcast';
|
2017-05-18 21:21:33 +03:00
|
|
|
import Baseline from '../baseline';
|
|
|
|
import typography from '../typography';
|
|
|
|
import is, { isNot } from 'styled-is';
|
|
|
|
import remcalc from 'remcalc';
|
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 Title from './title';
|
|
|
|
import React from 'react';
|
2017-01-11 16:13:58 +02:00
|
|
|
|
2017-05-25 17:59:58 +03:00
|
|
|
const StyledTitle = Title.extend`
|
2017-05-18 21:21:33 +03:00
|
|
|
${typography.fontFamily};
|
2017-03-03 17:29:03 +02:00
|
|
|
${typography.normal};
|
|
|
|
|
2017-08-14 13:21:45 +03:00
|
|
|
flex-grow: 1;
|
|
|
|
flex-basis: ${remcalc(90)};
|
2017-05-18 21:21:33 +03:00
|
|
|
|
2017-02-27 17:41:08 +02:00
|
|
|
${isNot('collapsed')`
|
2017-01-11 16:13:58 +02:00
|
|
|
padding-bottom: ${remcalc(12)};
|
2017-02-20 18:15:36 +02:00
|
|
|
`};
|
2017-01-09 14:13:12 +02:00
|
|
|
`;
|
|
|
|
|
|
|
|
const InnerDescription = styled.div`
|
2017-02-20 18:15:36 +02:00
|
|
|
justify-content: flex-start;
|
2017-08-30 03:22:35 +03:00
|
|
|
height: 100%;
|
|
|
|
position: relative;
|
2017-01-09 14:13:12 +02:00
|
|
|
`;
|
|
|
|
|
2017-05-18 21:21:33 +03:00
|
|
|
const Description = ({ children, ...rest }) => {
|
2017-08-28 22:21:08 +03:00
|
|
|
const render = ({ collapsed = false }) => (
|
2017-02-27 17:41:08 +02:00
|
|
|
<StyledTitle
|
|
|
|
collapsed={collapsed}
|
2017-05-18 21:21:33 +03:00
|
|
|
name="card-description"
|
2017-02-27 17:41:08 +02:00
|
|
|
xs={collapsed ? 6 : 12}
|
2017-05-18 21:21:33 +03:00
|
|
|
{...rest}
|
2017-02-27 17:41:08 +02:00
|
|
|
>
|
2017-08-28 22:21:08 +03:00
|
|
|
<InnerDescription collapsed={collapsed}>{children}</InnerDescription>
|
|
|
|
</StyledTitle>
|
2017-02-27 17:41:08 +02:00
|
|
|
);
|
2017-08-28 22:21:08 +03:00
|
|
|
|
|
|
|
return <Subscriber channel="card">{render}</Subscriber>;
|
2017-02-27 17:41:08 +02:00
|
|
|
};
|
2017-01-09 14:13:12 +02:00
|
|
|
|
|
|
|
Description.propTypes = {
|
2017-05-18 21:21:33 +03:00
|
|
|
children: PropTypes.node,
|
|
|
|
/**
|
|
|
|
* @ignore
|
|
|
|
*/
|
|
|
|
collapsed: PropTypes.bool
|
2017-01-09 14:13:12 +02:00
|
|
|
};
|
|
|
|
|
2017-05-18 21:21:33 +03:00
|
|
|
export default Baseline(Description);
|