TitleSection.tsx 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. import React from "react";
  2. import styled from "styled-components";
  3. interface Props {
  4. children: React.ReactNode;
  5. icon?: any;
  6. iconWidth?: string;
  7. capitalize?: boolean;
  8. handleNavBack?: () => void;
  9. }
  10. const TitleSection: React.FC<Props> = ({
  11. children,
  12. icon,
  13. iconWidth,
  14. capitalize,
  15. handleNavBack,
  16. }) => {
  17. return (
  18. <StyledTitleSection>
  19. {handleNavBack && (
  20. <BackButton>
  21. <i className="material-icons" onClick={handleNavBack}>
  22. keyboard_backspace
  23. </i>
  24. </BackButton>
  25. )}
  26. {icon && <Icon width={iconWidth} src={icon} />}
  27. <StyledTitle capitalize={capitalize}>{children}</StyledTitle>
  28. </StyledTitleSection>
  29. );
  30. };
  31. export default TitleSection;
  32. const BackButton = styled.div`
  33. > i {
  34. cursor: pointer;
  35. font-size 24px;
  36. color: #969Fbbaa;
  37. margin-right: 10px;
  38. padding: 3px;
  39. margin-left: 0px;
  40. border-radius: 100px;
  41. :hover {
  42. background: #ffffff11;
  43. }
  44. }
  45. `;
  46. const StyledTitleSection = styled.div`
  47. margin-bottom: 15px;
  48. display: flex;
  49. align-items: center;
  50. `;
  51. const Icon = styled.img<{ width: string }>`
  52. width: ${(props) => props.width || "28px"};
  53. margin-right: 16px;
  54. `;
  55. const StyledTitle = styled.div<{ capitalize: boolean }>`
  56. font-size: 24px;
  57. font-weight: 600;
  58. user-select: text;
  59. text-transform: ${(props) => (props.capitalize ? "capitalize" : "")};
  60. display: flex;
  61. align-items: center;
  62. > i {
  63. margin-left: 10px;
  64. cursor: pointer;
  65. font-size: 18px;
  66. color: #858faaaa;
  67. padding: 5px;
  68. border-radius: 100px;
  69. :hover {
  70. background: #ffffff11;
  71. }
  72. margin-bottom: -3px;
  73. }
  74. > a {
  75. > i {
  76. display: flex;
  77. align-items: center;
  78. margin-bottom: -2px;
  79. font-size: 18px;
  80. margin-left: 15px;
  81. color: #858faaaa;
  82. :hover {
  83. color: #aaaabb;
  84. }
  85. }
  86. }
  87. `;