From c9e762eefb07faf7060bb52c5d5a56ab7355755a Mon Sep 17 00:00:00 2001 From: mateuswetah Date: Wed, 3 Nov 2021 16:19:32 -0300 Subject: [PATCH] Adds transform from carousel items list to dynamic items list. --- .../blocks/carousel-items-list/index.js | 4 +- .../blocks/carousel-items-list/transforms.js | 73 +++++++++++++++++++ 2 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 src/views/gutenberg-blocks/blocks/carousel-items-list/transforms.js diff --git a/src/views/gutenberg-blocks/blocks/carousel-items-list/index.js b/src/views/gutenberg-blocks/blocks/carousel-items-list/index.js index 956c07742..39540ea88 100644 --- a/src/views/gutenberg-blocks/blocks/carousel-items-list/index.js +++ b/src/views/gutenberg-blocks/blocks/carousel-items-list/index.js @@ -5,11 +5,13 @@ import icon from './icon.js'; import edit from './edit.js'; import save from './save.js'; import deprecated from './deprecated.js'; +import transforms from './transforms.js'; tainacanRegisterBlockType({ metadata, icon, edit, save, - deprecated + deprecated, + transforms }); diff --git a/src/views/gutenberg-blocks/blocks/carousel-items-list/transforms.js b/src/views/gutenberg-blocks/blocks/carousel-items-list/transforms.js new file mode 100644 index 000000000..65bde2f50 --- /dev/null +++ b/src/views/gutenberg-blocks/blocks/carousel-items-list/transforms.js @@ -0,0 +1,73 @@ +const { createBlock } = wp.blocks; + +export default { + to: [ + { + type: 'block', + blocks: [ 'tainacan/dynamic-items-list' ], + transform: ( { + items, + collectionId, + searchURL, + maxItemsNumber, + maxItemsPerScreen, + spaceBetweenItems, + selectedItems, + loadStrategy, + hideTitle, + cropImagesToSquare, + showCollectionHeader, + showCollectionLabel, + collection, + collectionBackgroundColor, + collectionTextColor, + align, + textColor, + fontSize + } ) => { + return createBlock( + 'tainacan/dynamic-items-list', + { + items: items, + content: [ { type: true } ], + collection: collection, + collectionId: collectionId, + showImage: true, + showName: !hideTitle, + layout: 'grid', + isModalOpen: false, + gridMargin: spaceBetweenItems, + searchURL: searchURL, + itemsRequestSource: '', + maxItemsNumber: maxItemsNumber, + order: '', + searchString: '', + selectedItems: selectedItems, + isLoading: false, + loadStrategy: loadStrategy, + showSearchBar: false, + showCollectionHeader: showCollectionHeader, + showCollectionLabel: showCollectionLabel, + isLoadingCollection: false, + collectionBackgroundColor: collectionBackgroundColor, + collectionTextColor: collectionTextColor, + mosaicHeight: 280, + mosaicGridColumns: maxItemsPerScreen, + mosaicGridRows: 3, + mosaicItemFocalPoint: { + x: 0.5, + y: 0.5 + }, + sampleBackgroundImage: '', + mosaicDensity: 6, + maxColumnsCount: 4, + cropImagesToSquare: cropImagesToSquare, + align: align, + textColor: textColor, + fontSize: fontSize + } + ); + }, + } + ] +}; \ No newline at end of file