2017-10-09 21:01:34 +03:00
|
|
|
import { Subscriber } from 'joy-react-broadcast';
|
2017-02-20 18:15:36 +02:00
|
|
|
import styled from 'styled-components';
|
2017-05-18 21:21:33 +03:00
|
|
|
import Baseline from '../baseline';
|
|
|
|
import typography from '../typography';
|
|
|
|
import remcalc from 'remcalc';
|
2017-09-07 18:29:41 +03:00
|
|
|
import is from 'styled-is';
|
2017-05-18 21:21:33 +03:00
|
|
|
import PropTypes from 'prop-types';
|
2017-02-20 18:15:36 +02:00
|
|
|
import Title from './title';
|
|
|
|
import React from 'react';
|
2017-01-11 16:13:58 +02:00
|
|
|
|
2017-01-09 14:13:12 +02:00
|
|
|
const Span = styled.span`
|
2017-02-20 18:15:36 +02:00
|
|
|
display: inline-block;
|
2017-01-09 14:13:12 +02:00
|
|
|
flex-direction: column;
|
|
|
|
|
2017-03-03 17:29:03 +02:00
|
|
|
${typography.normal};
|
2017-01-09 14:13:12 +02:00
|
|
|
font-style: normal;
|
|
|
|
font-stretch: normal;
|
2017-01-12 21:04:52 +02:00
|
|
|
font-size: ${remcalc(14)};
|
2017-01-10 00:14:10 +02:00
|
|
|
|
|
|
|
justify-content: flex-end;
|
2017-02-20 18:15:36 +02:00
|
|
|
|
|
|
|
${is('collapsed')`
|
|
|
|
display: flex;
|
|
|
|
`};
|
2017-10-09 21:01:34 +03:00
|
|
|
|
2017-10-09 16:35:52 +03:00
|
|
|
${is('disabled')`
|
|
|
|
color: ${props => props.theme.text};
|
|
|
|
`};
|
2017-02-27 17:41:08 +02:00
|
|
|
|
|
|
|
${is('fromHeader')`
|
2017-05-18 21:21:33 +03:00
|
|
|
color: ${props => props.theme.white};
|
2017-02-27 17:41:08 +02:00
|
|
|
`};
|
2017-01-10 00:14:10 +02:00
|
|
|
`;
|
|
|
|
|
2017-05-25 17:59:58 +03:00
|
|
|
const StyledTitle = Title.extend`
|
2017-02-20 18:15:36 +02:00
|
|
|
display: inline-block;
|
|
|
|
padding: 0 ${remcalc(18)};
|
|
|
|
|
2017-03-03 17:29:03 +02:00
|
|
|
${typography.normal};
|
2017-02-27 17:41:08 +02:00
|
|
|
|
2017-02-20 18:15:36 +02:00
|
|
|
${is('collapsed')`
|
|
|
|
display: flex;
|
|
|
|
padding: 0;
|
|
|
|
`};
|
2017-01-09 14:13:12 +02:00
|
|
|
`;
|
|
|
|
|
2017-05-18 21:21:33 +03:00
|
|
|
const Subtitle = ({ children, ...props }) => {
|
2017-08-28 22:21:08 +03:00
|
|
|
const render = ({ active = true, fromHeader = false, collapsed = false }) => (
|
2017-02-27 17:41:08 +02:00
|
|
|
<StyledTitle
|
2017-05-18 21:21:33 +03:00
|
|
|
name="card-subtitle"
|
2017-02-27 17:41:08 +02:00
|
|
|
fromHeader={fromHeader}
|
|
|
|
collapsed={collapsed}
|
2017-08-14 13:21:45 +03:00
|
|
|
active={active}
|
2017-02-27 17:41:08 +02:00
|
|
|
{...props}
|
|
|
|
>
|
|
|
|
<Span fromHeader={fromHeader} collapsed={collapsed}>
|
|
|
|
{children}
|
|
|
|
</Span>
|
2017-08-28 22:21:08 +03:00
|
|
|
</StyledTitle>
|
2017-02-27 17:41:08 +02:00
|
|
|
);
|
2017-08-28 22:21:08 +03:00
|
|
|
|
|
|
|
return <Subscriber channel="card">{render}</Subscriber>;
|
2017-02-27 17:41:08 +02:00
|
|
|
};
|
|
|
|
|
2017-01-09 14:13:12 +02:00
|
|
|
Subtitle.propTypes = {
|
2017-05-18 21:21:33 +03:00
|
|
|
children: PropTypes.node,
|
|
|
|
collapsed: PropTypes.bool,
|
|
|
|
fromHeader: PropTypes.bool
|
2017-01-09 14:13:12 +02:00
|
|
|
};
|
|
|
|
|
2017-05-18 21:21:33 +03:00
|
|
|
export default Baseline(Subtitle);
|