/**
 * Style for ionicons icon.
 * @class ApIonIconStyle
 */

'use strict'

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

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

    let styles = readAsset('css/ionicons-inline.css')

    return (
      <ApStyle data={ Object.assign(data, props.style) }
               smallMediaData={ smallMediaData }
               mediumMediaData={ mediumMediaData }
               largeMediaData={ largeMediaData }
      >{ String(styles) }{ props.children }</ApStyle>
    )
  },

  componentDidMount () {
    console.warn(
      `
ApIonIconStyle is now deprecated. Please consider using CDN like following:
"${ICON_ICONS_CDN}"
      `
    )
  }
})

export default ApIonIconStyle
