content: import React from 'react';
  import {BaseMixin, ElementaryMixin, ContentMixin} from '../common/common.js';
  import Button from './button.js';
  
  import './button-switch.less';
  
  export const ButtonSwitch = React.createClass({
  
    //@@viewOn:mixins
    mixins: [
      BaseMixin,
      ElementaryMixin,
      ContentMixin
    ],
    //@@viewOff:mixins
  
    //@@viewOn:statics
    statics: {
      tagName: 'UU5.Bricks.ButtonSwitch',
      classNames: {
        main: 'uu5-bricks-button-switch'
      }
    },
    //@@viewOff:statics
  
    //@@viewOn:propTypes
    propTypes: {
      onProps: React.PropTypes.object,
      offProps: React.PropTypes.object,
      switchedOn: React.PropTypes.bool,
      props: React.PropTypes.object,
      size: React.PropTypes.oneOf(['lg', 'md', 'sm', 'xs'])
    },
    //@@viewOff:propTypes
  
    //@@viewOn:getDefaultProps
    getDefaultProps: function () {
      return {
        onProps: null,
        offProps: null,
        switchedOn: false,
        props: null,
        size: 'md'
      };
    },
    //@@viewOff:getDefaultProps
  
    //@@viewOn:standardComponentLifeCycle
    getInitialState: function () {
      return {
        switchedOn: this.props.switchedOn
      };
    },
  
    componentWillReceiveProps: function (nextProps) {
      if (nextProps.controlled) {
        this.setState({ switchedOn: nextProps.switchedOn });
      }
    },
    //@@viewOff:standardComponentLifeCycle
  
    //@@viewOn:interface
    switchOn: function (setStateCallback) {
      return this.setState({ switchedOn: true }, setStateCallback);
    },
  
    switchOff: function (setStateCallback) {
      return this.setState({ switchedOn: false }, setStateCallback);
    },
  
    toggle: function (setStateCallback) {
      this.setState(function (state) {
        return { switchedOn: !state.switchedOn }
      }, setStateCallback);
      return this;
    },
  
    isSwitchOn: function () {
      return this.state.switchedOn;
    },
  
    isSwitchOff: function () {
      return !this.isSwitchOn();
    },
    //@@viewOff:interface
  
    //@@viewOn:overridingMethods
    //@@viewOff:overridingMethods
  
    //@@viewOn:componentSpecificHelpers
    //@@viewOff:componentSpecificHelpers
  
    //@@viewOn:render
    render: function () {
      return (
        <Button
          {...this.buildMainAttrs()}
          size={this.props.size}
          {...this.isSwitchOn() ? this.props.onProps : this.props.offProps}
          {...this.props.props}
        >
          {this.getChildren()}
        </Button>
      );
    }
    //@@viewOff:render
  });
  
  export default ButtonSwitch;