2017-05-18 21:21:33 +03:00
|
|
|
import { Row, Col } from 'react-styled-flexboxgrid';
|
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 is from 'styled-is';
|
|
|
|
import remcalc from 'remcalc';
|
|
|
|
import PropTypes from 'prop-types';
|
2017-02-20 18:15:36 +02:00
|
|
|
import View from './view';
|
|
|
|
import React from 'react';
|
2017-02-15 03:19:26 +02:00
|
|
|
|
2017-05-25 17:59:58 +03:00
|
|
|
const InnerRow = Row.extend`
|
2017-02-20 18:15:36 +02:00
|
|
|
display: block;
|
2017-01-09 14:13:12 +02:00
|
|
|
height: 100%;
|
2017-02-20 18:15:36 +02:00
|
|
|
|
2017-03-22 14:15:09 +02:00
|
|
|
position: absolute;
|
|
|
|
top: 50%;
|
|
|
|
transform: translateY(-50%);
|
|
|
|
|
2017-02-20 18:15:36 +02:00
|
|
|
${is('collapsed')`
|
2017-05-18 21:21:33 +03:00
|
|
|
width: 100%;
|
2017-02-20 18:15:36 +02:00
|
|
|
display: flex;
|
2017-05-18 21:21:33 +03:00
|
|
|
padding-right: ${remcalc(47)};
|
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 Meta = ({ children, ...rest }) => {
|
2017-02-27 17:41:08 +02:00
|
|
|
const render = ({
|
|
|
|
collapsed = false,
|
|
|
|
fromHeader = false,
|
|
|
|
headed = false
|
|
|
|
}) => {
|
|
|
|
const meta = (
|
2017-05-18 21:21:33 +03:00
|
|
|
<Col
|
|
|
|
name="card-meta"
|
2017-02-27 17:41:08 +02:00
|
|
|
xs={collapsed ? 12 : 6}
|
|
|
|
collapsed={collapsed}
|
|
|
|
fromHeader={fromHeader}
|
|
|
|
headed={headed}
|
2017-05-18 21:21:33 +03:00
|
|
|
{...rest}
|
2017-02-27 17:41:08 +02:00
|
|
|
>
|
|
|
|
<InnerRow collapsed={collapsed}>
|
|
|
|
{children}
|
|
|
|
</InnerRow>
|
2017-05-18 21:21:33 +03:00
|
|
|
</Col>
|
2017-02-27 17:41:08 +02:00
|
|
|
);
|
2017-01-09 20:58:30 +02:00
|
|
|
|
2017-05-18 21:21:33 +03:00
|
|
|
return fromHeader
|
|
|
|
? <View collapsed fromHeader>
|
|
|
|
{meta}
|
|
|
|
</View>
|
|
|
|
: meta;
|
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 20:58:30 +02:00
|
|
|
);
|
2017-02-27 17:41:08 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
Meta.propTypes = {
|
2017-05-18 21:21:33 +03:00
|
|
|
children: PropTypes.node,
|
|
|
|
collapsed: PropTypes.bool,
|
|
|
|
fromHeader: PropTypes.bool,
|
|
|
|
headed: PropTypes.bool
|
2017-02-27 17:41:08 +02:00
|
|
|
};
|
2017-02-15 03:19:26 +02:00
|
|
|
|
2017-05-18 21:21:33 +03:00
|
|
|
export default Baseline(Meta);
|