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

Fix: Update styles for checkbox and radio controls. #61696

Merged
merged 11 commits into from
Jun 7, 2024

Conversation

vipul0425
Copy link
Contributor

What?

Fixes issue: #61652

Why?

The current spacing between the checkbox input and its label is inconsistent with that of the radio buttons, even though they have the same size.

How?

This PR updates the stylings for the checkbox control and radio control to make them consistent.

Testing Instructions

  1. Open any page or post in the editor and open its settings panel.
  2. Click on the published or discussions buttons and another tab should appear where one can test the checkbox and radio controls simultaneously.

Testing Instructions for Keyboard

nil

Screenshots or screencast

image

@vipul0425 vipul0425 requested a review from ajitbohra as a code owner May 15, 2024 21:00
Copy link

github-actions bot commented May 15, 2024

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: vipul0425 <vipulgupta003@git.wordpress.org>
Co-authored-by: mirka <0mirka00@git.wordpress.org>
Co-authored-by: jameskoster <jameskoster@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@jameskoster
Copy link
Contributor

Thanks for the PR, it will be nice to align the spacing here :)

I'd welcome feedback from others, but the balance doesn't feel quite right to me:

Screenshot 2024-05-16 at 14 16 03

Specifically, it's hierarchically awkward for the space between input + label to be larger than the space between each radio option. Perhaps 8px spacing between input + label, and 12px spacing between options would work better?

If this is preferable we should obviously update the checkbox component to match.

Screenshot 2024-05-16 at 14 18 07 Screenshot 2024-05-16 at 14 18 42

I appreciate the latter part is slightly out of scope, but it's indirectly related so probably fine to tweak here.

What do you think?

@jameskoster jameskoster requested review from a team May 16, 2024 13:22
@jameskoster jameskoster added [Type] Enhancement A suggestion for improvement. [Package] Components /packages/components labels May 16, 2024
@vipul0425
Copy link
Contributor Author

Hi @jameskoster,
Thanks for reviewing it. I have updated the spacing between the input and label to 8px.

@jameskoster
Copy link
Contributor

@vipul0425 thanks! How did you feel about increasing the spacing between radios to 12px?

@vipul0425
Copy link
Contributor Author

Hi @jameskoster, Sorry for replying that late. I have revised the spacing between radio controls to 12px and also rebased the branch.
Thanks.

Copy link
Member

@mirka mirka left a comment

Choose a reason for hiding this comment

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

I had some tweaks and questions, but on the whole this is looking good 👍

Comment on lines 34 to 36
{ __(
'Visitors cannot add new comments or replies. Existing comments remain visible.'
) }
Copy link
Member

Choose a reason for hiding this comment

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

Was this committed by accident?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, Actually when we updated the spacing between the spacing between the input and label to 12px then it was not looking visually appealing so converted it to a single line. But I think now its not required as we have revised it to 8px. Will update this in next commit.

Copy link
Member

Choose a reason for hiding this comment

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

Wait, is the extra wrapper remaining intentional?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh sorry @mirka it was a mistake 😓 Will update this.

@@ -55,7 +57,7 @@
.components-checkbox-control__input-container {
position: relative;
display: inline-block;
margin-right: $grid-unit-15;
margin-right: var(--checkbox-input-margin);
Copy link
Member

Choose a reason for hiding this comment

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

This change wasn't reflected in the help text margin, so I extracted it into a CSS var (f050242).

}

p.components-base-control__help:has(.components-checkbox-control__help) {
margin-top: $grid-unit-05;
Copy link
Member

Choose a reason for hiding this comment

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

Was this change discussed somewhere? The margin-top is still the standard 8px on the RadioControl, so not sure where this came from. I would prefer not to override this BaseControl style if possible, since it's a standard value across many components.

Copy link
Contributor Author

@vipul0425 vipul0425 Jun 4, 2024

Choose a reason for hiding this comment

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

To make it look consistent with the radio controls I have updated this to 4px. Let me know if we need to change this.
image

Copy link
Member

Choose a reason for hiding this comment

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

I see. That small text under those radio controls are custom spans injected by the consumer, and not the help text of the RadioControl component. The help text of the RadioControl is just a single chunk of text underneath all the options of a radio group.

Help text under RadioControl

The point is, we shouldn't be basing this decision (help text margin of the CheckboxControl) on a non-standard RadioControl use case like that "Status & visibility" panel.

For the scope of this PR, I would recommend removing this override of the CheckboxControl help text margin.

(No strong opinion about what kind of consistency improvements you might want to make at the consumer level in the "Status & visibility" panel itself.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mirka I agree thanks 🙇 . I have removed that style from the base component and added it specifically for the "status and visibility" panel I think it makes more sense there as radio and checkbox are similar so the spacing between the help text in both of these should look consistent in that panel. Is it good to go or we need to make any other changes here?

Copy link
Member

@mirka mirka left a comment

Choose a reason for hiding this comment

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

Looks good, thank you for all the follow-ups! Please add a changelog for the style changes in CheckboxControl and RadioControl, and we're good to merge 👍

@vipul0425
Copy link
Contributor Author

@mirka Updated the changelog and rebased the branch 🙇 .

@mirka mirka enabled auto-merge (squash) June 7, 2024 15:07
@mirka mirka merged commit bbdf1a7 into WordPress:trunk Jun 7, 2024
61 checks passed
@github-actions github-actions bot added this to the Gutenberg 18.6 milestone Jun 7, 2024
@ellatrix
Copy link
Member

Is the a bug for or enhancement. Title and label don't match. Should this fix be included in 6.6 Beta?

@vipul0425
Copy link
Contributor Author

Yes @ellatrix It was for enhancement in the checkbox and radio controls. It can be included in 6.6 Beta.

patil-vipul pushed a commit to patil-vipul/gutenberg that referenced this pull request Jun 17, 2024
* Fix: Update styles for checkbox and radio controls.

* chore: Update margin-right for checkbox and radio controls in style.scss

* fix: the sapcing b/w radio controls to 8px.

* refactor: Revised the spacing b/w radio-controls to '12px'.

* Fix checkbox help margin

* Revert the line break change in post-comments.

* fix: The changes as per feedback.

* Doc: Updates the changelog.md.

* Fixup changelog

---------

Co-authored-by: vipul0425 <vipulgupta003@git.wordpress.org>
Co-authored-by: mirka <0mirka00@git.wordpress.org>
Co-authored-by: jameskoster <jameskoster@git.wordpress.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Package] Components /packages/components [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants