/**
 * Basic style for ApTheme.
 * @constructor ApBasicThemeStyle
 */

"use strict";

import React, {PropTypes as types} from 'react';
import basic from 'apeman-react-basic';
import {ApStyle} from 'apeman-react-style';
import styleContent from './style_content';

/** @lends ApBasicThemeStyle */
let ApBasicThemeStyle = React.createClass({
    propTypes: {
        scoped: types.bool,
        style: types.object,
        dominant: types.string.isRequired,
        subordinate: types.string,
        accent: types.string
    },
    getDefaultProps() {
        return {
            scoped: false,
            style: {},
            dominant: '#38E',
            subordinate: '#FFF',
            accent: '#EE3'
        }
    },
    render() {
        let s = this,
            props = s.props;

        let {dominant, subordinate, accent} = props;

        let data = {
                '.ap-theme': {}
            },
            smallMediaData = {},
            mediumMediaData = {},
            largeMediaData = {};

        let themedStyle = [
            styleContent(<basic.ApContainerStyle/>),
            styleContent(<basic.ApTabStyle highlightColor={dominant} backgroundColor={subordinate}/>),
            styleContent(<basic.ApIconStyle/>),
            styleContent(<basic.ApSpinnerStyle/>),
            styleContent(<basic.ApImageStyle/>),
            styleContent(<basic.ApNoteStyle/>),
            styleContent(<basic.ApFlexStyle/>),
            styleContent(<basic.ApTagStyle/>),
            styleContent(<basic.ApListStyle/>),
            styleContent(<basic.ApButtonStyle highlightColor={dominant} backgroundColor={subordinate}/>),
            styleContent(<basic.ApCheckboxStyle highlightColor={dominant}/>),
            styleContent(<basic.ApRadioStyle highlightColor={dominant}/>),
            styleContent(<basic.ApArticleStyle />),
            styleContent(<basic.ApSectionStyle />),
            styleContent(<basic.ApAsideStyle />),
            styleContent(<basic.ApLabelStyle />),
            styleContent(<basic.ApTextStyle highlightColor={dominant}/>),
            styleContent(<basic.ApPasswordStyle highlightColor={dominant}/>),
            styleContent(<basic.ApUploadStyle highlightColor={dominant}/>),
            styleContent(<basic.ApLinksStyle />),
            styleContent(<basic.ApMenuStyle />),
            styleContent(<basic.ApInfoStyle />),
            styleContent(<basic.ApFrameStyle />),
            styleContent(<basic.ApCaptchaStyle />),
            styleContent(<basic.ApFieldStyle/>),
            styleContent(<basic.ApToastStyle/>),
            styleContent(<basic.ApBodyStyle/>),
            styleContent(<basic.ApDropdownStyle highlightColor={dominant}/>),
            styleContent(<basic.ApHeaderStyle highlightColor={dominant} backgroundColor={subordinate}/>),
            styleContent(<basic.ApMainStyle/>),
            styleContent(<basic.ApFooterStyle/>),
            styleContent(<basic.ApModalStyle/>),
            styleContent(<basic.ApDialogStyle/>),
            styleContent(<basic.ApYesnoDialogStyle/>),
            styleContent(<basic.ApFormStyle/>),
            styleContent(<basic.ApNoticeStyle/>),
            styleContent(<basic.ApSliderStyle highlightColor={dominant}/>),
            styleContent(<basic.ApRangeStyle highlightColor={dominant}/>),
            styleContent(<basic.ApAccordionStyle highlightColor={dominant}/>),
            styleContent(<basic.ApPageStyle />),
            styleContent(<basic.ApJumbotronStyle highlightColor={dominant} backgroundColor={subordinate}/>),
            styleContent(<basic.ApViewStyle highlightColor={dominant} backgroundColor={subordinate}/>),
            styleContent(<basic.ApViewStackStyle />),
            styleContent(<basic.ApDevtoolStyle />)
        ].join('');

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

module.exports = ApBasicThemeStyle;
