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

Improve support for Hulu & Imgur embeds #1218

Merged
merged 7 commits into from
Jun 22, 2018
Merged
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
82 changes: 39 additions & 43 deletions blocks/amp-brid-player/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export default registerBlockType(
{
title: __( 'AMP Brid Player', 'amp' ),
description: __( 'Displays the Brid Player used in Brid.tv Video Platform.', 'amp' ),
category: 'common',
category: 'embed',
icon: 'embed-generic',
keywords: [
__( 'Embed', 'amp' )
Expand Down Expand Up @@ -86,7 +86,7 @@ export default registerBlockType(
},

edit( props ) {
const { attributes, isSelected, setAttributes } = props;
const { attributes, setAttributes } = props;
const { autoPlay, dataPartner, dataPlayer, dataVideo, dataPlaylist, dataOutstream } = attributes;
const ampLayoutOptions = [
{ value: 'responsive', label: __( 'Responsive', 'amp' ) },
Expand All @@ -103,47 +103,43 @@ export default registerBlockType(
}
return (
<Fragment>
{
isSelected && (
<InspectorControls key='inspector'>
<PanelBody title={ __( 'Brid Player Settings', 'amp' ) }>
<TextControl
label={ __( 'Brid.tv partner ID (required)', 'amp' ) }
value={ dataPartner }
onChange={ value => ( setAttributes( { dataPartner: value } ) ) }
/>
<TextControl
label={ __( 'Brid.tv player ID (required)', 'amp' ) }
value={ dataPlayer }
onChange={ value => ( setAttributes( { dataPlayer: value } ) ) }
/>
<TextControl
label={ __( 'Video ID (one of video / playlist / outstream ID is required)', 'amp' ) }
value={ dataVideo }
onChange={ value => ( setAttributes( { dataVideo: value } ) ) }
/>
<TextControl
label={ __( 'Outstream unit ID (one of video / playlist / outstream ID is required)', 'amp' ) }
value={ dataOutstream }
onChange={ value => ( setAttributes( { dataOutstream: value } ) ) }
/>
<TextControl
label={ __( 'Playlist ID (one of video / playlist / outstream ID is required)', 'amp' ) }
value={ dataPlaylist }
onChange={ value => ( setAttributes( { dataPlaylist: value } ) ) }
/>
<ToggleControl
label={ __( 'Autoplay', 'amp' ) }
checked={ autoPlay }
onChange={ () => ( setAttributes( { autoPlay: ! autoPlay } ) ) }
/>
{
getLayoutControls( props, ampLayoutOptions )
}
</PanelBody>
</InspectorControls>
)
}
<InspectorControls key='inspector'>
<PanelBody title={ __( 'Brid Player Settings', 'amp' ) }>
<TextControl
label={ __( 'Brid.tv partner ID (required)', 'amp' ) }
value={ dataPartner }
onChange={ value => ( setAttributes( { dataPartner: value } ) ) }
/>
<TextControl
label={ __( 'Brid.tv player ID (required)', 'amp' ) }
value={ dataPlayer }
onChange={ value => ( setAttributes( { dataPlayer: value } ) ) }
/>
<TextControl
label={ __( 'Video ID (one of video / playlist / outstream ID is required)', 'amp' ) }
value={ dataVideo }
onChange={ value => ( setAttributes( { dataVideo: value } ) ) }
/>
<TextControl
label={ __( 'Outstream unit ID (one of video / playlist / outstream ID is required)', 'amp' ) }
value={ dataOutstream }
onChange={ value => ( setAttributes( { dataOutstream: value } ) ) }
/>
<TextControl
label={ __( 'Playlist ID (one of video / playlist / outstream ID is required)', 'amp' ) }
value={ dataPlaylist }
onChange={ value => ( setAttributes( { dataPlaylist: value } ) ) }
/>
<ToggleControl
label={ __( 'Autoplay', 'amp' ) }
checked={ autoPlay }
onChange={ () => ( setAttributes( { autoPlay: ! autoPlay } ) ) }
/>
{
getLayoutControls( props, ampLayoutOptions )
}
</PanelBody>
</InspectorControls>
{
url && getMediaPlaceholder( __( 'Brid Player', 'amp' ), url )
}
Expand Down
62 changes: 29 additions & 33 deletions blocks/amp-ima-video/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export default registerBlockType(
{
title: __( 'AMP IMA Video', 'amp' ),
description: __( 'Embeds a video player for instream video ads that are integrated with the IMA SDK', 'amp' ),
category: 'common',
category: 'embed',
icon: 'embed-generic',
keywords: [
__( 'Embed', 'amp' )
Expand Down Expand Up @@ -81,7 +81,7 @@ export default registerBlockType(
},

edit( props ) {
const { attributes, isSelected, setAttributes } = props;
const { attributes, setAttributes } = props;
const { dataDelayAdRequest, dataTag, dataSrc, dataPoster } = attributes;
const ampLayoutOptions = [
{ value: 'responsive', label: __( 'Responsive', 'amp' ) },
Expand All @@ -94,37 +94,33 @@ export default registerBlockType(
}
return (
<Fragment>
{
isSelected && (
<InspectorControls key='inspector'>
<PanelBody title={ __( 'IMA Video Settings', 'amp' ) }>
<TextControl
label={ __( 'Https URL for your VAST ad document (required)', 'amp' ) }
value={ dataTag }
onChange={ value => ( setAttributes( { dataTag: value } ) ) }
/>
<TextControl
label={ __( 'Https URL of your video content (required)', 'amp' ) }
value={ dataSrc }
onChange={ value => ( setAttributes( { dataSrc: value } ) ) }
/>
<TextControl
label={ __( 'Https URL to preview image', 'amp' ) }
value={ dataPoster }
onChange={ value => ( setAttributes( { dataPoster: value } ) ) }
/>
<ToggleControl
label={ __( 'Delay Ad Request', 'amp' ) }
checked={ dataDelayAdRequest }
onChange={ () => ( setAttributes( { dataDelayAdRequest: ! dataDelayAdRequest } ) ) }
/>
{
getLayoutControls( props, ampLayoutOptions )
}
</PanelBody>
</InspectorControls>
)
}
<InspectorControls key='inspector'>
<PanelBody title={ __( 'IMA Video Settings', 'amp' ) }>
<TextControl
label={ __( 'Https URL for your VAST ad document (required)', 'amp' ) }
value={ dataTag }
onChange={ value => ( setAttributes( { dataTag: value } ) ) }
/>
<TextControl
label={ __( 'Https URL of your video content (required)', 'amp' ) }
value={ dataSrc }
onChange={ value => ( setAttributes( { dataSrc: value } ) ) }
/>
<TextControl
label={ __( 'Https URL to preview image', 'amp' ) }
value={ dataPoster }
onChange={ value => ( setAttributes( { dataPoster: value } ) ) }
/>
<ToggleControl
label={ __( 'Delay Ad Request', 'amp' ) }
checked={ dataDelayAdRequest }
onChange={ () => ( setAttributes( { dataDelayAdRequest: ! dataDelayAdRequest } ) ) }
/>
{
getLayoutControls( props, ampLayoutOptions )
}
</PanelBody>
</InspectorControls>
{
dataSet && getMediaPlaceholder( __( 'IMA Video', 'amp' ), dataSrc )
}
Expand Down
52 changes: 24 additions & 28 deletions blocks/amp-jwplayer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default registerBlockType(
{
title: __( 'AMP JW Player', 'amp' ),
description: __( 'Displays a cloud-hosted JW Player.', 'amp' ),
category: 'common',
category: 'embed',
icon: 'embed-generic',
keywords: [
__( 'Embed', 'amp' )
Expand Down Expand Up @@ -73,7 +73,7 @@ export default registerBlockType(
},

edit( props ) {
const { attributes, isSelected, setAttributes } = props;
const { attributes, setAttributes } = props;
const { dataPlayerId, dataMediaId, dataPlaylistId } = attributes;
const ampLayoutOptions = [
{ value: 'responsive', label: __( 'Responsive', 'amp' ) },
Expand All @@ -94,32 +94,28 @@ export default registerBlockType(
}
return (
<Fragment>
{
isSelected && (
<InspectorControls key='inspector'>
<PanelBody title={ __( 'JW Player Settings', 'amp' ) }>
<TextControl
label={ __( 'Player ID (required)', 'amp' ) }
value={ dataPlayerId }
onChange={ value => ( setAttributes( { dataPlayerId: value } ) ) }
/>
<TextControl
label={ __( 'Media ID (required if playlist ID not set)', 'amp' ) }
value={ dataMediaId }
onChange={ value => ( setAttributes( { dataMediaId: value } ) ) }
/>
<TextControl
label={ __( 'Playlist ID (required if media ID not set)', 'amp' ) }
value={ dataPlaylistId }
onChange={ value => ( setAttributes( { dataPlaylistId: value } ) ) }
/>
{
getLayoutControls( props, ampLayoutOptions )
}
</PanelBody>
</InspectorControls>
)
}
<InspectorControls key='inspector'>
<PanelBody title={ __( 'JW Player Settings', 'amp' ) }>
<TextControl
label={ __( 'Player ID (required)', 'amp' ) }
value={ dataPlayerId }
onChange={ value => ( setAttributes( { dataPlayerId: value } ) ) }
/>
<TextControl
label={ __( 'Media ID (required if playlist ID not set)', 'amp' ) }
value={ dataMediaId }
onChange={ value => ( setAttributes( { dataMediaId: value } ) ) }
/>
<TextControl
label={ __( 'Playlist ID (required if media ID not set)', 'amp' ) }
value={ dataPlaylistId }
onChange={ value => ( setAttributes( { dataPlaylistId: value } ) ) }
/>
{
getLayoutControls( props, ampLayoutOptions )
}
</PanelBody>
</InspectorControls>
{
url && getMediaPlaceholder( __( 'JW Player', 'amp' ), url )
}
Expand Down
72 changes: 34 additions & 38 deletions blocks/amp-o2-player/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default registerBlockType(
'amp/amp-o2-player',
{
title: __( 'AMP O2 Player', 'amp' ),
category: 'common',
category: 'embed',
icon: 'embed-generic',
keywords: [
__( 'Embed', 'amp' ),
Expand Down Expand Up @@ -85,7 +85,7 @@ export default registerBlockType(
},

edit( props ) {
const { attributes, isSelected, setAttributes } = props;
const { attributes, setAttributes } = props;
const { autoPlay, dataPid, dataVid, dataBcid, dataBid } = attributes;
const ampLayoutOptions = [
{ value: 'responsive', label: __( 'Responsive', 'amp' ) },
Expand All @@ -102,42 +102,38 @@ export default registerBlockType(
}
return (
<Fragment>
{
isSelected && (
<InspectorControls key='inspector'>
<PanelBody title={ __( 'O2 Player Settings', 'amp' ) }>
<TextControl
label={ __( 'Player ID (required)', 'amp' ) }
value={ dataPid }
onChange={ value => ( setAttributes( { dataPid: value } ) ) }
/>
<TextControl
label={ __( 'Buyer Company ID (either buyer or video ID is required)', 'amp' ) }
value={ dataBcid }
onChange={ value => ( setAttributes( { dataBcid: value } ) ) }
/>
<TextControl
label={ __( 'Video ID (either buyer or video ID is required)', 'amp' ) }
value={ dataVid }
onChange={ value => ( setAttributes( { dataVid: value } ) ) }
/>
<TextControl
label={ __( 'Playlist ID', 'amp' ) }
value={ dataBid }
onChange={ value => ( setAttributes( { dataBid: value } ) ) }
/>
<ToggleControl
label={ __( 'Autoplay', 'amp' ) }
checked={ autoPlay }
onChange={ () => ( setAttributes( { autoPlay: ! autoPlay } ) ) }
/>
{
getLayoutControls( props, ampLayoutOptions )
}
</PanelBody>
</InspectorControls>
)
}
<InspectorControls key='inspector'>
<PanelBody title={ __( 'O2 Player Settings', 'amp' ) }>
<TextControl
label={ __( 'Player ID (required)', 'amp' ) }
value={ dataPid }
onChange={ value => ( setAttributes( { dataPid: value } ) ) }
/>
<TextControl
label={ __( 'Buyer Company ID (either buyer or video ID is required)', 'amp' ) }
value={ dataBcid }
onChange={ value => ( setAttributes( { dataBcid: value } ) ) }
/>
<TextControl
label={ __( 'Video ID (either buyer or video ID is required)', 'amp' ) }
value={ dataVid }
onChange={ value => ( setAttributes( { dataVid: value } ) ) }
/>
<TextControl
label={ __( 'Playlist ID', 'amp' ) }
value={ dataBid }
onChange={ value => ( setAttributes( { dataBid: value } ) ) }
/>
<ToggleControl
label={ __( 'Autoplay', 'amp' ) }
checked={ autoPlay }
onChange={ () => ( setAttributes( { autoPlay: ! autoPlay } ) ) }
/>
{
getLayoutControls( props, ampLayoutOptions )
}
</PanelBody>
</InspectorControls>
{
url && getMediaPlaceholder( __( 'O2 Player', 'amp' ), url )
}
Expand Down
Loading