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

58 lines
1.1 KiB
JavaScript
Raw Normal View History

2017-01-09 14:13:12 +02:00
const constants = require('../../shared/constants');
const fns = require('../../shared/functions');
const React = require('react');
const Row = require('../row');
const Styled = require('styled-components');
2017-01-09 20:58:30 +02:00
const transferProps = require('./transfer-props');
2017-01-09 14:13:12 +02:00
const {
boxes,
colors
} = constants;
const {
remcalc
} = fns;
const {
2017-01-09 22:33:32 +02:00
default: styled,
css
2017-01-09 14:13:12 +02:00
} = Styled;
2017-01-09 22:33:32 +02:00
const paper = `
0 8px 0 -5px #fafafa,
0 8px 1px -4px ${colors.borderSecondary},
0 16px 0 -10px #fafafa,
0 16px 1px -9px ${colors.borderSecondary},
0 18px 1px -11px ${colors.borderSecondary};
`;
2017-01-09 20:58:30 +02:00
const height = (props) => props.collapsed
? remcalc(48)
: remcalc(126);
2017-01-09 22:33:32 +02:00
const shadow = (props) => props.stacked
? paper
: props.collapsed && props.headed
? boxes.bottomShaddowDarker
: boxes.bottomShaddow;
2017-01-09 14:13:12 +02:00
const Item = styled(Row)`
2017-01-09 20:58:30 +02:00
position: relative;
2017-01-09 14:13:12 +02:00
height: ${height}
2017-01-09 20:58:30 +02:00
box-shadow: ${shadow};
2017-01-09 14:13:12 +02:00
border: 1px solid ${colors.borderSecondary};
background-color: ${colors.brandSecondary};
2017-01-09 20:58:30 +02:00
margin-bottom: ${remcalc(10)};
2017-01-09 14:13:12 +02:00
`;
2017-01-09 20:58:30 +02:00
module.exports = transferProps([
'collapsed',
'headed'
], (props) => (
2017-01-09 14:13:12 +02:00
<Item name='list-item' {...props}>
{props.children}
</Item>
));