1
0
mirror of https://github.com/yldio/copilot.git synced 2024-11-14 07:10:05 +02:00
copilot/ui/src/components/list/meta.js

67 lines
1.2 KiB
JavaScript
Raw Normal View History

import styled from 'styled-components';
2017-02-27 17:41:08 +02:00
import { Subscriber } from 'react-broadcast';
import { Baseline } from '../../shared/composers';
import { is } from '../../shared/functions';
import Column from '../column';
import Row from '../row';
import View from './view';
import React from 'react';
2017-02-15 03:19:26 +02:00
2017-01-09 14:13:12 +02:00
const InnerRow = styled(Row)`
display: block;
2017-01-09 14:13:12 +02:00
height: 100%;
${is('collapsed')`
display: flex;
`};
2017-01-09 14:13:12 +02:00
`;
2017-02-27 17:41:08 +02:00
const Meta = ({
children,
...props
}) => {
2017-02-27 17:41:08 +02:00
const render = ({
collapsed = false,
fromHeader = false,
headed = false
}) => {
const meta = (
<Column
name='list-item-meta'
xs={collapsed ? 12 : 6}
collapsed={collapsed}
fromHeader={fromHeader}
headed={headed}
{...props}
>
<InnerRow collapsed={collapsed}>
{children}
</InnerRow>
</Column>
);
2017-01-09 20:58:30 +02:00
2017-02-27 17:41:08 +02:00
return !fromHeader ? meta : (
<View collapsed fromHeader>
{meta}
</View>
);
};
return (
<Subscriber channel='list-item'>
{render}
</Subscriber>
2017-01-09 20:58:30 +02:00
);
2017-02-27 17:41:08 +02:00
};
Meta.propTypes = {
children: React.PropTypes.node,
collapsed: React.PropTypes.bool,
fromHeader: React.PropTypes.bool,
headed: React.PropTypes.bool
};
2017-02-15 03:19:26 +02:00
export default Baseline(
2017-02-15 03:19:26 +02:00
Meta
);