<commit_before>import classNames from 'classnames';
import React, { Component, PropTypes } from 'react';
import ModalOverlay from 'react-modal';
import CSSModules from 'react-css-modules';
import styles from './index.styl';

const noop = () => {};

// https://github.com/reactjs/react-modal
// Styles are passed as an object with 2 keys, 'overlay' and 'content' like so
const customStyles = {
    overlay: {
        position: 'fixed',
        top: 0,
        bottom: 0,
        left: 0,
        right: 0,
        backgroundColor: 'rgba(51, 51, 51, .55)',
        zIndex: 100
    },
    content: {
        boxShadow: '0 4px 16px rgba(0, 0, 0, .5)',
        border: '1px solid #ccc',
        borderRadius: 0,
        top: '50%',
        left: '50%',
        right: 'auto',
        bottom: 'auto',
        marginRight: '-50%',
        padding: 0,
        transform: 'translate(-50%, -50%)'
    }
};

@CSSModules(styles, { allowMultiple: true })
class Modal extends Component {
    static propTypes = {
        ...ModalOverlay.propTypes,

        bsSize: PropTypes.oneOf(['xs', 'sm', 'md', 'lg']),

        // When 'true' the modal will show itself.
        show: PropTypes.bool,

        // Specify 'static' for a backdrop that doesn't trigger an "onHide" when clicked.
        backdrop: PropTypes.oneOf(['static', true, false]),

        // Specify whether the Component should contain a close button
        closeButton: PropTypes.bool,

        // A callback fired when the header closeButton or non-static backdrop is clicked.
        onHide: PropTypes.func
    };
    static defaultProps = {
        ...ModalOverlay.defaultProps,
        bsSize: 'xs',
        show: true,
        backdrop: 'static',
        closeButton: true,
        onHide: noop
    };

    onHide(event) {
        this.props.onHide && this.props.onHide(event);
    }
    render() {
        const {
            children,
            bsSize,
            show,
            backdrop,
            closeButton,
            ...props
        } = this.props;

        return (
            <ModalOverlay
                isOpen={show}
                onRequestClose={::this.props.onHide}
                shouldCloseOnOverlayClick={backdrop === true}
                style={customStyles}
            >
                <div
                    {...props}
                    styleName={classNames(
                        'modal',
                        bsSize
                    )}<commit_msg>Prevent body scrolling<commit_after>import classNames from 'classnames';
import React, { Component, PropTypes } from 'react';
import ModalOverlay from 'react-modal';
import CSSModules from 'react-css-modules';
import styles from './index.styl';

const noop = () => {};

// https://github.com/reactjs/react-modal
// Styles are passed as an object with 2 keys, 'overlay' and 'content' like so
const customStyles = {
    overlay: {
        position: 'fixed',
        top: 0,
        bottom: 0,
        left: 0,
        right: 0,
        backgroundColor: 'rgba(51, 51, 51, .55)',
        zIndex: 100
    },
    content: {
        boxShadow: '0 4px 16px rgba(0, 0, 0, .5)',
        border: '1px solid #ccc',
        borderRadius: 0,
        top: '50%',
        left: '50%',
        right: 'auto',
        bottom: 'auto',
        marginRight: '-50%',
        padding: 0,
        transform: 'translate(-50%, -50%)'
    }
};

@CSSModules(styles, { allowMultiple: true })
class Modal extends Component {
    static propTypes = {
        ...ModalOverlay.propTypes,

        bsSize: PropTypes.oneOf(['xs', 'sm', 'md', 'lg']),

        // When 'true' the modal will show itself.
        show: PropTypes.bool,

        // Specify 'static' for a backdrop that doesn't trigger an "onHide" when clicked.
        backdrop: PropTypes.oneOf(['static', true, false]),

        // Specify whether the Component should contain a close button
        closeButton: PropTypes.bool,

        // A callback fired when the header closeButton or non-static backdrop is clicked.
        onHide: PropTypes.func
    };
    static defaultProps = {
        ...ModalOverlay.defaultProps,
        bsSize: 'xs',
        show: true,
        backdrop: 'static',
        closeButton: true,
        onHide: noop
    };

    style = {
        overflowY: ''
    };

    componentDidMount() {
        this.style.overflowY = document.body.style.overflowY;
        document.body.style.overflowY = 'hidden'; // prevent body scrolling
    }
    componentWillUnmount() {
        document.body.style.overflowY = this.style.overflowY;
    }
    onHide(event) {
        this.props.onHide && this.props.onHide(event);
    }
    render() {
        const {
            children,
            bsSize,
            show,
            backdrop,
            closeButton,
            ...props
        } = this.props;

        return (
            <ModalOverlay
                isOpen={show}
                onRequestClose={::this.props.onHide}
                shouldCloseOnOverlayClick={backdrop === true}
                style={customStyles}
            >
                <div
                    {...props}
                    styleName={classNames(
                        'modal',
                        bsSize
                    )}
{'fraction_non_alphanumeric': 0.12160611854684512, 'fraction_numerical': 0.014149139579349905, 'mean_word_length': 1.6908436213991769, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 2, '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': '7130958', 'n_tokens_mistral': 1540, 'n_tokens_neox': 1456, 'n_words': 397}