Header.tsx 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. import DynamicLink from "components/DynamicLink";
  2. import React from "react";
  3. import styled from "styled-components";
  4. import TitleSection from "components/TitleSection";
  5. import leftArrow from "assets/left-arrow.svg";
  6. type Props = {
  7. last_updated: string;
  8. back_link: string;
  9. name: string;
  10. icon: string;
  11. inline_title_items?: React.ReactNodeArray;
  12. sub_title_items?: React.ReactNodeArray;
  13. materialIconClass?: string;
  14. };
  15. const Header: React.FunctionComponent<Props> = (props) => {
  16. const {
  17. last_updated,
  18. back_link,
  19. icon,
  20. name,
  21. inline_title_items,
  22. sub_title_items,
  23. materialIconClass,
  24. } = props;
  25. return (
  26. <>
  27. <BreadcrumbRow>
  28. <Breadcrumb to={back_link}>
  29. <ArrowIcon src={leftArrow} />
  30. <Wrap>Back</Wrap>
  31. </Breadcrumb>
  32. </BreadcrumbRow>
  33. <HeaderWrapper>
  34. <Title
  35. icon={icon}
  36. iconWidth="25px"
  37. materialIconClass={materialIconClass}
  38. >
  39. {name}
  40. <Flex>{inline_title_items}</Flex>
  41. </Title>
  42. {sub_title_items || (
  43. <InfoWrapper>
  44. <InfoText>Last updated {last_updated}</InfoText>
  45. </InfoWrapper>
  46. )}
  47. </HeaderWrapper>
  48. </>
  49. );
  50. };
  51. export default Header;
  52. const Wrap = styled.div`
  53. z-index: 999;
  54. `;
  55. const ArrowIcon = styled.img`
  56. width: 15px;
  57. margin-right: 8px;
  58. opacity: 50%;
  59. `;
  60. const BreadcrumbRow = styled.div`
  61. width: 100%;
  62. display: flex;
  63. justify-content: flex-start;
  64. `;
  65. const Breadcrumb = styled(DynamicLink)`
  66. color: #aaaabb88;
  67. font-size: 13px;
  68. margin-bottom: 15px;
  69. display: flex;
  70. align-items: center;
  71. margin-top: -10px;
  72. z-index: 999;
  73. padding: 5px;
  74. padding-right: 7px;
  75. border-radius: 5px;
  76. cursor: pointer;
  77. :hover {
  78. background: #ffffff11;
  79. }
  80. `;
  81. const HeaderWrapper = styled.div`
  82. position: relative;
  83. margin-bottom: 10px;
  84. `;
  85. const InfoWrapper = styled.div`
  86. display: flex;
  87. align-items: center;
  88. width: auto;
  89. justify-content: space-between;
  90. `;
  91. const InfoText = styled.span`
  92. font-size: 13px;
  93. color: #aaaabb66;
  94. `;
  95. const Title = styled(TitleSection)`
  96. font-size: 16px;
  97. margin-top: 4px;
  98. `;
  99. const Flex = styled.div`
  100. display: flex;
  101. align-items: center;
  102. margin: 10px 0;
  103. `;