<commit_before>/*
 This file is a part of libertysoil.org website
 Copyright (C) 2017  Loki Education (Social Enterprise)

 This program is free software: you can redistribute it and/or modify
 it under the terms of the GNU Affero General Public License as published by
 the Free Software Foundation, either version 3 of the License, or
 (at your option) any later version.

 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU Affero General Public License for more details.

 You should have received a copy of the GNU Affero General Public License
 along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
import React, { PropTypes } from 'react';
import classNames from 'classnames';
import isEqual from 'lodash/isEqual';
import CSSTransitionGroup from 'react-transition-group/CSSTransitionGroup';

import ClickOutsideComponentDecorator from '../decorators/ClickOutsideComponentDecorator';
import { OldIcon as Icon } from './icon';

class SidebarModalMain extends React.Component {
  static displayName = 'SidebarModalMain';

  static propTypes = {
    rtl: PropTypes.bool
  };

  static defaultProps = {
    animate: true,
    isVisible: false,
    onHide: () => {}
  };

  shouldComponentUpdate(nextProps) {
    return nextProps !== this.props;
  }

  onClickOutside = () => {
    this.props.onHide();
  };

  handleClickInside = (e) => {
    e.stopPropagation();
  };

  render() {
    const content = (
      <div
        className={
          classNames(
            this.props.className,
            'sidebar-modal sidebar-modal__main',
            { 'sidebar-modal--rtl': this.props.rtl }
          )
        }
        key="main"
        onClick={this.handleClickInside}
      >
        {this.props.children}
      </div>
    );

    if (this.props.animate) {
      return (
        <CSSTransitionGroup
          transitionName="sidebar-modal__main--transition"
          transitionAppear
          transitionAppearTimeout={250}
          transitionEnterTimeout={250}
          transitionLeaveTimeout={250}
        >
          {this.props.isVisible ? content : null}
        </CSSTransitionGroup>
      );
    }

    return this.props.isVisible ? content : null;
  }
}

class SidebarModalOverlay extends React.Component {
  static displayName = 'SidebarModalOverlay';

  static propTypes = {
    color: PropTypes.string,
    isVisible: PropTypes.bool
  };

  static defaultProps = {
    color: "white",
    isVisible: false
  };

  constructor(props, ...args) {
    super(props, ...args);
    this.state = {
      isAppearing: false,
      isVisible: false
    };
  }<commit_msg>Fix hidden modal with JavaScript disabled<commit_after>/*
 This file is a part of libertysoil.org website
 Copyright (C) 2017  Loki Education (Social Enterprise)

 This program is free software: you can redistribute it and/or modify
 it under the terms of the GNU Affero General Public License as published by
 the Free Software Foundation, either version 3 of the License, or
 (at your option) any later version.

 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU Affero General Public License for more details.

 You should have received a copy of the GNU Affero General Public License
 along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
import React, { PropTypes } from 'react';
import classNames from 'classnames';
import isEqual from 'lodash/isEqual';
import CSSTransitionGroup from 'react-transition-group/CSSTransitionGroup';

import ClickOutsideComponentDecorator from '../decorators/ClickOutsideComponentDecorator';
import { OldIcon as Icon } from './icon';

class SidebarModalMain extends React.Component {
  static displayName = 'SidebarModalMain';

  static propTypes = {
    rtl: PropTypes.bool
  };

  static defaultProps = {
    animate: true,
    isVisible: false,
    onHide: () => {}
  };

  shouldComponentUpdate(nextProps) {
    return nextProps !== this.props;
  }

  onClickOutside = () => {
    this.props.onHide();
  };

  handleClickInside = (e) => {
    e.stopPropagation();
  };

  render() {
    const content = (
      <div
        className={
          classNames(
            this.props.className,
            'sidebar-modal sidebar-modal__main',
            { 'sidebar-modal--rtl': this.props.rtl }
          )
        }
        key="main"
        onClick={this.handleClickInside}
      >
        {this.props.children}
      </div>
    );

    if (this.props.animate) {
      return (
        <CSSTransitionGroup
          transitionName="sidebar-modal__main--transition"
          transitionAppear
          transitionAppearTimeout={250}
          transitionEnterTimeout={250}
          transitionLeaveTimeout={250}
        >
          {this.props.isVisible ? content : null}
        </CSSTransitionGroup>
      );
    }

    return this.props.isVisible ? content : null;
  }
}

class SidebarModalOverlay extends React.Component {
  static displayName = 'SidebarModalOverlay';

  static propTypes = {
    color: PropTypes.string,
    isVisible: PropTypes.bool
  };

  static defaultProps = {
    color: "white",
    isVisible: false
  };

  constructor(props, ...args) {
    super(props, ...args);
    this.state = {
      isAppearing: typeof window === 'undefined',
      isVisible: typeof window === 'undefined'
    };
  }
{'fraction_non_alphanumeric': 0.09648493543758967, 'fraction_numerical': 0.005021520803443328, 'mean_word_length': 2.8094262295081966, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3928840', 'n_tokens_mistral': 1581, 'n_tokens_neox': 1513, 'n_words': 473}