<commit_before>import React from 'react'
import Icon from '../components/Icon'
import { closeModal } from '../actions'
// circular import; code smell; refactor?
import BrowseTopicsModal from '../containers/BrowseTopicsModal'
import ShareTopicModal from '../containers/ShareTopicModal'
import ExpandedPostModal from '../containers/ExpandedPostModal'
import DirectMessageModal from '../containers/DirectMessageModal'
import ChecklistModal from '../containers/ChecklistModal'
import TagEditorModal from '../containers/TagEditorModal'
import AddLogoModal from '../containers/AddLogoModal'
import InviteModal from '../containers/InviteModal'
import PostEditorModal from '../containers/PostEditorModal'
import { NotificationsModal } from '../containers/Notifications'
import { ThreadsModal } from '../containers/ThreadsDropdown'
import cx from 'classnames'
import { get } from 'lodash/fp'
const { array, bool, func, node, object, string, oneOfType } = React.PropTypes

export const modalWrapperCSSId = 'top-level-modal-wrapper'
const mainColumnWidth = 688 // defined in CSS

// this has to cover the cases:
//  - desktop, left nav open
//  - desktop, left nav closed
//  - mobile
//
const modalStyle = isMobile => {
  if (typeof window === 'undefined') return {}
  const main = document.getElementById('main')
  const marginLeft = Math.max((main.offsetWidth - mainColumnWidth) / 2, 0) + main.offsetLeft
  return {marginLeft}
}

export class BareModalWrapper extends React.Component {
  static propTypes = {children: object, onClick: func, top: bool}

  render () {
    const { children, top } = this.props
    const onClick = event => {
      if (event.target !== this.refs.backdrop) return
      return this.props.onClick(event)
    }

    return <div id={modalWrapperCSSId}>
      {top
        ? <div className='scrolling-backdrop' ref='backdrop' onClick={onClick}>
            {children}
          </div>
        : <div>
            {children}
          </div>}
    </div>
  }
}

export class ModalWrapper extends React.Component {
  static propTypes = {type: string, params: object, top: bool, bottom: bool}
  static defaultProps = {top: true}
  static contextTypes = {dispatch: func}<commit_msg>fix tests<commit_after>import React from 'react'
import Icon from '../components/Icon'
import { closeModal } from '../actions'
// circular import; code smell; refactor?
import BrowseTopicsModal from '../containers/BrowseTopicsModal'
import ShareTopicModal from '../containers/ShareTopicModal'
import ExpandedPostModal from '../containers/ExpandedPostModal'
import DirectMessageModal from '../containers/DirectMessageModal'
import ChecklistModal from '../containers/ChecklistModal'
import TagEditorModal from '../containers/TagEditorModal'
import AddLogoModal from '../containers/AddLogoModal'
import InviteModal from '../containers/InviteModal'
import PostEditorModal from '../containers/PostEditorModal'
import { NotificationsModal } from '../containers/Notifications'
import { ThreadsModal } from '../containers/ThreadsDropdown'
import cx from 'classnames'
import { get } from 'lodash/fp'
const { array, bool, func, node, object, string, oneOfType } = React.PropTypes

export const modalWrapperCSSId = 'top-level-modal-wrapper'
const mainColumnWidth = 688 // defined in CSS

// this has to cover the cases:
//  - desktop, left nav open
//  - desktop, left nav closed
//  - mobile
//
const modalStyle = isMobile => {
  if (typeof window === 'undefined') return {}
  const main = document.getElementById('main')
  if (!main) return {} // this should be the case only during tests
  const marginLeft = Math.max((main.offsetWidth - mainColumnWidth) / 2, 0) + main.offsetLeft
  return {marginLeft}
}

export class BareModalWrapper extends React.Component {
  static propTypes = {children: object, onClick: func, top: bool}

  render () {
    const { children, top } = this.props
    const onClick = event => {
      if (event.target !== this.refs.backdrop) return
      return this.props.onClick(event)
    }

    return <div id={modalWrapperCSSId}>
      {top
        ? <div className='scrolling-backdrop' ref='backdrop' onClick={onClick}>
            {children}
          </div>
        : <div>
            {children}
          </div>}
    </div>
  }
}

export class ModalWrapper extends React.Component {
  static propTypes = {type: string, params: object, top: bool, bottom: bool}
  static defaultProps = {top: true}
  static contextTypes = {dispatch: func}
{'fraction_non_alphanumeric': 0.1192722371967655, 'fraction_numerical': 0.0022461814914645105, 'mean_word_length': 3.762566844919786, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '3272397', 'n_tokens_mistral': 1257, 'n_tokens_neox': 1239, 'n_words': 385}