-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added support for video (media content). Rendered in a responsive ifr…
…ame.
- Loading branch information
Showing
8 changed files
with
61 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,3 +51,7 @@ | |
margin-right: 0.3em; | ||
line-height: 0.9; | ||
} | ||
|
||
.media-content-video-container { | ||
padding-top: 26.25%; | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import React from "react"; | ||
import PropTypes from "prop-types"; | ||
import JsonLdUtils from "jsonld-utils"; | ||
import Constants from "../constants/Constants"; | ||
|
||
export default class MediaContent extends React.Component { | ||
|
||
static propTypes = { | ||
question: PropTypes.object.isRequired | ||
}; | ||
|
||
constructor(props) { | ||
super(props); | ||
} | ||
|
||
render() { | ||
const mediaContent = JsonLdUtils.getJsonAttValue(this.props.question, Constants.HAS_MEDIA_CONTENT); | ||
if (!mediaContent) { | ||
return null; | ||
} | ||
return this._renderDangerously(mediaContent); | ||
} | ||
|
||
_renderDangerously(mediaContent) { | ||
if (Array.isArray(mediaContent)) { | ||
return <div className='col-xs-6'> | ||
{mediaContent.map(src => <div key={'media-' + src} className='row embed-responsive media-content-video-container'>{MediaContent.iframe(src)}</div>)} | ||
</div>; | ||
} else { | ||
return <div className='row'> | ||
<div className='col-xs-6 embed-responsive media-content-video-container'>{MediaContent.iframe(mediaContent)}</div> | ||
</div>; | ||
} | ||
} | ||
|
||
static iframe(src) { | ||
return <iframe src={src} class="embed-responsive-item"></iframe>; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters