All files / src/utils Visible.jsx

100% Statements 6/6
100% Branches 2/2
100% Functions 1/1
100% Lines 6/6

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51                              6x                   6x                 6x                 38x 38x   38x        
/* eslint-disable react/boolean-prop-naming */
import {Component} from 'react';
 
import PropTypes from 'prop-types';
 
import {ScreenClassContext} from './ScreenClassProvider';
 
/**
 * Visible
 *
 * @component
 * @augments {Component<Props, State>}
 * @extends {Component}
 */
class Visible extends Component {
    static propTypes = {
        children: PropTypes.node.isRequired,
        lg: PropTypes.bool,
        md: PropTypes.bool,
        sm: PropTypes.bool,
        xl: PropTypes.bool,
        xs: PropTypes.bool,
        xxl: PropTypes.bool
    }
 
    static defaultProps = {
        lg: false,
        md: false,
        sm: false,
        xl: false,
        xs: false,
        xxl: false
    }
 
    static contextType = ScreenClassContext;
 
    /**
     * Renders the Component.
     *
     * @returns {JSX} Component.
     * @memberof Visible
     */
    render() {
        const screenClass = this.context;
        const {children, ...screenClasses} = this.props;
 
        return screenClasses[String(screenClass)] ? children : null;
    }
}
 
export default Visible;