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

81 lines
1.4 KiB
JavaScript
Raw Normal View History

import isString from 'lodash.isstring';
import { Baseline } from '../../shared/composers';
import { colors } from '../../shared/constants';
import { remcalc, is } from '../../shared/functions';
import styled from 'styled-components';
import React from 'react';
const xs = (props) => props.collapsed
? 6
: 12;
2017-01-09 14:13:12 +02:00
const Container = styled.div`
font-size: ${remcalc(16)};
font-weight: 600;
line-height: 1.5;
color: ${colors.base.secondary};
2017-01-09 14:13:12 +02:00
display: flex;
flex-direction: row;
justify-content: flex-start;
2017-01-09 14:13:12 +02:00
flex-grow: 2;
width: 100%;
2017-01-09 14:13:12 +02:00
padding: ${remcalc(12)} ${remcalc(18)} 0 ${remcalc(18)};
2017-01-09 14:13:12 +02:00
${is('collapsed')`
flex-grow: 0;
flex-direction: column;
width: auto;
justify-content: center;
padding: 0 ${remcalc(18)};
`};
${is('fromHeader')`
color: ${colors.base.primary};
`};
`;
2017-01-09 14:13:12 +02:00
const Span = styled.span`
display: inline-block;
2017-01-09 14:13:12 +02:00
flex-direction: column;
justify-content: center;
${is('collapsed')`
display: flex;
`};
2017-01-09 14:13:12 +02:00
`;
const Title = ({
children,
collapsed,
...props
}) => {
const _children = !isString(children) ? children : (
<Span>{children}</Span>
2017-01-09 14:13:12 +02:00
);
return (
<Container
collapsed={collapsed}
2017-01-09 14:13:12 +02:00
name='list-item-title'
xs={xs({
collapsed
})}
2017-01-09 14:13:12 +02:00
{...props}
>
{_children}
</Container>
);
};
Title.propTypes = {
children: React.PropTypes.node,
collapsed: React.PropTypes.bool
};
export default Baseline(
2017-02-15 03:19:26 +02:00
Title
);