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

40 lines
766 B
JavaScript
Raw Normal View History

2017-01-09 20:58:30 +02:00
const fns = require('../../shared/functions');
const transferProps = require('./transfer-props');
2017-01-09 14:13:12 +02:00
const React = require('react');
const Row = require('../row');
const Styled = require('styled-components');
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-09 14:13:12 +02:00
const View = styled(Row)`
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-09 20:58:30 +02:00
module.exports = transferProps([
'collapsed',
'headed',
'fromHeader'
], (props) => (
2017-01-09 14:13:12 +02:00
<View name='list-item-view' {...props}>
{props.children}
</View>
));