HeaderLogo.js 1.0 KB

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