import React, { Component, PropTypes } from "react"

import SVGIcon from "../SVGIcon"
import Avatar from "../Avatar"

import getAuthorUri from "../getAuthorUri"

export default class Author extends Component {

  static contextTypes = {
    metadata: PropTypes.object.isRequired,
  }

  static propTypes = {
    className: PropTypes.string,
    author: PropTypes.string.isRequired,
    afterName: PropTypes.string,
    isPost: PropTypes.bool,
  }

  render() {
    const { metadata } = this.context
    const i18n = metadata.i18n
    const author = metadata.contributors.getContributor(this.props.author)

    return (
      <div className={`putainde-Author ${this.props.className}`}>

        <Avatar
          author={author.login}
          className="putainde-Author-picture"
        />

        <div className="putainde-Author-description">
          <div className="putainde-Author-title">
            <h3 className="putainde-Author-name">
              {
                this.props.isPost &&
                <span className="putainde-WrittenBy">
                  {`${i18n.writtenBy} `}
                </span>
              }
              <a
                className="putainde-Link"
                href={getAuthorUri(author)}
              >
                {author.login}
              </a>
              {
                this.props.afterName &&
                <span className="putainde-Author-afterName">
                  {` ${this.props.afterName}`}
                </span>
              }
            </h3>

            <div className="putainde-Author-social">
              {
                author.url &&
                <a
                  href={getAuthorUri(author)}
                  className="r-Tooltip r-Tooltip--top"
                  data-r-tooltip="Website"
                >
                  <SVGIcon
                    className="putainde-Icon"
                    svg={require(`icons/home.svg`)}
                    cleanup
                  />
                </a>
              }
              {
                author.twitter &&
                <a
                  href={getAuthorUri(author, "twitter")}
                  className="r-Tooltip r-Tooltip--top"
                  data-r-tooltip="Twitter"
                >
                  <SVGIcon
                    className="putainde-Icon"
                    svg={require(`icons/twitter.svg`)}
                    cleanup
                  />
                </a>
              }
              {
                author.login &&
                <a
                  href={getAuthorUri(author, "github")}
                  className="r-Tooltip r-Tooltip--top"
                  data-r-tooltip="Github"
                >
                  <SVGIcon
                    className="putainde-Icon"
                    svg={require(`icons/github.svg`)}
                    cleanup
                  />
                </a>
              }
            </div>
          </div>

          <p className="putainde-Author-bio">
            {
              (author.fr && author.fr.bio && author.fr.bio.long) &&
              author.fr.bio.long
              /* @todo add new lines betwee lines */
            }
          </p>
        </div>
      </div>
    )
  }
}

@@ -305,25 +305,22 @@
 = %7B%0A    
-className
+author
 : PropTy
@@ -333,20 +333,34 @@
 ring
-,%0A    author
+.isRequired,%0A    className
 : Pr
@@ -369,35 +369,24 @@
 Types.string
-.isRequired
 ,%0A    afterN
@@ -436,16 +436,87 @@
 s.bool,%0A
+    bio: PropTypes.bool,%0A  %7D%0A%0A  static defaultProps = %7B%0A    bio: true,%0A
   %7D%0A%0A  r
@@ -594,16 +594,89 @@
 ta.i18n%0A
+    const %7B%0A      afterName,%0A      isPost,%0A      bio,%0A    %7D = this.props%0A
     cons
@@ -1115,27 +1115,16 @@
         
-this.props.
 isPost &
@@ -1396,16 +1396,17 @@
        %7B
+ 
 author.l
@@ -1401,32 +1401,33 @@
   %7B author.login
+ 
 %7D%0A              
@@ -1463,27 +1463,16 @@
         
-this.props.
 afterNam
@@ -1560,27 +1560,16 @@
    %7B%60 $%7B
-this.props.
 afterNam
@@ -3067,16 +3067,49 @@
 %3C/div%3E%0A%0A
+          %7B%0A            bio &&%0A  
         
@@ -3150,32 +3150,34 @@
 o%22%3E%0A            
+  
 %7B%0A              
@@ -3176,16 +3176,18 @@
         
+ 
+ 
 (author.
@@ -3242,24 +3242,26 @@
             
+  
 author.fr.bi
@@ -3281,16 +3281,18 @@
         
+ 
+ 
 /* @todo
@@ -3322,16 +3322,18 @@
 ines */%0A
+  
         
@@ -3352,13 +3352,27 @@
     
+  
 %3C/p%3E%0A
+          %7D%0A
     

Add ability to disable Author bio in Author component