Skip to content

Commit

Permalink
spacing
Browse files Browse the repository at this point in the history
  • Loading branch information
jameskoster committed Oct 19, 2023
1 parent 009a6fc commit cc33429
Showing 1 changed file with 77 additions and 61 deletions.
138 changes: 77 additions & 61 deletions packages/edit-site/src/components/dataviews/pagination.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,75 +73,91 @@ function Pagination( {
}
</Text>
{ !! totalItems && (
<HStack expanded={ false } spacing={ 1 }>
<Button
onClick={ () => onChangeView( { ...view, page: 0 } ) }
disabled={ view.page === 0 }
label={ __( 'First page' ) }
icon={ previous }
showTooltip
/>
<Button
onClick={ () =>
onChangeView( { ...view, page: view.page - 1 } )
}
disabled={ view.page === 0 }
label={ __( 'Previous page' ) }
icon={ chevronLeft }
showTooltip
/>
<HStack expanded={ false } spacing={ 3 }>
<HStack
justify="flex-start"
expanded={ false }
spacing={ 1 }
>
{ createInterpolateElement(
sprintf(
// translators: %1$s: Current page number, %2$s: Total number of pages.
_x( '<CurrenPageControl /> of %2$s', 'paging' ),
currentPage,
totalPages
),
{
CurrenPageControl: (
<NumberControl
aria-label={ __( 'Current page' ) }
min={ 1 }
max={ totalPages }
onChange={ ( value ) => {
if ( value > totalPages ) return;
onChangeView( {
...view,
page: view.page - 1,
} );
} }
step="1"
value={ currentPage }
isDragEnabled={ false }
spinControls="none"
/>
),
<Button
onClick={ () => onChangeView( { ...view, page: 0 } ) }
disabled={ view.page === 0 }
label={ __( 'First page' ) }
icon={ previous }
showTooltip
size='compact'
/>
<Button
onClick={ () =>
onChangeView( { ...view, page: view.page - 1 } )
}
) }
disabled={ view.page === 0 }
label={ __( 'Previous page' ) }
icon={ chevronLeft }
showTooltip
size='compact'
/>
</HStack>
<Button
onClick={ () =>
onChangeView( { ...view, page: view.page + 1 } )
}
disabled={ view.page >= totalPages - 1 }
label={ __( 'Next page' ) }
icon={ chevronRight }
showTooltip
/>
<Button
onClick={ () =>
onChangeView( { ...view, page: totalPages - 1 } )
<HStack
justify="flex-start"
expanded={ false }
spacing={ 2 }
>
{ createInterpolateElement(
sprintf(
// translators: %1$s: Current page number, %2$s: Total number of pages.
_x( '<CurrenPageControl /> of %2$s', 'paging' ),
currentPage,
totalPages
),
{
CurrenPageControl: (
<NumberControl
aria-label={ __( 'Current page' ) }
min={ 1 }
max={ totalPages }
onChange={ ( value ) => {
if ( value > totalPages ) return;
onChangeView( {
...view,
page: view.page - 1,
} );
} }
step="1"
value={ currentPage }
isDragEnabled={ false }
hideHTMLArrows
/>
),
}
disabled={ view.page >= totalPages - 1 }
label={ __( 'Last page' ) }
icon={ next }
showTooltip
/>
) }
</HStack>
<HStack
justify="flex-start"
expanded={ false }
spacing={ 1 }
>
<Button
onClick={ () =>
onChangeView( { ...view, page: view.page + 1 } )
}
disabled={ view.page >= totalPages - 1 }
label={ __( 'Next page' ) }
icon={ chevronRight }
showTooltip
size='compact'
/>
<Button
onClick={ () =>
onChangeView( { ...view, page: totalPages - 1 } )
}
disabled={ view.page >= totalPages - 1 }
label={ __( 'Last page' ) }
icon={ next }
showTooltip
size='compact'
/>
</HStack>
</HStack>
) }
<PageSizeControl view={ view } onChangeView={ onChangeView } />
Expand Down

0 comments on commit cc33429

Please sign in to comment.