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

AnglePickerControl: Style to better fit in narrow contexts and improve RTL layout #49046

Merged
merged 8 commits into from
Mar 17, 2023

Conversation

stokesman
Copy link
Contributor

@stokesman stokesman commented Mar 13, 2023

What?

  1. Makes the more room for the number input of the control
  2. For RTL, puts the degree symbol to the right of the number input
  3. A bit of refactoring to simplify styles

Why?

  1. Will close GradientPicker value gets cut off in block editor sidebar Popovers #45781
  2. Will close AnglePickerControl: RTL layout of degree symbol #35710

How?

  1. Reduces the gap between its constituent parts
  2. Conditionally uses the prefix prop for the angle symbol when RTL

Testing Instructions

  1. In either the Post Editor or Global Styles edit/apply a gradient
  2. Verify that three digit numbers are not cut off
  3. Verify that no other visual changes are introduced

Testing Instructions for Keyboard

Nothing has really changed for pure keyboard use. The knob is not tabbable in either trunk or this branch.

  1. In either the Post Editor or Global Styles edit/apply a gradient
  2. Tab into the “Angle” field and use the arrow keys to adjust the value

Screenshots or screencast

Before After
angle-picker-ltr-before angle-picker-ltr-after
RTL Before RTL After
angle-picker-rtl-before angle-picker-rtl-after
Archived from earlier iterations

In Post Editor adjusting a gradient

angle-picker-control-knob-affixed.mp4

Note the easy keyboard adjustment after dragging since the number input is already focused.

In Global Styles

angle-picker-knob-affixed-global-styles-sidebar

Other screenshots to show design alternatives

A before/after of just moving the knob “inside” without other style changes

angle-picker-control-compare

A style experiment I tried along the way

angle-picker-control-try-alt-style.mp4

@stokesman stokesman added Needs Design Feedback Needs general design feedback. [Package] Components /packages/components labels Mar 13, 2023
@jasmussen
Copy link
Contributor

Thanks for the PR!

I'm not sure it's good to change the morphology of the angle picker quite yet. I don't hate the line, but I also don't think it's necessarily clearer that it points in a particular direction. I think there's an opportunity to refine the design, to be clear, but it might be best to keep that separate from the other excellent bugfixes. What do you think?

@stokesman
Copy link
Contributor Author

I don't have a strong opinion on the line versus the dot. Here’s a before/after comparison of just moving the knob inside:


Would that be approvable? I'd still want to reduce the apparent size but it's not necessary.

Also, for a bit of context, the idea to try this came from the recent custom spinner controls:
image

@jasmussen
Copy link
Contributor

A simpler change might be to change the gap value from 16px to 8px.

Before:

Screenshot 2023-03-15 at 08 52 00

After:

Screenshot 2023-03-15 at 08 52 25

Screenshot 2023-03-15 at 08 52 29

What do you think?

@stokesman stokesman force-pushed the try/affix-knob-angle-picker-control branch from de51103 to 7c2c8e3 Compare March 16, 2023 06:25
@stokesman
Copy link
Contributor Author

What do you think?

It's great! Also it's done. I've updated the PR description and screenshots. It's funny how that gap has bugged me for quite some time. I just got a little tunnel vision on that other idea. Thanks for getting your hands dirty there Joen!

Copy link
Contributor

@jasmussen jasmussen 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 to me. Before, cropped text in the angle field:

before

After, uncropped:

after

I'm mainly reviewing this visually, so I'd appreciate a sanity check from a dev (maybe cc @mirka?). But otherwise, looks good, thanks for the PR!

