mirror of
https://github.com/yldio/copilot.git
synced 2024-11-10 21:30:06 +02:00
f3e531dbd8
styled-components@2 exposes a new `.extend`[1] API. It is less problematic than styled(Parent). [1]: https://www.styled-components.com/docs/basics#extending-styles
64 lines
1.3 KiB
JavaScript
64 lines
1.3 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')`
|
|
position: absolute;
|
|
bottom: 0;
|
|
padding-bottom: ${remcalc(12)};
|
|
padding-top: 0;
|
|
`};
|
|
`;
|
|
|
|
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);
|