2017-11-27 02:09:55 +00:00
|
|
|
// @flow
|
2020-06-20 20:59:15 +00:00
|
|
|
import * as React from "react";
|
|
|
|
import styled from "styled-components";
|
2017-11-27 02:09:55 +00:00
|
|
|
|
2021-02-14 21:18:33 +00:00
|
|
|
type Props = {|
|
2019-07-08 04:40:34 +00:00
|
|
|
children: React.Node,
|
2021-02-14 21:18:33 +00:00
|
|
|
|};
|
2019-07-08 04:40:34 +00:00
|
|
|
|
|
|
|
const H3 = styled.h3`
|
2020-08-09 01:53:11 +00:00
|
|
|
border-bottom: 1px solid ${(props) => props.theme.divider};
|
2021-02-14 21:18:33 +00:00
|
|
|
margin: 12px 0;
|
2019-07-08 04:40:34 +00:00
|
|
|
line-height: 1;
|
2017-11-27 02:09:55 +00:00
|
|
|
`;
|
|
|
|
|
2021-02-14 21:18:33 +00:00
|
|
|
const Underline = styled.div`
|
2020-11-09 06:33:52 +00:00
|
|
|
margin-top: -1px;
|
2019-07-08 04:40:34 +00:00
|
|
|
display: inline-block;
|
|
|
|
font-weight: 500;
|
|
|
|
font-size: 14px;
|
|
|
|
line-height: 1.5;
|
2020-08-09 01:53:11 +00:00
|
|
|
color: ${(props) => props.theme.textSecondary};
|
|
|
|
border-bottom: 3px solid ${(props) => props.theme.textSecondary};
|
2021-02-14 21:18:33 +00:00
|
|
|
padding-top: 7px;
|
2019-07-08 04:40:34 +00:00
|
|
|
padding-bottom: 5px;
|
|
|
|
`;
|
|
|
|
|
2021-02-14 21:18:33 +00:00
|
|
|
// When sticky we need extra background coverage around the sides otherwise
|
|
|
|
// items that scroll past can "stick out" the sides of the heading
|
|
|
|
const Sticky = styled.div`
|
|
|
|
position: sticky;
|
|
|
|
top: 54px;
|
|
|
|
margin: 0 -8px;
|
|
|
|
padding: 0 8px;
|
|
|
|
background: ${(props) => props.theme.background};
|
|
|
|
transition: ${(props) => props.theme.backgroundTransition};
|
2021-02-15 23:19:51 +00:00
|
|
|
z-index: 1;
|
2021-02-14 21:18:33 +00:00
|
|
|
`;
|
|
|
|
|
2019-07-08 04:40:34 +00:00
|
|
|
const Subheading = ({ children, ...rest }: Props) => {
|
|
|
|
return (
|
2021-02-14 21:18:33 +00:00
|
|
|
<Sticky>
|
|
|
|
<H3 {...rest}>
|
|
|
|
<Underline>{children}</Underline>
|
|
|
|
</H3>
|
|
|
|
</Sticky>
|
2019-07-08 04:40:34 +00:00
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2017-11-27 02:09:55 +00:00
|
|
|
export default Subheading;
|