Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply minimal variant to pagination dropdown #63815

Merged
merged 16 commits into from
Aug 13, 2024
Merged
59 changes: 27 additions & 32 deletions packages/dataviews/src/components/dataviews-pagination/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,38 +40,33 @@ function DataViewsPagination() {
spacing={ 2 }
className="dataviews-pagination__page-selection"
>
{ createInterpolateElement(
sprintf(
// translators: %s: Total number of pages.
_x( 'Page <CurrentPageControl /> of %s', 'paging' ),
totalPages
),
{
CurrentPageControl: (
<SelectControl
aria-label={ __( 'Current page' ) }
value={ view.page?.toString() }
options={ Array.from(
Array( totalPages )
).map( ( _, i ) => {
const page = i + 1;
return {
value: page.toString(),
label: page.toString(),
};
} ) }
onChange={ ( newValue ) => {
onChangeView( {
...view,
page: +newValue,
} );
} }
size="compact"
__nextHasNoMarginBottom
/>
),
}
) }
<SelectControl
aria-label={ __( 'Current page' ) }
value={ view.page?.toString() }
options={ Array.from( Array( totalPages ) ).map(
( _, i ) => {
const page = i + 1;
return {
value: page.toString(),
label: sprintf(
// translators: 1: Current page number, 2: Total number of pages
__( 'Page %1$s of %2$s' ),
page.toString(),
totalPages
),
};
}
) }
onChange={ ( newValue ) => {
onChangeView( {
...view,
page: +newValue,
} );
} }
size="compact"
__nextHasNoMarginBottom
variant="minimal"
/>
</HStack>
<HStack expanded={ false } spacing={ 1 }>
<Button
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@
}

.dataviews-pagination__page-selection {
font-size: 11px;
text-transform: uppercase;
font-weight: 500;
color: $gray-900;
.components-select-control__input {
&:hover,
&:focus {
color: $gray-900;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc @mirka when using the minimal variant of SelectControl, some wp-admin styles bleed through affecting the hover/focus color. I wonder if we should fix that in the component?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed! Fix at #63855

}
}
}

/* stylelint-disable-next-line scss/at-rule-no-unknown -- '@container' not globally permitted */
Expand Down
4 changes: 4 additions & 0 deletions packages/dataviews/src/layouts/list/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -185,5 +185,9 @@

& + .dataviews-pagination {
justify-content: space-between;

.dataviews-pagination__page-selection {
margin-left: - $grid-unit-10; // Offset the padding applied to the SelectControl
}
}
}
Loading