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

CheckboxControl: move icons out of labels #45535

Merged
merged 5 commits into from
Nov 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/block-editor/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

### Enhancement

- `BlockLockModal`: Move Icon component out of CheckboxControl label ([#45535](https://github.com/WordPress/gutenberg/pull/45535))

## 10.4.0 (2022-11-02)

### Bug Fix
Expand Down
51 changes: 15 additions & 36 deletions packages/block-editor/src/components/block-lock/modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,18 +136,7 @@ export default function BlockLockModal( { clientId, onClose } ) {
<li className="block-editor-block-lock-modal__checklist-item">
<CheckboxControl
__nextHasNoMarginBottom
label={
<>
{ __( 'Restrict editing' ) }
<Icon
icon={
lock.edit
? lockIcon
: unlockIcon
}
/>
</>
}
label={ __( 'Restrict editing' ) }
checked={ !! lock.edit }
onChange={ ( edit ) =>
setLock( ( prevLock ) => ( {
Expand All @@ -156,23 +145,16 @@ export default function BlockLockModal( { clientId, onClose } ) {
} ) )
}
/>
<Icon
className="block-editor-block-lock-modal__lock-icon"
icon={ lock.edit ? lockIcon : unlockIcon }
/>
</li>
) }
<li className="block-editor-block-lock-modal__checklist-item">
<CheckboxControl
__nextHasNoMarginBottom
label={
<>
{ __( 'Disable movement' ) }
<Icon
icon={
lock.move
? lockIcon
: unlockIcon
}
/>
</>
}
label={ __( 'Disable movement' ) }
checked={ lock.move }
onChange={ ( move ) =>
setLock( ( prevLock ) => ( {
Expand All @@ -181,22 +163,15 @@ export default function BlockLockModal( { clientId, onClose } ) {
} ) )
}
/>
<Icon
className="block-editor-block-lock-modal__lock-icon"
icon={ lock.move ? lockIcon : unlockIcon }
/>
</li>
<li className="block-editor-block-lock-modal__checklist-item">
<CheckboxControl
__nextHasNoMarginBottom
label={
<>
{ __( 'Prevent removal' ) }
<Icon
icon={
lock.remove
? lockIcon
: unlockIcon
}
/>
</>
}
label={ __( 'Prevent removal' ) }
checked={ lock.remove }
onChange={ ( remove ) =>
setLock( ( prevLock ) => ( {
Expand All @@ -205,6 +180,10 @@ export default function BlockLockModal( { clientId, onClose } ) {
} ) )
}
/>
<Icon
className="block-editor-block-lock-modal__lock-icon"
icon={ lock.remove ? lockIcon : unlockIcon }
/>
</li>
</ul>
{ hasTemplateLock && (
Expand Down
23 changes: 8 additions & 15 deletions packages/block-editor/src/components/block-lock/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,17 @@
}
}
.block-editor-block-lock-modal__checklist-item {
display: flex;
justify-content: space-between;
Copy link
Member

Choose a reason for hiding this comment

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

Would it be worth adding a flex-gap so the text and icon don't run together when the text is long?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That makes sense to me!

align-items: center;
gap: $grid-unit-15;
margin-bottom: 0;
padding: $grid-unit-15 0 $grid-unit-15 $grid-unit-40;

.components-base-control__field {
align-items: center;
display: flex;
}

.components-checkbox-control__label {
display: flex;
align-items: center;
justify-content: space-between;
flex-grow: 1;

svg {
margin-right: $grid-unit-15;
fill: $gray-900;
}
.block-editor-block-lock-modal__lock-icon {
flex-shrink: 0;
margin-right: $grid-unit-15;
fill: $gray-900;
Copy link
Member

Choose a reason for hiding this comment

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

The fill hack is not ideal (#40102), but I understand why it's needed at the moment. (No action required, just mentioning for future context.)

}

&:hover {
Expand Down
4 changes: 4 additions & 0 deletions packages/edit-post/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

### Enhancement

- ` BlockTypesChecklist`: Move BlockIcon component out of CheckboxControl label ([#45535](https://github.com/WordPress/gutenberg/pull/45535))

## 6.18.0 (2022-11-02)

## 6.17.0 (2022-10-19)
Expand Down
8 changes: 2 additions & 6 deletions packages/edit-post/src/components/block-manager/checklist.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,13 @@ function BlockTypesChecklist( { blockTypes, value, onItemChange } ) {
>
<CheckboxControl
__nextHasNoMarginBottom
label={
<>
{ blockType.title }
<BlockIcon icon={ blockType.icon } />
</>
}
label={ blockType.title }
checked={ value.includes( blockType.name ) }
onChange={ ( ...args ) =>
onItemChange( blockType.name, ...args )
}
/>
<BlockIcon icon={ blockType.icon } />
</li>
) ) }
</ul>
Expand Down
18 changes: 4 additions & 14 deletions packages/edit-post/src/components/block-manager/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -51,29 +51,19 @@
.edit-post-block-manager__category-title,
.edit-post-block-manager__checklist-item {
border-bottom: 1px solid $gray-300;

.components-base-control__field {
align-items: center;
display: flex;
}
}

.edit-post-block-manager__checklist-item {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 0;
padding-left: $grid-unit-20;
padding: $grid-unit-10 0 $grid-unit-10 $grid-unit-20;

.components-modal__content &.components-checkbox-control__input-container {
margin: 0 $grid-unit-10;
}

.components-checkbox-control__label {
display: flex;
align-items: center;
justify-content: space-between;
flex-grow: 1;
padding: $grid-unit-10 0;
}

.block-editor-block-icon {
margin-right: 10px;
fill: $gray-900;
Expand Down