import * as React from "react"
import styled from "styled-components"
import { UserProfilePicture } from "../ProfilePicture"
import { StarIndicator } from "../Book/RatingStarIndicator"

const Container = styled.div`
  text-align: left;
  flex: 1 1 auto;
  border: 1px solid #e9e9e9;
  padding: 10px;
  margin: 5px;
  border-radius: 10px;
  height: 170px;
  width: 250px;
  max-width: 280px;
  background-color: white;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  font-size: 1.1rem;
  display: inline-flex;

  vertical-align: middle;

  .star-container {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
  }
  .star-icon {
    color: #f05a22;
    padding: 0 5px 0 0;
    font-size: 24px;
    font-weight: bold;
  }
  .rating {
    line-height: 22px;
    font-size: 22px;
    font-weight: bold;
  }
  .profile-wrapper {
    width: 40px;
    height: 40px;
    flex: 0 0 40px;
  }
  .review-top {
    display: flex;
    flex-direction: row;
  }
  .review-bottom {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
  }
  .comma-wrapper {
    display: block;
    padding: 0 10px 0 0;
    font-family: "Lucida Grande";
    font-size: 50px;
    font-weight: bold;
    color: #f05a22;
  }
  .review-wrapper {
    padding: 0px;
    width: 100%;
    white-space: pre-wrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
  }

  .StarIndicator {
    color: ${(props) => props.theme.pumpkin};
    margin-right: 8px;
    .jamplay-icon {
      display: inline-block;
    }
  }

  @media screen and (max-width: 600px) {
    height: 130px;
    width: 205px;
    min-width: 205px;
    padding: 5px;
    margin: 5px;
    font-size: 0.9rem;
  }
`

class ReviewItem extends React.Component<{
  message?: string
  rating: number
  profilePicture: string
}> {
  public render() {
    return (
      <Container className="ReviewHighlight__ReviewItem">
        <div className="review-top">
          <div className="comma-wrapper">“</div>
          <div className="review-wrapper">{this.props.message}</div>
        </div>
        <div className="review-bottom">
          <div className="profile-wrapper">
            <UserProfilePicture src={this.props.profilePicture} />
          </div>
          <div className="star-container">
            <StarIndicator average={this.props.rating} count={5} />
            <div className="rating">{this.props.rating}</div>
          </div>
        </div>
      </Container>
    )
  }
}

export default ReviewItem
