-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
React Native collapsible OnDeviceUI navigation #1544
Conversation
Codecov Report
@@ 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
Continue to review full report at Codecov.
|
I am considering adding the ability to tap outside of the menu to close it as well. |
…ouchable to close
I am not completely sold on the location of the buttons yet. Images came from: |
There was a problem hiding this 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); |
There was a problem hiding this comment.
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)
...
}
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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>} |
There was a problem hiding this comment.
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 😃
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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!
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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...
There was a problem hiding this comment.
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', |
There was a problem hiding this comment.
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 😃
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolved.
@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: 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.) |
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? |
On the other hand I could adjust the size of the preview window, some people components may not handle that well though. |
@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. |
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 |
@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! |
There was a problem hiding this 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
@rmevans9 i'm gonna merge this into release/3.2 so we can get an alpha out without compromising the release |
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
How to test
Run storybook with OnDeviceUI and see it.