<commit_before>import React from 'react';
import {node, shape} from 'prop-types';
import {injectSheet} from 'styles';
import Term from 'containers/Term';
import parseFirstTextLineComponentToEmbedLink from './parser';
import calculateStyles from './calculateStyles';

const iframePresenter = ({height, width, src, shortHeight}) => // eslint-disable-line react/prop-types
    <iframe title='This is a unique title' width={width} height={shortHeight ? 100 : height} src={src} allowFullScreen frameBorder='0' />;

const videoPresenter = ({height, width, src, type}) => { // eslint-disable-line react/prop-types
    const videoTerm = {id: 29, value: 'Video'};
    return <video width={width} height={height} controls><source src={src} type={type} /><a href={src}><Term term={videoTerm} /></a></video>; // eslint-disable-line jsx-a11y/media-has-caption
};

const audioPresenter = ({src, type}) => { // eslint-disable-line react/prop-types
    const audioTerm = {id: 28, value: 'Audio'};
    return <audio controls><source src={src} type={type} /><a href={src}><Term term={audioTerm} /></a></audio>; // eslint-disable-line jsx-a11y/media-has-caption
};


const objectTypeToPresenterMapping = {
    iframe: iframePresenter,
    video: videoPresenter,
    audio: audioPresenter
};

const matchResourceTypeToPresenter = typeString => {
    const parsedType = typeString.match(/(iframe|audio|video)/i);
    return objectTypeToPresenterMapping[parsedType[0]];
};
<commit_msg>added propTypes to Media nested presenters<commit_after>/* eslint-disable jsx-a11y/media-has-caption */

import React from 'react';
import {node, shape, number, bool, string} from 'prop-types';
import {injectSheet} from 'styles';
import Term from 'containers/Term';
import parseFirstTextLineComponentToEmbedLink from './parser';
import calculateStyles from './calculateStyles';

const iframePresenter = ({height, width, src, shortHeight}) =>
    <iframe title='This is a unique title' width={width} height={shortHeight ? 100 : height} src={src} allowFullScreen frameBorder='0' />;

iframePresenter.propTypes = {
    height: number.isRequired,
    width: number.isRequired,
    shortHeight: bool.isRequired,
    src: string.isRequired
};

const videoPresenter = ({height, width, src, type}) => {
    const videoTerm = {id: 29, value: 'Video'};
    return (
        <video width={width} height={height} controls>
            <source src={src} type={type} />
            <a href={src}>
                <Term term={videoTerm} />
            </a>
        </video>
    );
};

videoPresenter.propTypes = {
    height: number.isRequired,
    width: number.isRequired,
    type: string.isRequired,
    src: string.isRequired
};

const audioPresenter = ({src, type}) => {
    const audioTerm = {id: 28, value: 'Audio'};
    return (
        <audio controls>
            <source src={src} type={type} />
            <a href={src}><Term term={audioTerm} /></a>
        </audio>
    );
};

audioPresenter.propTypes = {
    type: string.isRequired,
    src: string.isRequired
};


const objectTypeToPresenterMapping = {
    iframe: iframePresenter,
    video: videoPresenter,
    audio: audioPresenter
};

const matchResourceTypeToPresenter = typeString => {
    const parsedType = typeString.match(/(iframe|audio|video)/i);
    return objectTypeToPresenterMapping[parsedType[0]];
};

{'fraction_non_alphanumeric': 0.1476147614761476, 'fraction_numerical': 0.0072007200720072, 'mean_word_length': 4.021084337349397, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 37, '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': '6206313', 'n_tokens_mistral': 1037, 'n_tokens_neox': 1000, 'n_words': 253}