React = require 'react'
PropTypes = require 'prop-types'
createClass = require 'create-react-class'


{div, ul, li, header, p} = React.DOM


Note = createClass

  displayName: 'Note'

  propTypes:
    className: PropTypes.string
    headerText: PropTypes.string
    values: PropTypes.oneOfType [
      PropTypes.string
      PropTypes.array
    ]

  getDefaultProps: ->
    className: ''
    headerText: ''

  render: ->
    {values, headerText, className, children} = @props
    noteItems = []

    if typeof values is 'object'
      for value, index in values
        noteItems.push li {
          key: index
        }, value

    div {
      className: "note #{className}"
    }, children or [
      header {
        key: 'header'
        className: 'notes-header'
      }, headerText if headerText
      ul {
        key: 'list'
        className: 'notes-list'
      }, noteItems if typeof values is 'object'
      p {
        key: 'note'
        className: 'notes-text'
      }, values if typeof values is 'string'
    ]


module.exports = Note