Skip to content

Commit

Permalink
pagination at the bottom of the frame
Browse files Browse the repository at this point in the history
  • Loading branch information
ntsekouras committed Oct 26, 2023
1 parent 8d04537 commit 2caf1f9
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 45 deletions.
2 changes: 1 addition & 1 deletion packages/edit-site/src/components/dataviews/dataviews.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default function DataViews( {
}, [ fields ] );
return (
<div className="dataviews-wrapper">
<VStack spacing={ 4 }>
<VStack spacing={ 4 } justify="flex-start">
<HStack>
<HStack justify="start">
<Filters
Expand Down
36 changes: 0 additions & 36 deletions packages/edit-site/src/components/dataviews/pagination.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,46 +6,11 @@ import {
__experimentalHStack as HStack,
__experimentalText as Text,
__experimentalNumberControl as NumberControl,
__experimentalInputControlPrefixWrapper as InputControlPrefixWrapper,
SelectControl,
} from '@wordpress/components';
import { createInterpolateElement } from '@wordpress/element';
import { sprintf, __, _x, _n } from '@wordpress/i18n';
import { chevronRight, chevronLeft, previous, next } from '@wordpress/icons';

const PAGE_SIZE_VALUES = [ 5, 20, 50 ];
function PageSizeControl( { view, onChangeView } ) {
const label = __( 'Rows per page:' );
return (
<SelectControl
__nextHasNoMarginBottom
label={ label }
hideLabelFromVision
// TODO: This should probably use a label based on the wanted design
// and we could remove InputControlPrefixWrapper usage.
prefix={
<InputControlPrefixWrapper
as="span"
className="dataviews__select-control-prefix"
>
{ label }
</InputControlPrefixWrapper>
}
value={ view.perPage }
options={ PAGE_SIZE_VALUES.map( ( pageSize ) => ( {
value: pageSize,
label: pageSize,
} ) ) }
onChange={ ( value ) =>
onChangeView( { ...view, perPage: value, page: 1 } )
}
/>
);
}

// For now this is copied from the patterns list Pagination component, because
// the datatable pagination starts from index zero(`0`). Eventually all lists will be
// using this one.
function Pagination( {
view,
onChangeView,
Expand Down Expand Up @@ -167,7 +132,6 @@ function Pagination( {
</HStack>
</HStack>
) }
<PageSizeControl view={ view } onChangeView={ onChangeView } />
</HStack>
);
}
Expand Down
15 changes: 7 additions & 8 deletions packages/edit-site/src/components/dataviews/style.scss
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
.dataviews-wrapper {
width: 100%;
min-height: calc(100% - 60px);
overflow: auto;
padding: $grid-unit-40;

> div {
min-height: 100%;
}
}

.dataviews-pagination {
position: sticky;
bottom: $grid-unit-20;
background: $white;
margin-top: auto;
}

.dataviews-list-view {
Expand Down Expand Up @@ -36,11 +40,6 @@
}
}

.dataviews__select-control-prefix {
color: $gray-700;
text-wrap: nowrap;
}

.dataviews-view-grid__media {
width: 100%;
min-height: 200px;
Expand Down

0 comments on commit 2caf1f9

Please sign in to comment.