TitleSection.tsx 2.2 KB

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