-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Implement video settings. * Share common settings between native and web * Remove unused methods.
- Loading branch information
1 parent
353b384
commit f50a976
Showing
3 changed files
with
93 additions
and
54 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 |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { __ } from '@wordpress/i18n'; | ||
import { | ||
ToggleControl, | ||
SelectControl, | ||
} from '@wordpress/components'; | ||
|
||
const VideoSettings = ( { setAttributes, attributes } ) => { | ||
const { | ||
autoplay, | ||
controls, | ||
loop, | ||
muted, | ||
playsInline, | ||
preload, | ||
} = attributes; | ||
|
||
const getAutoplayHelp = ( checked ) => { | ||
return checked ? __( 'Note: Autoplaying videos may cause usability issues for some visitors.' ) : null; | ||
}; | ||
|
||
const toggleAttribute = ( attribute ) => { | ||
return ( newValue ) => { | ||
setAttributes( { [ attribute ]: newValue } ); | ||
}; | ||
}; | ||
|
||
return ( | ||
<> | ||
<ToggleControl | ||
label={ __( 'Autoplay' ) } | ||
onChange={ toggleAttribute( 'autoplay' ) } | ||
checked={ autoplay } | ||
help={ getAutoplayHelp } | ||
/> | ||
<ToggleControl | ||
label={ __( 'Loop' ) } | ||
onChange={ toggleAttribute( 'loop' ) } | ||
checked={ loop } | ||
/> | ||
<ToggleControl | ||
label={ __( 'Muted' ) } | ||
onChange={ toggleAttribute( 'muted' ) } | ||
checked={ muted } | ||
/> | ||
<ToggleControl | ||
label={ __( 'Playback Controls' ) } | ||
onChange={ toggleAttribute( 'controls' ) } | ||
checked={ controls } | ||
/> | ||
<ToggleControl | ||
label={ __( 'Play inline' ) } | ||
onChange={ toggleAttribute( 'playsInline' ) } | ||
checked={ playsInline } | ||
/> | ||
<SelectControl | ||
label={ __( 'Preload' ) } | ||
value={ preload } | ||
onChange={ ( value ) => setAttributes( { preload: value } ) } | ||
options={ [ | ||
{ value: 'auto', label: __( 'Auto' ) }, | ||
{ value: 'metadata', label: __( 'Metadata' ) }, | ||
{ value: 'none', label: __( 'None' ) }, | ||
] } | ||
/> | ||
</> | ||
); | ||
}; | ||
|
||
export default VideoSettings; |
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