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

BoxControl: update design #56665

Merged
merged 37 commits into from
Jan 12, 2024
Merged

BoxControl: update design #56665

merged 37 commits into from
Jan 12, 2024

Conversation

brookewp
Copy link
Contributor

@brookewp brookewp commented Nov 30, 2023

What?

While working on adding updated sizing in #56185, we noticed that the larger sizing affects the visibility of the input for BoxControl when the width is constrained. And while there is a max-width on this component, the main concern is this happens regardless due to the width of the inspector:

Screenshot 2023-11-15 at 6 32 19 PM

Why?

BoxControl is only used in the dimension panel for backward compatibility. So it was decided to change the design of the component to match custom padding when presets are provided (excluding the settings icon): #56185 (comment)

Screenshot 2023-11-20 at 10 29 10

How?

Since this component isn't used in many places, the main goal was to match the design specs so we could move forward with updating to the 40px sizing. So there could be potential follow-ups to reduce some redundancy currently present, but I don't believe it is a priority due to its current usage. Therefore, the main changes are:

  • changing flex-direction to column
  • adding a RangeControl component to each side
  • adjusting where/when the icons are shown
  • grouping the buttons together (reset and linked)

Screenshots

AllInputControl

Before After
Screenshot 2023-11-30 at 5 13 29 PM Screenshot 2023-11-30 at 5 30 42 PM

InputControls

Before After
Screenshot 2023-11-30 at 5 13 36 PM Screenshot 2023-12-01 at 6 31 05 PM

AxialInputControls

Will look similar but with two inputs when unlinked and the icons highlighting two sides (vertical and horizontal)

Screenshot 2023-12-01 at 6 31 13 PM

Testing Instructions

Ensure tests pass and component behaves the same as before.

For new changes:

Ensure that RangeControl updates to the correct value when typing in the input.

@brookewp brookewp added [Type] Enhancement A suggestion for improvement. [Package] Components /packages/components labels Nov 30, 2023
@brookewp brookewp self-assigned this Nov 30, 2023
@brookewp
Copy link
Contributor Author

brookewp commented Dec 1, 2023

There are a couple things that I'd like to run by design (cc @jameskoster) before finishing up this PR and marking it ready for review.

Buttons

The placement of the linked button doesn't work as well with the vertical inputs, especially if allowReset is false. So, I grouped both buttons in the same area as the icon in SpacingInputControl:

Screenshot 2023-11-30 at 5 31 44 PM

And this is how it looks if allowReset is false:

Before After
Screenshot 2023-11-29 at 6 14 09 PM Screenshot 2023-11-30 at 5 50 57 PM

When the Reset button is present, should it also have the 40px height when the inputs do?

Input Size

The input is a bit bigger than the one in SpacingInputControl. This is due to the missing settings icon. In lieu of that, do we want to:

Keep it as it is now, with the UnitControl and RangeControl as equal sizes?

Screenshot 2023-11-30 at 5 30 42 PM

Or add a max size of 90px to the UnitControl to match the sizing of SpacingInputControl? Or maybe a compact size option for this?

Screenshot 2023-11-30 at 6 03 00 PM

And if there's any other feedback, please share! One thing to note is the Axial Controls haven't been updated with the changes yet so those will look strange right now.

@jameskoster
Copy link
Contributor

The placement of the link button seems sensible 👍

When the Reset button is present, should it also have the 40px height when the inputs do?

I think the current size is okay, and consistent with other reset buttons.

For the input size, a max-width is probably a good idea as it's unlikely to be populated with more than 3 characters. Using the compact variant could make sense too (while retaining the 40px row height), to avoid the inputs butting up against each other.

Screenshot 2023-12-01 at 09 56 29

What do you think?

@brookewp
Copy link
Contributor Author

brookewp commented Dec 1, 2023

What do you think?

That looks great, thank you for the info and example! I initially didn't add spacing between the inputs to match the current SpacingInputControl, but I prefer what you've shared instead.

Copy link
Contributor

@ciampo ciampo left a comment

Choose a reason for hiding this comment

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

Overall things are looking good, although I spotted two aspects that may need improving:

  1. When the slider has its maximum value, both the thumb and the tooltip (shown when the thumb is focused) render partially outside of the component's boundary. This may be problematic in the sidebar, as they would either cause a horizontal scrollbar to appear, or they could be potentially cut off.

Screenshot 2023-12-08 at 19 53 53

  1. The sliders have a fixed max value of 100, which, depending on the selected unit, may be too little or too much. We should take inspiration from SpacingSizesControl and adapt max and step values per unit (see code)

@brookewp
Copy link
Contributor Author

brookewp commented Dec 8, 2023

