Adds transform from carousel items list to dynamic items list.

This commit is contained in:
mateuswetah 2021-11-03 16:19:32 -03:00
parent c686e7ce0e
commit c9e762eefb
2 changed files with 76 additions and 1 deletions

View File

@ -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
});

View File

@ -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
}
);
},
}
]
};