Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Updates aspectRatio prop to match jw-player doc #193

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions src/helpers/aspectRatioType.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
function aspectRatioType(props, propName, componentName = 'ANONYMOUS') {
if (props[propName]) {
const value = props[propName];

if (typeof value === 'string') {
const vList = value.split(':');

if (
value === 'inherit' ||
(vList.length === 2 && !isNaN(Number(vList[0])) && !isNaN(Number(vList[1])))
) {
return null;
}

return new Error(
`Invalid prop \`${propName}\` of value \`${value}\` supplied to ${componentName}, expected a value of \`Number:Number\``,
);
}

return new Error(
`Invalid prop \`${propName}\` of type ${typeof value} supplied to ${componentName}, expected a value of type \`string\``,
);
}

return null;
}

export default aspectRatioType;
3 changes: 2 additions & 1 deletion src/player-prop-types.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import PropTypes from 'prop-types';
import aspectRatioType from './helpers/aspectRatioType';

const propTypes = {
aspectRatio: PropTypes.oneOf(['inherit', '1:1', '16:9']),
aspectRatio: aspectRatioType,
className: PropTypes.string,
customProps: PropTypes.object,
file: PropTypes.string,
Expand Down