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

React Native collapsible OnDeviceUI navigation #1544

Merged
merged 8 commits into from
Jul 30, 2017
Merged

React Native collapsible OnDeviceUI navigation #1544

merged 8 commits into from
Jul 30, 2017

Conversation

rmevans9
Copy link
Contributor

Issue: N/A

What I did

Modified the styles for the OnDeviceMenu to make the menu something you can show/hide instead of always taking up the space.

NOTES

  • Right now it is not "fancy" meaning no animation or anything. I plan on adding that likely in a commit within the next 24 hours.
  • Instead of un-mounting the menu like I originally planned I had to simply move it off screen as the mount/unmount causes issues with resetting which story you are looking at. This could probably be solved so you could unmount however since I plan on animating it I will need it to sit off screen anyway... so lets call it "planning for the future"
  • I found that a method call in the StoryListView was incorrect when cleaning up listeners. I fixed that.
  • Right now the trigger for opening/closing the menu is just text. We probably will want something better.

How to test

Run storybook with OnDeviceUI and see it.

@codecov
Copy link

codecov bot commented Jul 30, 2017

Codecov Report

Merging #1544 into master will decrease coverage by 0.08%.
The diff coverage is 0%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1544      +/-   ##
==========================================
- Coverage   20.53%   20.45%   -0.09%     
==========================================
  Files         241      241              
  Lines        5220     5242      +22     
  Branches      650      652       +2     
==========================================
  Hits         1072     1072              
+ Misses       3666     3662       -4     
- Partials      482      508      +26
Impacted Files Coverage Δ
...tive/src/preview/components/StoryListView/style.js 0% <ø> (ø) ⬆️
...tive/src/preview/components/StoryListView/index.js 0% <0%> (ø) ⬆️
...-native/src/preview/components/OnDeviceUI/style.js 0% <0%> (ø) ⬆️
...-native/src/preview/components/OnDeviceUI/index.js 0% <0%> (ø) ⬆️
lib/ui/src/libs/key_events.js 23.25% <0%> (ø) ⬆️
app/react/src/client/preview/error_display.js 0% <0%> (ø) ⬆️
lib/ui/src/modules/ui/containers/left_panel.js 25% <0%> (ø) ⬆️
addons/knobs/src/components/types/Color.js 8% <0%> (ø) ⬆️
lib/ui/src/modules/ui/libs/filters.js 53.33% <0%> (ø) ⬆️
addons/knobs/src/KnobManager.js 35.41% <0%> (ø) ⬆️
... and 14 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 73fd1dc...bcb4db8. Read the comment docs.

@rmevans9
Copy link
Contributor Author

I have added an animation to the open/close of the menu to make it feel better. Now its just the styles of the menu and what the open/close button should be.

screen shot 2017-07-30 at 6 28 42 am

screen shot 2017-07-30 at 6 29 07 am

I am thinking a "hamburger" menu icon but wanted to see if there were any other opinions?

@rmevans9
Copy link
Contributor Author

I am considering adding the ability to tap outside of the menu to close it as well.

@rmevans9
Copy link
Contributor Author

screen shot 2017-07-30 at 7 07 01 am

Added an overlay over the preview window that fades in with the menu opening. It is touchable so that you can tap outside of the menu to close it like you would expect to be able to do in a drawer menu

@rmevans9
Copy link
Contributor Author

rmevans9 commented Jul 30, 2017

screen shot 2017-07-30 at 7 18 08 am

screen shot 2017-07-30 at 7 31 27 am

I am not completely sold on the location of the buttons yet.

Images came from:
https://www.iconfinder.com/icons/134226/arrow_back_left_icon#size=128
https://www.iconfinder.com/icons/134216/hamburger_lines_menu_icon

@shilman
Copy link
Member

shilman commented Jul 30, 2017

From our slack chat:

untitled

Copy link
Member

@atticoos atticoos left a comment

Choose a reason for hiding this comment

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

I'm so excited for this one 😃 this is going to make the experience on devices so nice. I have some very minor code style feedback as I was skimming through, and otherwise just one clarifying question. Great job!

const { stories, events, url } = props;
export default class OnDeviceUI extends Component {
constructor(props, ...args) {
super(props, ...args);
Copy link
Member

Choose a reason for hiding this comment

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

Super nitty feedback - but since props isn't used, we could just spread all the arguments

constructor(...props) {
  super(...props)
  ...
}

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. I had props in there before and just forgot to clean this up. I'll get it updated.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Resolved.

{isMenuOpen &&
<TouchableWithoutFeedback onPress={this.handleToggleMenu}>
<Animated.View style={overlayStyles} />
</TouchableWithoutFeedback>}
Copy link
Member

Choose a reason for hiding this comment

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

dropping the trailing } onto another line would make this more legible -- thought Animated.View was part of this condition block 😃

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Prettier is not a fan of that. I typically would have it on the next line but prettier complained at me. I'll look at options because I agree that this isn't as readable as it could be.

Copy link
Member

Choose a reason for hiding this comment

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

Oh, if prettier did this, then nothing to see here!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Resolved by way of removing this code all together 😄

}

render() {
const { stories, events, url } = this.props;
Copy link
Member

@atticoos atticoos Jul 30, 2017

Choose a reason for hiding this comment

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

Do we need to subscribe for stories being added? Or will added stories become updated in props.stories and lead to a re-render?

Update: Deferred to #1547

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Honestly not sure. The subscription setup was actually setup by someone else. This PR is just changing the UI to be more giving on space available to the preview section. I can work on cleaning this up in a follow up PR

Copy link
Member

Choose a reason for hiding this comment

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

The original component received added stories through event emissions -- I think we may want to subscribe to those here too, or otherwise the sidebar may not update as stories become added. cc @shilman or @ndelangen -- do Preview components receive additional stories on props.stories over time? Or are subscriptions needed

Copy link
Member

Choose a reason for hiding this comment

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

@ajwhite right now in examples/react-native-vanilla it appears the stories don't update in the browser OR in the OnDeviceUI when I modify the story code. I'm not sure if this is a bug in my setup or whether something is broken in @storybook/react-native or just the example...

Copy link
Member

Choose a reason for hiding this comment

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

Okay - sounds like something we can come back to and keep the scope of this PR narrow 👍

Opened #1547, can probably tackle once I'm back in Boston on Tuesday.

color: 'rgba(0, 0, 0, 0.5)',
},
overlayContainer: {
position: 'absolute',
Copy link
Member

Choose a reason for hiding this comment

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

For consistency, you can use StyleSheet.absoluteFillObject like used below in the preview style 😃

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. I meant to switch them all to be the same but forgot. Will get this updated

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Resolved.

@shilman
Copy link
Member

shilman commented Jul 30, 2017

@rmevans9 This is looking great! I have some issues with the current design though. If you look at the old behavior, it's useful to be able to click through different UI states quickly in the old UI:

reactnative-ondevice-900

This ability is greatly diminished in the new version, because the story contents are both obscured by the menu and also dimmed.

My suggestion is that the menu's slideout behavior pushes the story contents to the side rather than obscures it. This enables the old behavior, which is great for landscape phones and all tablets (I think, I haven't actually tried it on a tablet.)

@rmevans9
Copy link
Contributor Author

No problem, I can get that fixed up here in a couple of hours. If we shift the content part of the right side of the preview window will go off screen, would that be an issue you think?

@rmevans9
Copy link
Contributor Author

On the other hand I could adjust the size of the preview window, some people components may not handle that well though.

@shilman
Copy link
Member

shilman commented Jul 30, 2017

@rmevans9 Is it possible to shrink the preview window instead? The current behavior is one in which the preview screen is narrower by the width of the menu, which means that if the component is centered, it works pretty well on wider screens. I'm not sure what is possible on RN.

@rmevans9
Copy link
Contributor Author

Yeah, it might just be that some users components act oddly when shrinking/expanding but we can cross that bridge when it happens. I'll get these changes in soon

@rmevans9
Copy link
Contributor Author

@shilman per slack convo - updated design is in based upon your request. Let me know if there is anything else you see that you want changed!

Copy link
Member

@shilman shilman left a comment

Choose a reason for hiding this comment

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

LGTM! 👍

And in this case G = GREAT

@shilman
Copy link
Member

shilman commented Jul 30, 2017

@rmevans9 i'm gonna merge this into release/3.2 so we can get an alpha out without compromising the release

@shilman shilman changed the base branch from master to release/3.2 July 30, 2017 23:28
@shilman shilman merged commit 2bf095c into storybookjs:release/3.2 Jul 30, 2017
@shilman shilman changed the title [WIP] OnDeviceUI menu tweaks React Native collapsible OnDeviceUI navigation Jul 31, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants