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-05-18 21:21:33 +03:00
|
|
|
flex-grow: 2;
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
${is('collapsed')`
|
|
|
|
justify-content: flex-end;
|
2017-02-27 17:41:08 +02:00
|
|
|
margin-left: auto;
|
2017-02-20 18:15:36 +02:00
|
|
|
`};
|
2017-01-09 14:13:12 +02:00
|
|
|
`;
|
|
|
|
|
2017-05-18 21:21:33 +03:00
|
|
|
const Description = ({ children, ...rest }) => {
|
2017-06-12 01:58:22 +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
|
|
|
>
|
|
|
|
<InnerDescription collapsed={collapsed}>
|
|
|
|
{children}
|
|
|
|
</InnerDescription>
|
2017-06-12 01:58:22 +03:00
|
|
|
</StyledTitle>;
|
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
|
|
|
|
|
|
|
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);
|