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

[Drawer] Support all types of navigation drawers in the Material Design Guidelines #6878

Closed
wants to merge 32 commits into from

Conversation

Zuurkern
Copy link

@Zuurkern Zuurkern commented May 16, 2017

  • has tests
  • has docs demos
  • is linted
  • Commit and PR titles begin with [ComponentName], and are in imperative form: "[Component] Fix leaky abstraction".
  • Description explains the issue / use-case resolved, and auto-closes the related issue(s) (http://tr.im/vFqem).

Description

The Material Design Guidelines specify different navigation drawer types/behaviors under Patterns. This PR aims to support all of those types, true to the spec, while retaining or hopefully expanding the flexibility of the Drawer component. It also adds demos to show how you can create all of these behaviors in your app, as some of these patterns require the Drawer, AppBar and a content element to work together in harmony.

Should close #4773 and possibly #4752 and #6451? (the latter two are for master though I think)

I apologize in advance for potentially bad JS code, I have only been coding in React (or JS for that matter) for a couple of months. But we have to start somewhere, right?

I also haven't written tests as I haven't figured out the testing tools yet :/ Sorry about that.

About changes to [Slide]

For the persistent navigation drawer demo to work, I had to modify Slide and give it a prop to transition its child element from outside its own position in the DOM instead of from outside the viewport. Without this, the transitions on the AppBar and content wouldn't sync up nicely with the Drawer's. In a real scenario where your app fills the entire viewport, you won't need this. Still, I think this opens up possibilities to get creative with the Drawer component (which passes this optional prop on to Slide). Also, I think it's a nice addition to Slide. I'm having a hard time coming up with a succinct and descriptive prop name for it though. Would love to discuss all of this further.

Hardcoding of the width transition for the mini variant

Currently, the width transition for the mini variant is hardcoded into the stylesheet. I was thinking maybe we could add support for width to the Collapse component and use that so it's more configurable. What do you think about this?

Zuurkern added 30 commits May 8, 2017 14:25
…e layout (overflow is on body instead of AppContent)
…next"

This reverts commit 41d08cf, reversing
changes made to a1c248e.
@muibot muibot added the PR: out-of-date The pull request has merge conflicts and can't be merged label May 18, 2017
* If `false`, let the child element slide in from outside the viewport.
* Set to `true` to let the child element slide in from outside its own
* bounding box and position.
*/
Copy link
Member

Choose a reason for hiding this comment

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

We are using the pattern: "If true the child element slides in from outside its own bounding box and position"

Not sure how best to address the default case - perhaps follow the above with: "; by default, the child element slide in from outside the viewport."?

Copy link
Author

Choose a reason for hiding this comment

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

That makes sense! Good call on scrapping the "let"s too.

@mbrookes
Copy link
Member

@Zuurkern Thanks for your hard work on this - it looks great! Please could you rebase - there have been some conflicting changes since.

@oliviertassinari any thoughts on the name for the useChildBounds prop in Slide, and @Zuurkern's question about adding support for width to Collapse?

@Zuurkern
Copy link
Author

Zuurkern commented May 31, 2017

@mbrookes thanks for picking this back up and sorry for not following up on this sooner, I'm working on another, older project right now (and miss material-ui sooo bad) and I'm short on time.

I did some battle testing last week, trying to get creative with the Drawer to see how well it holds up flexibility wise. I made some small adjustments and took notes for things I would like to improve and/or discuss. I will try to make time this weekend to write those out and post here.

In its current state though, getting a basic layout down as described in the guidelines (drawer, app bar, content synergy) is really easy. You can basically just copy paste the demos. I tested the demos in latest Chrome, Firefox, Safari, Edge and IE11 (I think) as well. It just works.

I'll rebase too when I dive back into the code.

@mbrookes
Copy link
Member

mbrookes commented Jun 1, 2017

Fantastic, thanks for sticking with it - it'll be here when you get time. 👍

@bai
Copy link

bai commented Jun 22, 2017

Thanks for implementing this one! I'd be happy to fork & rebase — is that something I could help with to get this shipped?

@oliviertassinari oliviertassinari changed the base branch from next to v1-alpha June 27, 2017 20:37
@Zuurkern
Copy link
Author

Zuurkern commented Jun 27, 2017

Hey guys, sorry about the radio silence. I was going to post my findings like a month ago but some things have changed in the meantime.

There have been some changes to the API in general and other components that Drawer is composed of:

  • classes prop, which got rid of paperClassName in @oliviertassinari 's latest iteration
  • Slide now has an offset prop - although not implemented yet, that's a great idea and gets rid of my awkwardly named useChildBounds and slideFromOutsideSelf props

paperClassName prop is gone now and I've tried to get rid of it as well because the mini variant implementation makes the stylesheet too specific (you have to use !important to do non-MD-spec stuff when trying to override CSS via this prop) - this was one of my gripes with my current implementation.

I still think we should add support for width to Collapse first (for the mini variant) and then revisit Drawer to make it leaner in the render function and be a good example of how to compose more complex components from other components (Paper, Slide, Collapse).

@wtgtybhertgeghgtwtg
Copy link

What about clipped drawers?

@Zuurkern
Copy link
Author

Zuurkern commented Jul 3, 2017

Clipped drawers are just a matter of leaving the AppBar styling as is. It's not really something Drawer controls, except for maybe adding a top padding the same height as the AppBar.

I considered adding seperate demos for clipped drawers but decided not to because I just wanted some proof of concept for the changes I made to the Drawer component.

@jaesung2061
Copy link

@Zuurkern what is the status on the PR?

@oliviertassinari oliviertassinari changed the base branch from v1-alpha to v1-beta July 23, 2017 17:09
@acmitch
Copy link

acmitch commented Jul 24, 2017

@mbrookes @Zuurkern @oliviertassinari When is this expected to be released? Our team is needing a mini-variant navigation bar and this looks extremely promising.

@mbrookes
Copy link
Member

@acmitch I think everyone would welcome it if you or your team were to pick up this PR and continue the good work that @Zuurkern has started.

@cr101
Copy link

cr101 commented Jul 30, 2017

It would be great to have a navigation drawer clipped under the AppBar so it doesn't cover the site brand and burger icon when open on mobile.

@nathanmarks nathanmarks mentioned this pull request Jul 30, 2017
5 tasks
@kgregory
Copy link
Member

kgregory commented Jul 31, 2017

@cr101 I'm not familiar with that material design standard for navigation drawer, can you share a link? I've seen similar behavior documented for permanent drawers.

@wtgtybhertgeghgtwtg
Copy link

Should it matter? Clipping and permanence are independent.

@kgregory
Copy link
Member

@wtgtybhertgeghgtwtg is there a standard defined for that behavior?

@cr101
Copy link

cr101 commented Jul 31, 2017

@kgregory
Copy link
Member

kgregory commented Jul 31, 2017

@cr101 I'm familiar with this document, but unfortunately it doesn't support your request:

It would be great to have a navigation drawer clipped under the AppBar so it doesn't cover the site brand and burger icon when open on mobile.

The only thing that comes close is a permanent navigation drawer:

Types of permanent navigation drawers:
Navigation drawer clipped under the app bar: Apps focused on productivity that require balance across the screen

Or perhaps the mini-variant of the persistent navigation drawer:

Its resting state is as a mini-drawer at the same elevation as the content, clipped by the app bar. When expanded, it appears as the standard persistent navigation drawer.

However, it is not suitable for mobile:

Persistent navigation drawers are acceptable for all sizes larger than mobile.

The standard requires a temporary navigation drawer for mobile:

Temporary navigation drawers can toggle open or closed. Closed by default, the drawer opens temporarily above all other content until a section is selected.
Required for: Mobile

@cr101
Copy link

cr101 commented Jul 31, 2017

@kgregory I'm after a permanent, clipped drawer like the example below:

Types of permanent navigation drawers:
Navigation drawer clipped under the app bar: Apps focused on productivity that require balance across the screen

patterns_navdrawer_behavior_permanent3

@kgregory
Copy link
Member

@cr101 right..

@oliviertassinari
Copy link
Member

I'm going to resume this work as the oldest PR we have open, will move to the other after.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: drawer This is the name of the generic UI component, not the React module! PR: needs revision The pull request can't be merged. More details is available on the code review or fails in the CI PR: out-of-date The pull request has merge conflicts and can't be merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants