daily pastebin goal
69%
SHARE
TWEET

Untitled

a guest May 27th, 2018 54 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import React, { Component } from 'react';
  2. import PropTypes from 'prop-types'
  3. import { Route } from 'react-router-dom'
  4.  
  5. import Tooltip from "../functional/Tooltip"
  6. import Image from "../statics/Image"
  7.  
  8. import Capitalize from "../../functions/Capitalize"
  9. import urlalize from "../../functions/urlalize"
  10. class Book extends Component {
  11.     constructor(props) {
  12.         super(props)
  13.     }
  14.  
  15.     render() {
  16.         let title = this.props.book.title;
  17.         let banner = this.props.book.banner;
  18.         let tags = this.props.book.tags;
  19.         let price = Math.floor(this.props.book.price * 267) + "Ft";
  20.         let id = this.props.book.id;
  21.         let description = this.props.book.description.substring(0,200);
  22.         let difficulty = this.props.book.rate
  23.         description = description + "...";
  24.         let language = Capitalize(this.props.book.language);
  25.         let stars = []
  26.         for(var i = 0; i < difficulty; i++){
  27.             stars.push(i)
  28.         }
  29.         return (
  30.             <Route render={({ history}) => (
  31.             <div className="book-container" onClick={() => { history.push('/book/' + urlalize(title)) }}>
  32.                 <div className="img-container">
  33.                     <Image src={"/static/images/books/"+banner+".jpg"} alt={banner} />
  34.                 </div>
  35.                 <div className="data">
  36.                     <span className="title">{title}</span>  
  37.                     <div className="tags">
  38.                         <div className="tag-container">
  39.                             {tags.map((tag, i) => <span key={i}>{tag}</span>)}
  40.                         </div>
  41.                     </div>
  42.                     <div className="description">{description}</div>  
  43.                     <div className="difficulty">{difficulty ? stars.map((star, i) => <span key={i}>&#9733;</span>) : ""}</div>
  44.                 </div>
  45.             </div>
  46.             )} />
  47.         )
  48.     }
  49. }
  50.  
  51. export default Book
  52.  
  53. Book.contextTypes = {
  54.   store: PropTypes.object,
  55.   functions: PropTypes.object
  56. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top