UNPKG

@wordpress/block-library

Version:
1 lines • 2.76 kB
{"version":3,"file":"variations.mjs","names":[],"sources":["../../src/gallery/variations.js"],"sourcesContent":["import { __ } from '@wordpress/i18n';\nimport { gallery, grid } from '@wordpress/icons';\nimport { ATTACHED_MEDIA } from './dynamic-source';\nimport { isGalleryFlexLayout } from './shared';\n\nconst variations = [\n\t{\n\t\tname: 'dynamic-gallery',\n\t\ttitle: __( 'Dynamic Gallery' ),\n\t\tdescription: __(\n\t\t\t'Display images from a source, such as those attached to the current post.'\n\t\t),\n\t\tattributes: {\n\t\t\tdynamicContent: { source: ATTACHED_MEDIA },\n\t\t},\n\t\t// Match any gallery that has a dynamic source configured, regardless of\n\t\t// the specific source or options, so the variation's title and\n\t\t// description describe the block whenever it runs in dynamic mode.\n\t\tisActive: ( blockAttributes ) => !! blockAttributes.dynamicContent,\n\t\t// No scopes for now. While dynamic mode only supports the \"attached to the\n\t\t// current post\" source, `'inserter'` is intentionally omitted: a dedicated\n\t\t// inserter entry would surface in post-less contexts (templates, template\n\t\t// parts, synced patterns) where there's no post to resolve images from. The\n\t\t// entry point is instead the inspector toggle on a regular Gallery.\n\t\t// `isActive` still relabels the block card to \"Dynamic Gallery\" regardless\n\t\t// of scope. Revisit adding `'inserter'` in a follow-up as the feature grows\n\t\t// beyond the post-attached source.\n\t\tscope: [],\n\t},\n\t{\n\t\tname: 'gallery-flex',\n\t\ttitle: __( 'Gallery' ),\n\t\tdescription: __( 'Arrange images in flexible rows.' ),\n\t\ticon: gallery,\n\t\tattributes: {\n\t\t\tlayout: {\n\t\t\t\ttype: 'flex',\n\t\t\t},\n\t\t},\n\t\tisActive: ( blockAttributes ) =>\n\t\t\tisGalleryFlexLayout( blockAttributes.layout ),\n\t\tscope: [ 'transform' ],\n\t},\n\t{\n\t\tname: 'gallery-grid',\n\t\ttitle: __( 'Gallery Grid' ),\n\t\tdescription: __( 'Arrange images in a grid.' ),\n\t\ticon: grid,\n\t\tattributes: {\n\t\t\tlayout: {\n\t\t\t\ttype: 'grid',\n\t\t\t},\n\t\t},\n\t\tisActive: ( blockAttributes ) =>\n\t\t\tblockAttributes.layout?.type === 'grid',\n\t\tscope: [ 'transform' ],\n\t},\n];\n\nexport default variations;\n"],"mappings":";;;;;AAKA,MAAM,aAAa;CAClB;EACC,MAAM;EACN,OAAO,GAAI,iBAAkB;EAC7B,aAAa,GACZ,2EACD;EACA,YAAY,EACX,gBAAgB,EAAE,QAAQ,eAAe,EAC1C;EAIA,WAAY,oBAAqB,CAAC,CAAE,gBAAgB;EASpD,OAAO,CAAC;CACT;CACA;EACC,MAAM;EACN,OAAO,GAAI,SAAU;EACrB,aAAa,GAAI,kCAAmC;EACpD,MAAM;EACN,YAAY,EACX,QAAQ,EACP,MAAM,OACP,EACD;EACA,WAAY,oBACX,oBAAqB,gBAAgB,MAAO;EAC7C,OAAO,CAAE,WAAY;CACtB;CACA;EACC,MAAM;EACN,OAAO,GAAI,cAAe;EAC1B,aAAa,GAAI,2BAA4B;EAC7C,MAAM;EACN,YAAY,EACX,QAAQ,EACP,MAAM,OACP,EACD;EACA,WAAY,oBACX,gBAAgB,QAAQ,SAAS;EAClC,OAAO,CAAE,WAAY;CACtB;AACD"}