HeaderLeftMenu.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. import React from 'react';
  2. import PropTypes from 'prop-types';
  3. import { bindActionCreators } from 'redux';
  4. import { connect } from 'react-redux';
  5. import styled from 'styled-components';
  6. import Router from 'next/router';
  7. import HeaderMenuItem from './HeaderMenuItem';
  8. import { showPageLoading } from '../../actions';
  9. const List = styled.ul`
  10. display: flex;
  11. align-items: flex-end;
  12. list-style: none;
  13. margin: 0 0 3px;
  14. padding: 0;
  15. @media only screen and (max-width: 488px) {
  16. display: none;
  17. }
  18. `;
  19. const HeaderLeftMenu = props => {
  20. const goTo = e => {
  21. e.preventDefault();
  22. const path = e.currentTarget.getAttribute('href');
  23. if (!path || window.location.pathname === path) return;
  24. props.showPageLoading();
  25. Router.push(path);
  26. };
  27. return (
  28. <List>
  29. <HeaderMenuItem>
  30. <a
  31. href="//github.com/thedevs-network/kutt"
  32. target="_blank"
  33. rel="noopener noreferrer"
  34. title="GitHub"
  35. >
  36. GitHub
  37. </a>
  38. </HeaderMenuItem>
  39. <HeaderMenuItem>
  40. <a href="/report" title="Report abuse" onClick={goTo}>
  41. Report
  42. </a>
  43. </HeaderMenuItem>
  44. </List>
  45. );
  46. };
  47. HeaderLeftMenu.propTypes = {
  48. showPageLoading: PropTypes.func.isRequired,
  49. };
  50. const mapDispatchToProps = dispatch => ({
  51. showPageLoading: bindActionCreators(showPageLoading, dispatch),
  52. });
  53. export default connect(
  54. null,
  55. mapDispatchToProps
  56. )(HeaderLeftMenu);