1
0
mirror of https://github.com/yldio/copilot.git synced 2024-11-15 15:50:06 +02:00
copilot/packages/ui-toolkit/src/card/description.js
2017-06-28 18:38:28 +01:00

60 lines
1.2 KiB
JavaScript

import { Subscriber } from 'react-broadcast';
import Baseline from '../baseline';
import typography from '../typography';
import is, { isNot } from 'styled-is';
import remcalc from 'remcalc';
import styled from 'styled-components';
import PropTypes from 'prop-types';
import Title from './title';
import React from 'react';
const StyledTitle = Title.extend`
${typography.fontFamily};
${typography.normal};
flex-grow: 2;
${isNot('collapsed')`
padding-bottom: ${remcalc(12)};
`};
`;
const InnerDescription = styled.div`
justify-content: flex-start;
${is('collapsed')`
justify-content: flex-end;
margin-left: auto;
`};
`;
const Description = ({ children, ...rest }) => {
const render = ({ collapsed = false }) =>
<StyledTitle
collapsed={collapsed}
name="card-description"
xs={collapsed ? 6 : 12}
{...rest}
>
<InnerDescription collapsed={collapsed}>
{children}
</InnerDescription>
</StyledTitle>;
return (
<Subscriber channel="card">
{render}
</Subscriber>
);
};
Description.propTypes = {
children: PropTypes.node,
/**
* @ignore
*/
collapsed: PropTypes.bool
};
export default Baseline(Description);