/**
 * Style for font awesome icon.
 * @class ApFaIconStyle
 */

'use strict'

import React, {PropTypes as types} from 'react'
import {ApStyle} from 'apeman-react-style'
import readAsset from './assets/read_asset'
import {FONT_AWESOME_CDN} from './cdn_constants'

/** @lends ApFaIconStyle */
const ApFaIconStyle = React.createClass({
  propTypes: {
    style: types.object
  },
  getDefaultProps () {
    return {
      style: {}
    }
  },
  render () {
    const s = this
    let { props } = s
    let data = {
      '.ap-fa-icon': {}
    }
    let smallMediaData = {}
    let mediumMediaData = {}
    let largeMediaData = {}

    let styles = readAsset('css/font-awesome-inline.css')
    return (
      <ApStyle data={ Object.assign(data, props.style) }
               smallMediaData={ smallMediaData }
               mediumMediaData={ mediumMediaData }
               largeMediaData={ largeMediaData }
      >{ String(styles) }{ props.children }</ApStyle>
    )
  },
  componentDidMount () {
    console.warn(
      `
ApFaIconStyle is now deprecated. Please consider using CDN like following:
"${FONT_AWESOME_CDN}"
      `
    )
  }
})

export default ApFaIconStyle
