From 130a145c7b41a6629a340ba46c200517e4085bc9 Mon Sep 17 00:00:00 2001 From: Nik Tsekouras Date: Thu, 23 Nov 2023 16:48:55 +0200 Subject: [PATCH] Dataviews: Add preview and grid view in templates list (#56382) * Dataviews: Add preview and grid view in templates list * Update preview design * Preview heights in grid view * fix linting issue * address feedback * minor tweak --------- Co-authored-by: James Koster --- .../src/components/dataviews/view-grid.js | 13 +++- .../src/components/dataviews/view-list.js | 10 ++- .../page-templates/dataviews-templates.js | 73 ++++++++++++++++++- .../src/components/page-templates/style.scss | 18 +++++ packages/edit-site/src/style.scss | 1 + 5 files changed, 107 insertions(+), 8 deletions(-) create mode 100644 packages/edit-site/src/components/page-templates/style.scss diff --git a/packages/edit-site/src/components/dataviews/view-grid.js b/packages/edit-site/src/components/dataviews/view-grid.js index b9d4bd78d96d6..d97a9db04200d 100644 --- a/packages/edit-site/src/components/dataviews/view-grid.js +++ b/packages/edit-site/src/components/dataviews/view-grid.js @@ -8,6 +8,7 @@ import { FlexBlock, Placeholder, } from '@wordpress/components'; +import { useAsyncList } from '@wordpress/compose'; /** * Internal dependencies @@ -23,9 +24,15 @@ export function ViewGrid( { data, fields, view, actions, getItemId } ) { ! view.hiddenFields.includes( field.id ) && field.id !== view.layout.mediaField ); + const shownData = useAsyncList( data, { step: 3 } ); return ( - - { data.map( ( item, index ) => { + + { shownData.map( ( item, index ) => { return (
@@ -50,7 +57,7 @@ export function ViewGrid( { data, fields, view, actions, getItemId } ) { ) ) } - +