joyent-portal/ui/src/components/list/view.js

44 lines
832 B
JavaScript
Raw Normal View History

2017-01-09 20:58:30 +02:00
const fns = require('../../shared/functions');
2017-01-09 14:13:12 +02:00
const React = require('react');
const Row = require('../row');
const Styled = require('styled-components');
2017-01-10 00:14:10 +02:00
const transferProps = require('./transfer-props');
2017-01-09 14:13:12 +02:00
2017-01-09 20:58:30 +02:00
const {
remcalc
} = fns;
2017-01-09 14:13:12 +02:00
const {
default: styled
} = Styled;
2017-01-09 20:58:30 +02:00
const paddingTop = (props) => props.headed && !props.fromHeader
? remcalc(47)
: remcalc(0);
const display = (props) => props.headed && !props.fromHeader && props.collapsed
? 'none'
: 'flex';
2017-01-10 00:14:10 +02:00
const StyledView = styled(Row)`
2017-01-09 14:13:12 +02:00
flex: 1;
margin: 0;
height: 100%;
2017-01-09 20:58:30 +02:00
padding-top: ${paddingTop};
display: ${display};
2017-01-09 14:13:12 +02:00
`;
2017-01-10 00:14:10 +02:00
const View = (props) => (
<StyledView name='list-item-view' {...props}>
{props.children}
</StyledView>
);
2017-01-09 20:58:30 +02:00
module.exports = transferProps([
'collapsed',
'headed',
'fromHeader'
2017-01-10 00:14:10 +02:00
], View);
module.exports.raw = View;