When the slider has its maximum value, both the thumb and the tooltip (shown when the thumb is focused) render partially outside of the component's boundary. This may be problematic in the sidebar, as they would either cause a horizontal scrollbar to appear, or they could be potentially cut off.

Good find! SpacingSizesControl has a settings icon to the right, so that problem wasn't there. But I'll look at other use cases of RangeControl to be consistent with those.

The sliders have a fixed max value of 100, which, depending on the selected unit, may be too little or too much. We should take inspiration from SpacingSizesControl and adapt max and step values per unit (see code)

Thank you for sharing that example! I was initially concerned about using RangeControl because of the max prop limitation since BoxControl doesn't have a max limit. But if we're happy to use the unit/max/step pairing from SpacingSizesControl then that works for me!

@brookewp brookewp requested review from ciampo and a team December 8, 2023 23:30
@ciampo
Copy link
Contributor

ciampo commented Dec 12, 2023

I'll look at other use cases of RangeControl to be consistent with those.

I see that you added an 8px right margin, which mitigates the issue but doesn't necessarily solve it entirely

Screenshot 2023-12-12 at 19 42 51

Adding more right margin would feel awkward, though. I wonder if the component would still look alright in the editor, since the sidebar should have some padding?

@brookewp
Copy link
Contributor Author

I wonder if the component would still look alright in the editor, since the sidebar should have some padding?

As you suspected, the thumb isn't cut off because of the sidebar's padding. I think the small right margin helps the slider track edge align a bit more with the ellipsis menu:

With Margin Without
Screenshot 2023-12-12 at 1 42 55 PM Screenshot 2023-12-12 at 1 43 38 PM

Comment on lines 144 to 141
aria-controls={ inputId }
aria-labelledby={ inputId }
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I based this on a similar example I saw from @andrewhayward:

 <label id="lbl-2" for="ipt-2">Label 2</label>
  <input id="ipt-2">
  <input id="ipt-3" aria-labelledby="lbl-2" aria-controls="ipt-2">

BoxControl has very different markup, so it isn't implemented the same. In this instance, it may be completely wrong, so I would appreciate a more expert eye on this. However, this did get rid of the redundant label on the slider, while avoiding a violation for having no label.

Some additional context:

When unlinking the sides, the unit control labels are labelled by aria-labels. So I added aria-controls and aria-labelledby with the intention to connect it to those inputs.

In AllInputControl when it's a single/mixed set of values, there isn't an explicit label, but it inherits one from the BaseControl.VisualLabel:

<Grid
id={ id }
columns={ 3 }
role="group"
aria-labelledby={ headingId }
>
<BaseControl.VisualLabel id={ headingId }>
{ label }
</BaseControl.VisualLabel>

@ciampo ciampo added this to In progress (owned) ⏳ in WordPress Components via automation Dec 13, 2023
@brookewp brookewp requested a review from ciampo December 14, 2023 02:49
@brookewp brookewp requested a review from mirka January 4, 2024 23:48
Comment on lines +36 to +39
screen.getByRole( 'group', { name: 'Box Control' } )
).toBeVisible();
expect(
screen.getByRole( 'textbox', { name: 'All sides' } )
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The labels have been updated to be more clear, as discussed: #56665 (comment)

Context of the change:

All of the changes in 25cf3f6 will just be naming updates, except for the highlighted portion above. The change here was adding an additional assertion to still check for the input, but with the new name. Before, the label for the component (group role) was also the label of the first input, but only when the sides were linked. Therefore the assertion would pass if the query was screen.getByRole( 'group', { name: 'Box Control' } or screen.getByRole( 'textbox', { name: 'Box Control' }. Which is why the query could be updated to group from textbox with no additional changes needed. The original labelling could be confusing when using a screenreader, with just the one input having a different labelling scheme and it being so generic.

Tl;dr, what has been changed:

So instead, now, the label implemented by the consumer for the purpose of the component will only be applied to the group. And each input is labelled, so the linked input will now be labelled as 'All sides' or 'Mixed sides'. And unlinked will be 'Top side', 'Left side', 'Left and Right sides', etc.

@brookewp brookewp requested a review from mirka January 10, 2024 19:21
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.

Great work wrangling all the feedback! Looks good to go once the tests are updated 👍

@brookewp brookewp merged commit 9dcd4cc into trunk Jan 12, 2024
56 checks passed
WordPress Components automation moved this from In progress (owned) ⏳ to Done 🎉 Jan 12, 2024
@brookewp brookewp deleted the update/boxcontrol-design branch January 12, 2024 03:04
@github-actions github-actions bot added this to the Gutenberg 17.6 milestone Jan 12, 2024
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
Development

Successfully merging this pull request may close these issues.

None yet

5 participants