<commit_before>import React, { Component } from "react";
import PropTypes from "prop-types";
import cx from "classnames";

import ModalHeaderPresenter from "./ModalHeaderPresenter";
import { types } from "../types";
import "./ModalPresenter.scss";

export default class ModalPresenter extends Component {
  static propTypes = {
    /**
     * Supports adding any dom content to the body of the modal
     */
    children: PropTypes.node,
    /**
     * ARIA label attribute for the close button if/when headerChildren
     * are not utilized
     */
    closeButtonAriaLabel: PropTypes.string,
    /**
     * Supports adding any dom content to the header of the modal
     */
    headerChildren: PropTypes.node,
    /**
     * Triggers when one clicks the close button
     */
    onCloseClick: PropTypes.func,
    /**
     * Triggers when one clicks the overlay behind the modal
     */
    onOverlayClick: PropTypes.func,
    /**
     * Triggers when one clicks the modal window
     */
    onWindowClick: PropTypes.func,
    /**
     * Modal is visible when true
     */
    open: PropTypes.bool,
    /**
     * Title of the modal
     */
    title: PropTypes.string,
    /**
     * Style of the modal shell
     */
    type: PropTypes.string
  };

  static defaultProps = {
    type: types.STANDARD
  };

  setScrolling = element => {
    this.hasScrolling = element.scrollHeight > element.clientHeight;
  };

  render() {
    const {
      children,
      closeButtonAriaLabel,
      headerChildren,
      onCloseClick,
      onOverlayClick,
      onWindowClick,
      open,
      title,
      type
    } = this.props;

    const windowClasses = cx([
      "hig__modal-V1__window",
      `hig__modal-V1__window--${type}`
    ]);

    const wrapperClasses = cx([
      "hig__modal-V1",
      {
        "hig__modal-V1--open": open
      }
    ]);

    return (
      <div className={wrapperClasses}>
        <a
          className="hig__modal-V1__overlay"
          onClick={onOverlayClick}
          role="button"
          tabIndex="0"
        >
          <a
            className={windowClasses}
            onClick={onWindowClick}
            role="button"
            tabIndex="0"
          >
            <ModalHeaderPresenter
              closeButtonAriaLabel={closeButtonAriaLabel}
              onCloseClick={onCloseClick}
              title={title}
            >
              {headerChildren}
            </ModalHeaderPresenter>
            <div className="hig__modal-V1__body">
              <div className="hig__modal-V1__slot">{children}</div>
            </div>
          </a>
        </a>
      </div>
    );
  }
}
<commit_msg>refactor: Use dictionary for variant style modifiers<commit_after>import React, { Component } from "react";
import PropTypes from "prop-types";
import cx from "classnames";

import ModalHeaderPresenter from "./ModalHeaderPresenter";
import { types } from "../types";
import "./ModalPresenter.scss";

export default class ModalPresenter extends Component {
  static modifiersByType = {
    [types.STANDARD]: "hig__modal-V1__window--standard",
    [types.ALTERNATE]: "hig__modal-V1__window--alternate"
  };

  static propTypes = {
    /**
     * Supports adding any dom content to the body of the modal
     */
    children: PropTypes.node,
    /**
     * ARIA label attribute for the close button if/when headerChildren
     * are not utilized
     */
    closeButtonAriaLabel: PropTypes.string,
    /**
     * Supports adding any dom content to the header of the modal
     */
    headerChildren: PropTypes.node,
    /**
     * Triggers when one clicks the close button
     */
    onCloseClick: PropTypes.func,
    /**
     * Triggers when one clicks the overlay behind the modal
     */
    onOverlayClick: PropTypes.func,
    /**
     * Triggers when one clicks the modal window
     */
    onWindowClick: PropTypes.func,
    /**
     * Modal is visible when true
     */
    open: PropTypes.bool,
    /**
     * Title of the modal
     */
    title: PropTypes.string,
    /**
     * Style of the modal shell
     */
    type: PropTypes.string
  };

  static defaultProps = {
    type: types.STANDARD
  };

  setScrolling = element => {
    this.hasScrolling = element.scrollHeight > element.clientHeight;
  };

  render() {
    const {
      children,
      closeButtonAriaLabel,
      headerChildren,
      onCloseClick,
      onOverlayClick,
      onWindowClick,
      open,
      title,
      type
    } = this.props;

    const windowClasses = cx(
      "hig__modal-V1__window",
      ModalPresenter.modifiersByType[type]
    );

    const wrapperClasses = cx([
      "hig__modal-V1",
      {
        "hig__modal-V1--open": open
      }
    ]);

    return (
      <div className={wrapperClasses}>
        <a
          className="hig__modal-V1__overlay"
          onClick={onOverlayClick}
          role="button"
          tabIndex="0"
        >
          <a
            className={windowClasses}
            onClick={onWindowClick}
            role="button"
            tabIndex="0"
          >
            <ModalHeaderPresenter
              closeButtonAriaLabel={closeButtonAriaLabel}
              onCloseClick={onCloseClick}
              title={title}
            >
              {headerChildren}
            </ModalHeaderPresenter>
            <div className="hig__modal-V1__body">
              <div className="hig__modal-V1__slot">{children}</div>
            </div>
          </a>
        </a>
      </div>
    );
  }
}

{'fraction_non_alphanumeric': 0.10373746581586143, 'fraction_numerical': 0.003463992707383774, 'mean_word_length': 1.9670091941590049, 'pattern_counts': {'":': 2, '<': 27, '<?xml version=': 0, '>': 31, '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': '3130501', 'n_tokens_mistral': 1570, 'n_tokens_neox': 1566, 'n_words': 370}