AllenYuan

Untitled

May 31st, 2020
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. import React from 'react';
  2. import PropTypes from 'prop-types';
  3. import { connect } from 'react-redux';
  4. import { Link } from 'react-router-dom';
  5. import styled from 'styled-components';
  6. import FlatButton from 'material-ui/FlatButton';
  7. import Spinner from '../Spinner';
  8.  
  9. const StyledFlatButton = styled(FlatButton)`
  10. min-width: 30px !important;
  11. & > div > span {
  12. display: inline-block;
  13. max-width: 90px;
  14. overflow: hidden;
  15. text-overflow: ellipsis;
  16. text-transform: none !important;
  17. white-space: nowrap;
  18. font-size: 16px !important;
  19. padding-right: 10px !important;
  20. padding-left: 0 !important;
  21. }
  22. `;
  23.  
  24. // link to user profile
  25. const LoggedIn = ({ playerId, style, strings }) => {
  26. // fetching user => spinner
  27. if (!playerId) {
  28. return <Spinner color="#fff" size={0.5} />
  29. }
  30. return (
  31. <Link style={style} to={`/players/${playerId}`}>
  32. <StyledFlatButton
  33. label={strings.app_my_profile}
  34. hoverColor="transparent"
  35. />
  36. </Link>
  37. );
  38. };
  39.  
  40. LoggedIn.propTypes = {
  41. playerId: PropTypes.number,
  42. style: PropTypes.shape({}),
  43. strings: PropTypes.shape({}),
  44. };
  45.  
  46. const mapStateToProps = state => ({
  47. strings: state.app.strings,
  48. });
  49.  
  50. export default connect(mapStateToProps)(LoggedIn);
Add Comment
Please, Sign In to add comment