/**
 * Style for ApYesnoDialog.
 * @class ApYesnoDialogStyle
 */

'use strict'

import React, {Component, PropTypes as types} from 'react'
import {ApStyle} from 'apeman-react-style'

/** @lends ApYesnoDialogStyle */
class ApYesnoDialogStyle extends Component {
  render () {
    const s = this
    let { props } = s

    let { all, small, medium, large } = ApYesnoDialogStyle.styleData(props)

    return (
      <ApStyle data={ Object.assign(all, props.style) }
               smallMediaData={ small }
               mediumMediaData={ medium }
               largeMediaData={ large }
      >{ props.children }</ApStyle>
    )
  }
}

Object.assign(ApYesnoDialogStyle, {
  propTypes: {
    style: types.object,
    buttonHeight: types.number,
    highlightColor: types.string
  },
  defaultProps: {
    style: {},
    buttonHeight: 40,
    borderColor: '#D0D0D0',
    highlightColor: '#38E'
  },
  styleData (config) {
    let {
      buttonHeight,
      borderColor,
      highlightColor
    } = config
    return {
      all: {
        '.ap-yesno-dialog .ap-dialog-body': {
          paddingBottom: `${buttonHeight + 8}px`
        },
        '.ap-yesno-dialog .ap-dialog-close-button-icon': {
          display: 'none'
        },
        '.ap-yesno-dialog-control': {
          display: 'flex',
          position: 'absolute',
          left: 0,
          right: 0,
          bottom: 0,
          boxSizing: 'border-box',
          overflowX: 'hidden',
          justifyContent: 'flex-end',
          padding: '0 8px',
          backgroundColor: 'rgba(255,255,255,0.9)'
        },
        '.ap-yesno-dialog-button': {
          display: 'block',
          maxWidth: '50%',
          textAlign: 'center',
          margin: '0 -1px',
          color: `${highlightColor}`
        },
        '.ap-yesno-dialog-button .ap-touchable': {
          padding: '4px 16px'
        },
        '.ap-yesno-dialog-button-text': {
          display: 'inline-block',
          width: '100%',
          boxSizing: 'border-box',
          lineHeight: `${buttonHeight}px`
        },
        '.ap-yesno-dialog-button:hover': {
          cursor: 'pointer',
          opacity: 0.9
        },
        '.ap-yesno-dialog-button:active': {
          opacity: 0.6
        }
      },
      small: {},
      medium: {},
      large: {}
    }
  }
})

export default ApYesnoDialogStyle
