From 048ab873adbd04b2b844b893060c0938c631e7c5 Mon Sep 17 00:00:00 2001 From: Andrew Serong <14988353+andrewserong@users.noreply.github.com> Date: Wed, 5 Nov 2025 15:11:42 +1100 Subject: [PATCH 01/16] DataViewsPicker: Try a paddingX prop to override horizontal padding --- .../components/dataviews-footer/style.scss | 20 ++-- .../src/components/dataviews-picker/index.tsx | 17 +++- .../src/components/dataviews/index.tsx | 17 +++- .../src/components/dataviews/style.scss | 93 ++++++++++++------- .../src/stories/dataviews-picker.story.tsx | 35 +++---- 5 files changed, 123 insertions(+), 59 deletions(-) diff --git a/packages/dataviews/src/components/dataviews-footer/style.scss b/packages/dataviews/src/components/dataviews-footer/style.scss index 9f22c42c2d6163..0be05d5419edb3 100644 --- a/packages/dataviews/src/components/dataviews-footer/style.scss +++ b/packages/dataviews/src/components/dataviews-footer/style.scss @@ -6,8 +6,8 @@ position: sticky; bottom: 0; left: 0; - background-color: inherit; - padding: $grid-unit-15 $grid-unit-60; + background-color: $white; + padding: $grid-unit-15 0; border-top: $border-width solid $gray-100; flex-shrink: 0; @@ -18,12 +18,6 @@ z-index: z-index(".dataviews-footer"); } -@container (max-width: 430px) { - .dataviews-footer { - padding: $grid-unit-15 $grid-unit-30; - } -} - @container (max-width: 560px) { .dataviews-footer { flex-direction: column !important; @@ -42,3 +36,13 @@ } } } + +/** + * Apply custom padding-x from the wrapper to the footer. + */ +.dataviews-wrapper, +.dataviews-picker-wrapper { + .dataviews-footer { + padding: $grid-unit-15 var(--dataviews-padding-x, $grid-unit-60); + } +} diff --git a/packages/dataviews/src/components/dataviews-picker/index.tsx b/packages/dataviews/src/components/dataviews-picker/index.tsx index a97bb40825978f..70d2161a82a357 100644 --- a/packages/dataviews/src/components/dataviews-picker/index.tsx +++ b/packages/dataviews/src/components/dataviews-picker/index.tsx @@ -63,6 +63,7 @@ type DataViewsPickerProps< Item > = { }; itemListLabel?: string; empty?: ReactNode; + paddingX?: string | number; } & ( Item extends ItemWithId ? { getItemId?: ( item: Item ) => string } : { getItemId: ( item: Item ) => string } ); @@ -128,6 +129,7 @@ function DataViewsPicker< Item >( { config = { perPageSizes: [ 10, 20, 50, 100 ] }, itemListLabel, empty, + paddingX, }: DataViewsPickerProps< Item > ) { const { infiniteScrollHandler } = paginationInfo; const containerRef = useRef< HTMLDivElement | null >( null ); @@ -242,7 +244,20 @@ function DataViewsPicker< Item >( { hasInfiniteScrollHandler: !! infiniteScrollHandler, } } > -
+
{ children ?? ( ) } diff --git a/packages/dataviews/src/components/dataviews/index.tsx b/packages/dataviews/src/components/dataviews/index.tsx index 07cda5d91bd9b7..fd66fcdbc05f91 100644 --- a/packages/dataviews/src/components/dataviews/index.tsx +++ b/packages/dataviews/src/components/dataviews/index.tsx @@ -66,6 +66,7 @@ type DataViewsProps< Item > = { perPageSizes: number[]; }; empty?: ReactNode; + paddingX?: string | number; } & ( Item extends ItemWithId ? { getItemId?: ( item: Item ) => string } : { getItemId: ( item: Item ) => string } ); @@ -142,6 +143,7 @@ function DataViews< Item >( { children, config = { perPageSizes: [ 10, 20, 50, 100 ] }, empty, + paddingX, }: DataViewsProps< Item > ) { const { infiniteScrollHandler } = paginationInfo; const containerRef = useRef< HTMLDivElement | null >( null ); @@ -271,7 +273,20 @@ function DataViews< Item >( { hasInfiniteScrollHandler: !! infiniteScrollHandler, } } > -
+
{ children ?? ( []; selection?: string[]; + paddingX?: string | number; } const DataViewsPickerContent = ( { @@ -72,8 +72,10 @@ const DataViewsPickerContent = ( { infiniteScrollEnabled, actions: customActions, selection: customSelection, + paddingX, }: PickerContentProps ) => { const [ view, setView ] = useState< View >( { + type: LAYOUT_PICKER_GRID, fields: [], titleField: 'title', mediaField: 'image', @@ -81,8 +83,7 @@ const DataViewsPickerContent = ( { page: 1, perPage: 10, filters: [], - type: LAYOUT_PICKER_GRID, - groupBy: isGrouped ? { field: 'type', direction: 'asc' } : undefined, + groupByField: isGrouped ? 'type' : undefined, infiniteScrollEnabled, } ); const { data: shownData, paginationInfo: normalPaginationInfo } = @@ -93,10 +94,8 @@ const DataViewsPickerContent = ( { useEffect( () => { setView( ( prevView ) => ( { ...prevView, - groupBy: - isGrouped && ! infiniteScrollEnabled - ? { field: 'type', direction: 'asc' } - : undefined, + groupByField: + isGrouped && ! infiniteScrollEnabled ? 'type' : undefined, infiniteScrollEnabled, } ) ); }, [ isGrouped, infiniteScrollEnabled ] ); @@ -141,14 +140,13 @@ const DataViewsPickerContent = ( { setView, data: shownData, getItemId: ( item ) => item.id.toString(), - totalDataLength: data.length, } ); return ( <> { infiniteScrollEnabled && (