mirror of
https://github.com/yldio/copilot.git
synced 2024-11-10 21:30:06 +02:00
f3e531dbd8
styled-components@2 exposes a new `.extend`[1] API. It is less problematic than styled(Parent). [1]: https://www.styled-components.com/docs/basics#extending-styles
52 lines
1.1 KiB
JavaScript
52 lines
1.1 KiB
JavaScript
import React from 'react';
|
|
import styled from 'styled-components';
|
|
import { Broadcast, Subscriber } from 'react-broadcast';
|
|
import remcalc from 'remcalc';
|
|
import PropTypes from 'prop-types';
|
|
import Baseline from '../baseline';
|
|
import Card from './card';
|
|
|
|
const StyledCard = Card.extend`
|
|
position: absolute;
|
|
|
|
background-color: ${props => props.theme.primary};
|
|
border: solid ${remcalc(1)} ${props => props.theme.primaryDesaturatedActive};
|
|
box-shadow: none;
|
|
|
|
width: calc(100% + ${remcalc(2)});
|
|
margin: 0;
|
|
|
|
top: ${remcalc(-1)};
|
|
left: ${remcalc(-1)};
|
|
right: ${remcalc(-1)};
|
|
`;
|
|
|
|
const Header = ({ children, ...rest }) => {
|
|
const render = value => {
|
|
const newValue = {
|
|
...value,
|
|
fromHeader: true
|
|
};
|
|
|
|
return (
|
|
<Broadcast channel="card" value={newValue}>
|
|
<StyledCard name="card-header" collapsed headed {...rest}>
|
|
{children}
|
|
</StyledCard>
|
|
</Broadcast>
|
|
);
|
|
};
|
|
|
|
return (
|
|
<Subscriber channel="card">
|
|
{render}
|
|
</Subscriber>
|
|
);
|
|
};
|
|
|
|
Header.propTypes = {
|
|
children: PropTypes.node
|
|
};
|
|
|
|
export default Baseline(Header);
|