mirror of
https://github.com/yldio/copilot.git
synced 2024-11-11 05:40:11 +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
69 lines
1.3 KiB
JavaScript
69 lines
1.3 KiB
JavaScript
import styled from 'styled-components';
|
|
import { Row, Col } from 'react-styled-flexboxgrid';
|
|
import { Subscriber } from 'react-broadcast';
|
|
import Baseline from '../baseline';
|
|
import is from 'styled-is';
|
|
import remcalc from 'remcalc';
|
|
import PropTypes from 'prop-types';
|
|
import View from './view';
|
|
import React from 'react';
|
|
|
|
const InnerRow = Row.extend`
|
|
display: block;
|
|
height: 100%;
|
|
|
|
position: absolute;
|
|
top: 50%;
|
|
transform: translateY(-50%);
|
|
|
|
${is('collapsed')`
|
|
width: 100%;
|
|
display: flex;
|
|
padding-right: ${remcalc(47)};
|
|
`};
|
|
`;
|
|
|
|
const Meta = ({ children, ...rest }) => {
|
|
const render = ({
|
|
collapsed = false,
|
|
fromHeader = false,
|
|
headed = false
|
|
}) => {
|
|
const meta = (
|
|
<Col
|
|
name="card-meta"
|
|
xs={collapsed ? 12 : 6}
|
|
collapsed={collapsed}
|
|
fromHeader={fromHeader}
|
|
headed={headed}
|
|
{...rest}
|
|
>
|
|
<InnerRow collapsed={collapsed}>
|
|
{children}
|
|
</InnerRow>
|
|
</Col>
|
|
);
|
|
|
|
return fromHeader
|
|
? <View collapsed fromHeader>
|
|
{meta}
|
|
</View>
|
|
: meta;
|
|
};
|
|
|
|
return (
|
|
<Subscriber channel="card">
|
|
{render}
|
|
</Subscriber>
|
|
);
|
|
};
|
|
|
|
Meta.propTypes = {
|
|
children: PropTypes.node,
|
|
collapsed: PropTypes.bool,
|
|
fromHeader: PropTypes.bool,
|
|
headed: PropTypes.bool
|
|
};
|
|
|
|
export default Baseline(Meta);
|