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

[RNMobile] RangeCell styling refactor #18157

Merged
merged 41 commits into from
Nov 15, 2019
Merged

Conversation

lukewalczak
Copy link
Member

@lukewalczak lukewalczak commented Oct 29, 2019

Description

NOTE: That PR is based on rnmobile/spacer
Fixes: wordpress-mobile/gutenberg-mobile#1448
Ref to gb-mobile: wordpress-mobile/gutenberg-mobile#1511
Change RangeCell mobile component styling.

How has this been tested?

  1. Open ios or android app
  2. Add Spacer component
  3. Press settings button
  4. Check RangeCell styling

Screenshots

ios dark mode unfocused ios light mode unfocused
Screenshot 2019-10-29 at 10 39 29 Screenshot 2019-10-29 at 10 41 09
ios dark mode focused ios light mode focused
Screenshot 2019-10-29 at 11 12 03 Screenshot 2019-10-29 at 10 41 14
android focused android unfocused
Screenshot 2019-10-29 at 10 44 07 Screenshot 2019-10-29 at 10 44 02
  • Reset Button functionality

Types of changes

  • add reset button
  • move slider to new line
  • change input styling

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • My code has proper inline documentation.
  • I've included developer documentation if appropriate.

@lukewalczak lukewalczak added Mobile App - i.e. Android or iOS Native mobile impl of the block editor. (Note: used in scripts, ping mobile folks to change) [Block] Spacer Affects the Spacer Block labels Oct 29, 2019
@lukewalczak
Copy link
Member Author

@iamthomasbishop please look at it 🙏

@lukewalczak lukewalczak added the Needs Design Feedback Needs general design feedback. label Oct 29, 2019
@lukewalczak
Copy link
Member Author

Updated description with a link to gb-mobile PR and resolved conflicts.

@lukewalczak lukewalczak removed the [Status] In Progress Tracking issues with work in progress label Nov 5, 2019
@jbinda
Copy link
Contributor

jbinda commented Nov 6, 2019

I have also resolve conflicts after merge RangeControl markup

Copy link
Contributor

@etoledom etoledom left a comment

Choose a reason for hiding this comment

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

Thank you for these improvements @lukewalczak - they look great! 🎉

Added a couple of questions (rather than requests) on the code comments.

And I noticed a few small detail testing with bigger text sizes:

  • If the system font sizes are set to a bigger size (quite common size), the fields start cropping the last digit for numbers bigger than 1000. This can be super confusing.
  • If the text size is set to the accessibility sizes (the super big ones), the layout start to break. This case is a bit more extreme and we don't really have it well covered in the library in general, so maybe it's not that urgent. But we would want in this case the reset button to be vertically aligned.

range

packages/components/src/mobile/bottom-sheet/cell.native.js Outdated Show resolved Hide resolved
accessibilityRole={ 'none' }
editable={ false }
accessible={ accessible }
onPress={ this.onCellPress }
accessibilityLabel={ accessibilityLabel }
allowReset={ this.handleReset }
Copy link
Contributor

Choose a reason for hiding this comment

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

It's interesting that the root Cell component provides Reset option, but the reset functionality has to be handled by the parent component. It feels to me more like a generic button that could be anything. Maybe we can add it as an accessory view on this component, similar how we added the Switch?

Just by curiosity, I added allowReset to other controls, it shows the Reset button but it looks a bit off (apart than it does nothing). It doesn't feel to me that it deserves to be on the root Cell component, unless we plan to add reset to more controls? (In which case this might be a good-enough first step). cc @iamthomasbishop

IMG_3459

Choose a reason for hiding this comment

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

It doesn't feel to me that it deserves to be on the root Cell component, unless we plan to add reset to more controls? (In which case this might be a good-enough first step)

That's correct, I don't think there are any other planned components at the moment that will need an explicit reset button like this.

Choose a reason for hiding this comment

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

One more note: if we do end up adding reset to other cells/components, we'll want to display them in the same two-row way which provides more space for the reset button.

Copy link
Contributor

@jbinda jbinda Nov 6, 2019

Choose a reason for hiding this comment

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

Currently we don't have many settings in block but maybe it's not bad idea to allow reset single field (in case we will have much more settings). Correct me if I'm wrong but it seems now it's possible to manually delete/change the value or clear all settings.

Copy link
Member Author

@lukewalczak lukewalczak Nov 7, 2019

Choose a reason for hiding this comment

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

  • Reset button is placed within a Cell component, because we want to locate it next to the label (Height in pixels) which is defined there actually, otherwise it has to be positioned absolutely.

@jbinda
Copy link
Contributor

jbinda commented Nov 6, 2019

@etoledom thanks for remarks ! We try to discuss big font size issue with Luke tomorrow

@lukewalczak
Copy link
Member Author

lukewalczak commented Nov 7, 2019

I did some accessibility tweaks (@etoledom @iamthomasbishop please look at it):

  • made some space for Reset button, but then label is truncated
  • TextInput width is multiplied by PixelRatio.getFontScale() therefore we can display 4 digits
  • by default and when PixelRatio.getFontScale() is lower than 1 TextInput width is 40

default medium the largest
def medium large

pay no attention to the DONE button, something was wrong with a simulator

Comment on lines +44 to 61
componentDidMount() {
AppState.addEventListener( 'change', this.handleChangePixelRatio );
}

componentWillUnmount() {
this.handleToggleFocus();
AppState.removeEventListener( 'change', this.handleChangePixelRatio );
}

getFontScale() {
return PixelRatio.getFontScale() < 1 ? 1 : PixelRatio.getFontScale();
}

handleChangePixelRatio( nextAppState ) {
if ( nextAppState === 'active' ) {
this.setState( { fontScale: this.getFontScale() } );
}
}
Copy link
Member Author

Choose a reason for hiding this comment

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

Honestly, I think that it's worth to save that info in redux store, because it can be useful in the future to control other components 🤔

Copy link
Contributor

Choose a reason for hiding this comment

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

It does sound like it would be helpful! But maybe it's too much for this PR.

Copy link
Contributor

@etoledom etoledom left a comment

Choose a reason for hiding this comment

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

It looks so much better on bigger font sizes! Thanks for the update 🙏

made some space for Reset button, but then label is truncated

That's why is better to modify the layout to vertical when the text sizes are set to accessibility sizes. This is simple to do on iOS but not sure on RN. Anyway, I think it's good as it is for now 👍

TextInput width is multiplied by PixelRatio.getFontScale() therefore we can display 4 digits

Probably, having more than 4 digits is too much of an edge case for this context in particular. I wonder if there are other usages of the Range Control where the numbers could grow a lot bigger.

I think we can revisit if this case becomes a real problem.

From #18157 (comment)

Reset button is placed within a Cell component, because we want to locate it next to the label (Height in pixels) which is defined there actually, otherwise it has to be positioned absolutely.

Makes sense 👍
I'm still not sure about having a specific Reset button that does nothing, and the reset logic has to be implemented on every instance of it. In this case I'd suggest to add it as a generic button (or "box" holder for any component).

But since it's the only component that uses it so far, it might be OK go forward with it and modify it if we need another control with Reset later on. I'm happy with what @pinarol decides.

@pinarol
Copy link
Contributor

pinarol commented Nov 8, 2019

otherwise it has to be positioned absolutely

I'm still not sure about having a specific Reset button that does nothing, and the reset logic has to be implemented on every instance of it. In this case I'd suggest to add it as a generic button (or "box" holder for any component).

I agree both. I think we can make this better with a simple tweak. Let's not name it as Reset in BottomSheetCell if it doesn't reset anything inside that component. How about just naming it as "customAction" and injecting the title and event handler from outside? Something like this:

<BottomSheetCell
...
customAction={title:_('Reset'), onAction:{this.onReset}}
/>

ps: Feel free to change namings I don't feel strong about them :)

"box" holder for any component seems too upfront design to me at this point and without knowing the real use cases it can fail to meet future needs.

<View style={ platformStyles.labelIconSeparator } />
</View>
) }
<Text numberOfLines={ 1 } style={ [ defaultLabelStyle, labelStyle ] }>
Copy link
Member Author

@lukewalczak lukewalczak Nov 8, 2019

Choose a reason for hiding this comment

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

@etoledom If we remove numberOfLines={ 1 } we can have a not truncated label and it will look like:

wdyt?

Copy link
Member Author

Choose a reason for hiding this comment

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

I've also checked how it will affect other settings:

before after
Screenshot 2019-11-08 at 11 36 33 Screenshot 2019-11-08 at 11 36 28

Copy link
Contributor

Choose a reason for hiding this comment

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

Looks better than cropping!
Let's go with it if it does't affect other instances of cells and controls.

Copy link
Contributor

Choose a reason for hiding this comment

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

I've also checked how it will affect other settings

Again, better than cropping. Looks good to me :)

@lukewalczak
Copy link
Member Author

How about just naming it as "customAction" and injecting the title and event handler from outside?

Works for me! Going to adjust it :)

@etoledom
Copy link
Contributor

etoledom commented Nov 8, 2019

How about just naming it as "customAction" and injecting the title and event handler from outside?

Sounds good! That's what I meant by a add it as a generic button 👍

@lukewalczak
Copy link
Member Author

@etoledom @pinarol I've refactored it according to your suggestion and added:

customActionButton={ { title: resetButtonText, handler: this.handleReset } }

@pinarol
Copy link
Contributor

pinarol commented Nov 8, 2019

Works for me! Also I did a quick testing and it is working pretty smoothly, i am very happy that we got rid of the jumpiness.

Copy link
Contributor

@etoledom etoledom left a comment

Choose a reason for hiding this comment

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

Looks and work great 🎉
Tested on iOS and Android.

Nice job @lukewalczak !

@lukewalczak lukewalczak merged commit 2e42f8c into master Nov 15, 2019
@lukewalczak lukewalczak deleted the rnmobile/rangecell-styling branch November 15, 2019 17:12
@youknowriad youknowriad added this to the Gutenberg 7.0 milestone Nov 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Spacer Affects the Spacer Block Mobile App - i.e. Android or iOS Native mobile impl of the block editor. (Note: used in scripts, ping mobile folks to change)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BottomSheet - change style of RangeCell component
6 participants