return (
<Root
{ ...restProps }
ref={ ref }
__nextHasNoMarginBottom={ __nextHasNoMarginBottom }
className={ classes }
gap={ 4 }
gap={ 2 }
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice.

import CONFIG from '../../utils/config-values';

import type { AnglePickerControlProps } from '../types';

const CIRCLE_SIZE = 32;
const INNER_CIRCLE_SIZE = 3;
const INNER_CIRCLE_SIZE = 6;
Copy link
Contributor

Choose a reason for hiding this comment

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

What does this one actually do? Mostly for curiosity.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's the size of the dot on the knob. Previously it was used as a radius. As part of simplifying the styles used to draw the dot it was more straightforward to use as a diameter (which also makes it consistent with CIRCLE_SIZE which is a diameter).

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh interesting, thanks for the response! I don't know that we'd ever want to actually change the size of the knob situationally, so I guess it good that it isn't surfaced as a prop :)

@@ -39,31 +40,33 @@ export const CircleRoot = styled.div`
height: ${ CIRCLE_SIZE }px;
overflow: hidden;
width: ${ CIRCLE_SIZE }px;

:active {
cursor: grabbing;
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice.

@mirka mirka self-requested a review March 16, 2023 09:05
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.

Very nice fixes, thank you! Let us know when this is ready for a full code review 🙂 It might be worth splitting this into at least two PRs since it's touching several independent concerns. Would be easier to pin down if there are any regressions.

packages/components/src/angle-picker-control/index.tsx Outdated Show resolved Hide resolved
@stokesman stokesman force-pushed the try/affix-knob-angle-picker-control branch from 7c2c8e3 to 2fd322d Compare March 17, 2023 05:09
@stokesman stokesman changed the title Affix knob in AnglePickerControl Fix visuals of AnglePickerControl Mar 17, 2023
@stokesman
Copy link
Contributor Author

Thanks for testing and reviewing Joen!

I've taken Lena’s advice and dropped any changes here besides the visual stuff. So I'll go ahead and mark this as ready. Oh that and add to the changelog.

@stokesman stokesman marked this pull request as ready for review March 17, 2023 05:28
@github-actions
Copy link

github-actions bot commented Mar 17, 2023

Flaky tests detected in 6835eea.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/4450374242
📝 Reported issues:

@stokesman stokesman force-pushed the try/affix-knob-angle-picker-control branch from 2fd322d to 650b716 Compare March 17, 2023 06:00
@stokesman stokesman changed the title Fix visuals of AnglePickerControl AngleControlPicker: Style to better fit in narrow contexts and improve RTL layout Mar 17, 2023
@stokesman stokesman changed the title AngleControlPicker: Style to better fit in narrow contexts and improve RTL layout AnglePickerControl: Style to better fit in narrow contexts and improve RTL layout Mar 17, 2023
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 great, thanks for the polish! 🚀

marginTop: 'auto',
} }
>
<Spacer marginBottom="1" marginTop="auto">
Copy link
Member

Choose a reason for hiding this comment

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

Interesting. Not for this PR, but for layouts like this I'd probably first try using the NumberControl without a label, and wrap the entire thing in a separate BaseControl. I hope our components support that kind of composability without messing up the HTML semantics.

@@ -9,6 +9,7 @@
- `FontSizePicker`: Allow custom units for custom font size control ([#48468](https://github.com/WordPress/gutenberg/pull/48468)).
- `Navigator`: Disable initial screen animation ([#49062](https://github.com/WordPress/gutenberg/pull/49062)).
- `FormTokenField`: Hide suggestions list on blur event if the input value is invalid ([#48785](https://github.com/WordPress/gutenberg/pull/48785)).
- `AnglePickerControl`: Style to better fit in narrow contexts and improve RTL layout ([#49046](https://github.com/WordPress/gutenberg/pull/49046)).
Copy link
Member

Choose a reason for hiding this comment

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

This needs to be moved up again, there was a release a few days ago. (When will we be free from this merge annoyance? 🥲)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch!

@stokesman stokesman force-pushed the try/affix-knob-angle-picker-control branch from 1f9e1fe to 6835eea Compare March 17, 2023 18:09
@stokesman
Copy link
Contributor Author

6835eea Restores a bit of style whose removal was part of proposed changes to focus handling that were dropped from this PR. Ultimately it’s a non-change, so I'll merge without further review.

Thanks again to Joen and Lena 🙇

@stokesman stokesman merged commit 6434e0b into trunk Mar 17, 2023
@stokesman stokesman deleted the try/affix-knob-angle-picker-control branch March 17, 2023 19:11
@github-actions github-actions bot added this to the Gutenberg 15.5 milestone Mar 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Design Feedback Needs general design feedback. [Package] Components /packages/components
Projects
None yet
3 participants