AllenYuan

src/components/App/AppLogo.jsx

Apr 27th, 2020
638
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import React from 'react';
  2. import { connect } from 'react-redux';
  3. import PropTypes from 'prop-types';
  4. import { Link } from 'react-router-dom';
  5. import styled from 'styled-components';
  6. import constants from '../constants';
  7.  
  8. // logo style
  9. const StyledLink = styled(Link)`
  10.   font-weight: ${constants.fontWeightMedium};
  11.   color: ${constants.textColorPrimary};
  12.   text-transform: uppercase;
  13.  
  14.   &:hover {
  15.     color: ${constants.textColorPrimary};
  16.     opacity: 0.6;
  17.   }
  18. `;
  19.  
  20. // render logo
  21. const AppLogo = ({ size, strings, onClick }) => (
  22.   <StyledLink to="/" onClick={onClick}>
  23.     <span style={{ fontSize: size }}>
  24.       {strings.app_name && `<${strings.app_name}/>`}
  25.     </span>
  26.   </StyledLink>
  27. );
  28.  
  29. // type enforcement
  30. AppLogo.propTypes = {
  31.   size: PropTypes.string,
  32.   strings: PropTypes.shape({}),
  33.   onClick: PropTypes.func,
  34. };
  35.  
  36. // extract strings from state
  37. const mapStateToProps = state => ({
  38.   strings: state.app.strings,
  39. });
  40.  
  41. export default connect(mapStateToProps)(AppLogo);
Advertisement
Add Comment
Please, Sign In to add comment