<commit_before>{ Component, PropTypes } = React = require 'react'
classnames = require 'classnames'

Label = require 'lab/Text/Label'
Button = require 'lab/Button'

ReactModal = require 'react-modal'

styles = require './Modal.stylus'

noop = ->

module.exports = class Modal extends Component

  render: ->

    { isOpen, onAfterOpen, onRequestClose, children, contentLabel
      shouldCloseOnOverlayClick, width, height, showAlien } = @props

    className = classnames [
      styles.modal
      styles[width]
      styles[height]
    ]

    <ReactModal
      className={className}
      contentLabel={contentLabel}
      overlayClassName={styles.overlay}
      isOpen={isOpen}
      onAfterOpen={onAfterOpen}
      onRequestClose={onRequestClose}
      shouldCloseOnOverlayClick={shouldCloseOnOverlayClick}>
      <div className={styles.wrapper}>
        {<figure className={styles.alien}/>  if showAlien}
        {children}
      </div>
    </ReactModal>


Modal.defaultProps =
  width: 'large'
  height: 'normal'
  showAlien: no
  contentLabel: ''


exports.Header = Modal.Header = ({ title }) ->
  <div className={styles.header}>
    <Label size='xlarge' type="info">{title}</Label>
  </div>


exports.Content = Modal.Content = ({ children }) ->
  <div className={styles.content}>
    {children}
  </div>


exports.Footer = Modal.Footer = (props) ->
  { primaryButtonType, primaryButtonSize
    primaryButtonTitle, onPrimaryButtonClick } = props

  { secondaryButtonType, secondaryButtonSize
    secondaryButtonTitle, onSecondaryButtonClick } = props

  <div className={styles.footer}>
    <div className={styles.footerContainer}>

      <Button type={secondaryButtonType} size={primaryButtonSize} onClick={onSecondaryButtonClick}>
        {secondaryButtonTitle}
      </Button>

      <Button type={primaryButtonType} size={secondaryButtonSize} onClick={onPrimaryButtonClick}>
        {primaryButtonTitle}
      </Button>

    </div>
  </div>

Modal.Footer.defaultProps =
  primaryButtonType: 'primary-1'
  secondaryButtonType: 'secondary'
  primaryButtonSize: 'small'
  secondaryButtonSize: 'small'
  primaryButtonTitle: 'Primary'
  secondaryButtonTitle: 'Secondary'
  onPrimaryButtonClick: noop<commit_msg>lab/Modal: introduce disabled state for ModalFooter<commit_after>{ Component, PropTypes } = React = require 'react'
classnames = require 'classnames'

Label = require 'lab/Text/Label'
Button = require 'lab/Button'

ReactModal = require 'react-modal'

styles = require './Modal.stylus'

noop = ->

module.exports = class Modal extends Component

  render: ->

    { isOpen, onAfterOpen, onRequestClose, children, contentLabel
      shouldCloseOnOverlayClick, width, height, showAlien } = @props

    className = classnames [
      styles.modal
      styles[width]
      styles[height]
    ]

    <ReactModal
      className={className}
      contentLabel={contentLabel}
      overlayClassName={styles.overlay}
      isOpen={isOpen}
      onAfterOpen={onAfterOpen}
      onRequestClose={onRequestClose}
      shouldCloseOnOverlayClick={shouldCloseOnOverlayClick}>
      <div className={styles.wrapper}>
        {<figure className={styles.alien}/>  if showAlien}
        {children}
      </div>
    </ReactModal>


Modal.defaultProps =
  width: 'large'
  height: 'normal'
  showAlien: no
  contentLabel: ''


exports.Header = Modal.Header = ({ title }) ->
  <div className={styles.header}>
    <Label size='xlarge' type="info">{title}</Label>
  </div>


exports.Content = Modal.Content = ({ children }) ->
  <div className={styles.content}>
    {children}
  </div>


exports.Footer = Modal.Footer = (props) ->
  { primaryButtonType, primaryButtonSize
    primaryButtonTitle, onPrimaryButtonClick } = props

  { secondaryButtonType, secondaryButtonSize
    secondaryButtonTitle, onSecondaryButtonClick } = props

  <div className={styles.footer}>
    <div className={styles.footerContainer}>

      <Button
        disabled={props.disabled}
        type={secondaryButtonType}
        size={primaryButtonSize}
        onClick={onSecondaryButtonClick}
        children={secondaryButtonTitle} />

      <Button
        disabled={props.disabled}
        type={primaryButtonType}
        size={secondaryButtonSize}
        onClick={onPrimaryButtonClick}
        children={primaryButtonTitle} />

    </div>
  </div>

Modal.Footer.defaultProps =
  primaryButtonType: 'primary-1'
  secondaryButtonType: 'secondary'
  primaryButtonSize: 'small'
  secondaryButtonSize: 'small'
  primaryButtonTitle: 'Primary'
  secondaryButtonTitle: 'Secondary'
  onPrimaryButtonClick: noop
{'fraction_non_alphanumeric': 0.11625874125874126, 'fraction_numerical': 0.00043706293706293706, 'mean_word_length': 3.733195449844881, 'pattern_counts': {'":': 0, '<': 39, '<?xml version=': 0, '>': 49, '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': '6705301', 'n_tokens_mistral': 1326, 'n_tokens_neox': 1305, 'n_words': 264}