UNPKG

@wordpress/block-library

Version:
8 lines (7 loc) 3.14 kB
{ "version": 3, "sources": ["../../src/video/variations.js"], "sourcesContent": ["import { __ } from '@wordpress/i18n';\nimport { video as videoIcon } from '@wordpress/icons';\n\n/**\n * Whether a set of Video block attributes describes a GIF-behaving video: a\n * muted, looping, autoplaying, inline video with no controls. An animated GIF\n * uploaded through the editor is converted to a video and presented with these\n * attributes so it plays like the original GIF.\n *\n * @param {Object} attributes Video block attributes.\n * @param {boolean} attributes.controls Whether playback controls are shown.\n * @param {boolean} attributes.loop Whether the video loops.\n * @param {boolean} attributes.autoplay Whether the video autoplays.\n * @param {boolean} attributes.muted Whether the video is muted.\n * @param {boolean} attributes.playsInline Whether the video plays inline.\n *\n * @return {boolean} Whether the attributes describe a GIF-behaving video.\n */\nexport const isGifVariation = ( {\n\tcontrols,\n\tloop,\n\tautoplay,\n\tmuted,\n\tplaysInline,\n} = {} ) => ! controls && !! loop && !! autoplay && !! muted && !! playsInline;\n\nconst variations = [\n\t{\n\t\tname: 'video',\n\t\ttitle: __( 'Video' ),\n\t\tdescription: __(\n\t\t\t'A video with customizable playback and interaction controls.'\n\t\t),\n\t\ticon: videoIcon,\n\t\tattributes: { controls: true },\n\t\tisActive: ( blockAttributes ) => ! isGifVariation( blockAttributes ),\n\t\t// Not offered in the inserter; used to label a regular video and to\n\t\t// switch a GIF back to a standard video.\n\t\tscope: [ 'block', 'transform' ],\n\t},\n\t{\n\t\tname: 'gif',\n\t\ttitle: __( 'GIF' ),\n\t\tdescription: __(\n\t\t\t'A muted, looping video that plays automatically like an animated GIF.'\n\t\t),\n\t\ticon: videoIcon,\n\t\tkeywords: [ __( 'animated' ), 'gif' ],\n\t\tattributes: {\n\t\t\tcontrols: false,\n\t\t\tloop: true,\n\t\t\tautoplay: true,\n\t\t\tmuted: true,\n\t\t\tplaysInline: true,\n\t\t},\n\t\tisActive: ( blockAttributes ) => isGifVariation( blockAttributes ),\n\t\t// Created by converting an uploaded GIF, not inserted directly.\n\t\tscope: [ 'block', 'transform' ],\n\t},\n];\n\nexport default variations;\n"], "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAmB;AACnB,mBAAmC;AAiB5B,IAAM,iBAAiB,CAAE;AAAA,EAC/B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,IAAI,CAAC,MAAO,CAAE,YAAY,CAAC,CAAE,QAAQ,CAAC,CAAE,YAAY,CAAC,CAAE,SAAS,CAAC,CAAE;AAEnE,IAAM,aAAa;AAAA,EAClB;AAAA,IACC,MAAM;AAAA,IACN,WAAO,gBAAI,OAAQ;AAAA,IACnB,iBAAa;AAAA,MACZ;AAAA,IACD;AAAA,IACA,MAAM,aAAAA;AAAA,IACN,YAAY,EAAE,UAAU,KAAK;AAAA,IAC7B,UAAU,CAAE,oBAAqB,CAAE,eAAgB,eAAgB;AAAA;AAAA;AAAA,IAGnE,OAAO,CAAE,SAAS,WAAY;AAAA,EAC/B;AAAA,EACA;AAAA,IACC,MAAM;AAAA,IACN,WAAO,gBAAI,KAAM;AAAA,IACjB,iBAAa;AAAA,MACZ;AAAA,IACD;AAAA,IACA,MAAM,aAAAA;AAAA,IACN,UAAU,KAAE,gBAAI,UAAW,GAAG,KAAM;AAAA,IACpC,YAAY;AAAA,MACX,UAAU;AAAA,MACV,MAAM;AAAA,MACN,UAAU;AAAA,MACV,OAAO;AAAA,MACP,aAAa;AAAA,IACd;AAAA,IACA,UAAU,CAAE,oBAAqB,eAAgB,eAAgB;AAAA;AAAA,IAEjE,OAAO,CAAE,SAAS,WAAY;AAAA,EAC/B;AACD;AAEA,IAAO,qBAAQ;", "names": ["videoIcon"] }