/**
 * ThreadDetailStyle component
 *
 * Generated by coz on 2016-12-31,
 * from a template provided by apeman-asset-templates.
 *
 * @function ThreadDetailStyle
 */
'use strict'

import React from 'react'
import defineDebug from 'debug'
import { ThreadColorCodes } from 'ore-fol-codes'
import { ApStyle } from 'apeman-react-basic'
import { isDark } from 'acolor'
import { prefixedStyle } from 'ore-fol-helpers'

const debug = defineDebug('project:fragment:thread-style')

const { COLOR_A: DEFAULT_COLOR } = ThreadColorCodes

/** @lends ThreadDetailStyle */
const ThreadDetailStyle = ({
  prefix = '.thread-detail',
  color = DEFAULT_COLOR
}) => {
  let monoColor = isDark(color) ? 'white' : '#333'
  let transparentColor = 'transparent'
  let inheritColor = 'inherit'
  let data = prefixedStyle(prefix, {
    '.thread-panel': {
      background: color,
      color: monoColor
    },
    '.thread-panel .ap-button': {
      color: monoColor,
      background: transparentColor,
      borderColor: transparentColor
    },
    '.thread-panel-source-link': {
      color: monoColor
    },
    '.ap-button': {
      color: color,
      borderColor: color,
      background: monoColor
    },
    '.ap-button.ap-button-primary': {
      backgroundColor: color,
      borderColor: color,
      color: monoColor
    },
    '.post-list-item-button-row .ap-button': {
      color: inheritColor,
      backgroundColor: transparentColor
    },
    '.star-button.ap-button.star-button-active .star-button-icon': {
      color
    },
    '.post-banned-blocker .ap-button': {
      border: 'none',
      backgroundColor: transparentColor
    },
    '.thread-panel-meta-tag': {
      color: monoColor
    },
    '.tag-label-button.ap-button': {
      color: inheritColor,
      background: transparentColor
    },
    '.ap-text,.ap-password': {
      outlineColor: color
    }
  })
  return (
    <ApStyle className='thread-detail-style'
             data-prefix={ prefix }
             data={ data }
    />
  )
}

export default ThreadDetailStyle
