2017-05-18 21:21:33 +03:00
|
|
|
import React from 'react';
|
|
|
|
import { Broadcast, Subscriber } from 'react-broadcast';
|
|
|
|
import remcalc from 'remcalc';
|
|
|
|
import PropTypes from 'prop-types';
|
2017-08-14 13:21:45 +03:00
|
|
|
import is, { isNot } from 'styled-is';
|
2017-05-18 21:21:33 +03:00
|
|
|
import Baseline from '../baseline';
|
|
|
|
import Card from './card';
|
|
|
|
|
2017-05-25 17:59:58 +03:00
|
|
|
const StyledCard = Card.extend`
|
2017-05-18 21:21:33 +03:00
|
|
|
position: absolute;
|
2017-06-28 20:36:54 +03:00
|
|
|
flex-direction: row;
|
2017-05-18 21:21:33 +03:00
|
|
|
|
|
|
|
background-color: ${props => props.theme.primary};
|
|
|
|
border: solid ${remcalc(1)} ${props => props.theme.primaryDesaturatedActive};
|
|
|
|
box-shadow: none;
|
|
|
|
|
|
|
|
width: calc(100% + ${remcalc(2)});
|
2017-06-02 04:15:06 +03:00
|
|
|
margin: ${remcalc(-1)} ${remcalc(-1)} 0 ${remcalc(-1)};
|
2017-07-27 20:44:29 +03:00
|
|
|
|
2017-08-14 13:21:45 +03:00
|
|
|
${isNot('active')`
|
2017-07-27 20:44:29 +03:00
|
|
|
background-color: ${props => props.theme.disabled};
|
|
|
|
border-color: ${props => props.theme.grey};
|
|
|
|
`};
|
2017-05-18 21:21:33 +03:00
|
|
|
`;
|
|
|
|
|
|
|
|
const Header = ({ children, ...rest }) => {
|
|
|
|
const render = value => {
|
2017-08-14 13:21:45 +03:00
|
|
|
const { active } = value;
|
2017-07-27 20:44:29 +03:00
|
|
|
|
2017-05-18 21:21:33 +03:00
|
|
|
const newValue = {
|
|
|
|
...value,
|
|
|
|
fromHeader: true
|
|
|
|
};
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Broadcast channel="card" value={newValue}>
|
2017-08-08 13:07:18 +03:00
|
|
|
<StyledCard
|
|
|
|
name="card-header"
|
2017-08-14 13:21:45 +03:00
|
|
|
active={active}
|
2017-08-08 13:07:18 +03:00
|
|
|
collapsed
|
|
|
|
headed
|
|
|
|
{...rest}
|
|
|
|
>
|
2017-05-18 21:21:33 +03:00
|
|
|
{children}
|
|
|
|
</StyledCard>
|
|
|
|
</Broadcast>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2017-08-28 22:21:08 +03:00
|
|
|
return <Subscriber channel="card">{render}</Subscriber>;
|
2017-05-18 21:21:33 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
Header.propTypes = {
|
|
|
|
children: PropTypes.node
|
|
|
|
};
|
|
|
|
|
|
|
|
export default Baseline(Header);
|