Skip to content

Commit

Permalink
Fix: Button Replace remaining 40px default size violations [Block Edi…
Browse files Browse the repository at this point in the history
…tor 2] (WordPress#65308)

* Add __next40pxDefaultSize for block-editor 2 files

* Add size compact to buttons

* Remove style overrides

---------

Co-authored-by: dhruvang21 <dhruvang21@git.wordpress.org>
Co-authored-by: ciampo <mciampini@git.wordpress.org>
Co-authored-by: hbhalodia <hbhalodia@git.wordpress.org>
  • Loading branch information
4 people authored Sep 26, 2024
1 parent 427a8d0 commit d0bcf79
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ function BlockNavigationDropdownToggle( {
} ) {
return (
<Button
// TODO: Switch to `true` (40px size) if possible
__next40pxDefaultSize={ false }
__next40pxDefaultSize
{ ...props }
ref={ innerRef }
icon={ listView }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ import { VIEWMODES } from './constants';
const Actions = ( { onBlockPatternSelect } ) => (
<div className="block-editor-block-pattern-setup__actions">
<Button
// TODO: Switch to `true` (40px size) if possible
__next40pxDefaultSize={ false }
__next40pxDefaultSize
variant="primary"
onClick={ onBlockPatternSelect }
>
Expand All @@ -36,17 +35,15 @@ const CarouselNavigation = ( {
} ) => (
<div className="block-editor-block-pattern-setup__navigation">
<Button
// TODO: Switch to `true` (40px size) if possible
__next40pxDefaultSize={ false }
size="compact"
icon={ isRTL() ? chevronRight : chevronLeft }
label={ __( 'Previous pattern' ) }
onClick={ handlePrevious }
disabled={ activeSlide === 0 }
accessibleWhenDisabled
/>
<Button
// TODO: Switch to `true` (40px size) if possible
__next40pxDefaultSize={ false }
size="compact"
icon={ isRTL() ? chevronLeft : chevronRight }
label={ __( 'Next pattern' ) }
onClick={ handleNext }
Expand All @@ -69,16 +66,14 @@ const SetupToolbar = ( {
const displayControls = (
<div className="block-editor-block-pattern-setup__display-controls">
<Button
// TODO: Switch to `true` (40px size) if possible
__next40pxDefaultSize={ false }
size="compact"
icon={ stretchFullWidth }
label={ __( 'Carousel view' ) }
onClick={ () => setViewMode( VIEWMODES.carousel ) }
isPressed={ isCarouselView }
/>
<Button
// TODO: Switch to `true` (40px size) if possible
__next40pxDefaultSize={ false }
size="compact"
icon={ grid }
label={ __( 'Grid view' ) }
onClick={ () => setViewMode( VIEWMODES.grid ) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,24 +38,24 @@ export default function Pagination( {
className="block-editor-patterns__grid-pagination-previous"
>
<Button
// TODO: Switch to `true` (40px size) if possible
__next40pxDefaultSize={ false }
variant="tertiary"
onClick={ () => changePage( 1 ) }
disabled={ currentPage === 1 }
aria-label={ __( 'First page' ) }
size="compact"
accessibleWhenDisabled
className="block-editor-patterns__grid-pagination-button"
>
<span>«</span>
</Button>
<Button
// TODO: Switch to `true` (40px size) if possible
__next40pxDefaultSize={ false }
variant="tertiary"
onClick={ () => changePage( currentPage - 1 ) }
disabled={ currentPage === 1 }
aria-label={ __( 'Previous page' ) }
size="compact"
accessibleWhenDisabled
className="block-editor-patterns__grid-pagination-button"
>
<span></span>
</Button>
Expand All @@ -74,13 +74,13 @@ export default function Pagination( {
className="block-editor-patterns__grid-pagination-next"
>
<Button
// TODO: Switch to `true` (40px size) if possible
__next40pxDefaultSize={ false }
variant="tertiary"
onClick={ () => changePage( currentPage + 1 ) }
disabled={ currentPage === numPages }
aria-label={ __( 'Next page' ) }
size="compact"
accessibleWhenDisabled
className="block-editor-patterns__grid-pagination-button"
>
<span></span>
</Button>
Expand All @@ -89,8 +89,9 @@ export default function Pagination( {
onClick={ () => changePage( numPages ) }
disabled={ currentPage === numPages }
aria-label={ __( 'Last page' ) }
size="default"
size="compact"
accessibleWhenDisabled
className="block-editor-patterns__grid-pagination-button"
>
<span>»</span>
</Button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,37 +4,20 @@
border-top: 1px solid $gray-800;
padding: $grid-unit-05;
justify-content: center;
.components-button.is-tertiary {
width: auto;
height: $button-size-compact;
justify-content: center;

&:disabled {
color: $gray-600;
background: none;
}

&:hover:not(:disabled) {
color: $white;
background-color: $gray-700;
}
}
}
}

.show-icon-labels {
.block-editor-patterns__grid-pagination {
.components-button {
width: auto;
// Hide the button icons when labels are set to display...
span {
display: none;
}
// ... and display labels.
// Uses ::before as ::after is already used for active tab styling.
&::before {
content: attr(aria-label);
}
.block-editor-patterns__grid-pagination-button {
width: auto;
// Hide the button icons when labels are set to display...
span {
display: none;
}
// ... and display labels.
// Uses ::before as ::after is already used for active tab styling.
&::before {
content: attr(aria-label);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@ function BlockQuickNavigationItem( { clientId, onSelect } ) {

return (
<Button
// TODO: Switch to `true` (40px size) if possible
__next40pxDefaultSize={ false }
__next40pxDefaultSize
isPressed={ isSelected }
onClick={ async () => {
await selectBlock( clientId );
Expand Down

0 comments on commit d0bcf79

Please sign in to comment.