HeaderLogo.tsx 935 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import React, { FC } from "react";
  2. import Router from "next/router";
  3. import styled from "styled-components";
  4. const LogoImage = styled.div`
  5. & > a {
  6. position: relative;
  7. display: flex;
  8. align-items: center;
  9. margin: 0 8px 0 0;
  10. font-size: 22px;
  11. font-weight: bold;
  12. text-decoration: none;
  13. color: inherit;
  14. transition: border-color 0.2s ease-out;
  15. }
  16. @media only screen and (max-width: 488px) {
  17. a {
  18. font-size: 18px;
  19. }
  20. }
  21. img {
  22. width: 18px;
  23. margin-right: 11px;
  24. }
  25. `;
  26. const HeaderLogo: FC = () => {
  27. const goTo = e => {
  28. e.preventDefault();
  29. const path = e.target.getAttribute("href");
  30. if (window.location.pathname === path) return;
  31. Router.push(path);
  32. };
  33. return (
  34. <LogoImage>
  35. <a href="/" title="Homepage" onClick={goTo}>
  36. <img src="/images/logo.svg" alt="" />
  37. Kutt.it
  38. </a>
  39. </LogoImage>
  40. );
  41. };
  42. export default HeaderLogo;