-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
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] Proper placement for anchor other than left #6516
Conversation
- Assume a default of 'left' - Check right to left, swap 'right' and 'left' - Set initial placement and height based on the anchor property - Consideration of right-to-left when anchor is set to right - For top and bottom, height is set to auto, the max height is left for the consumer of this component since Material Design does not prevent a full-height bottom sheet. No word on top sheets. - Added top, bottom, right drawers to component demo.
Associated this PR with Issue #6517 |
- left anchor should switch to right - right anchor should switch to left
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.
Wow, the demos are pretty cool. Thanks!
|
||
render() { | ||
const classes = this.context.styleManager.render(styleSheet); | ||
return ( | ||
<div> | ||
<Button onClick={this.handleOpen}>Open Drawer</Button> | ||
<Button onClick={this.handleTopOpen}>Open Top Drawer</Button> |
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 would have the left drawer first in the list as people will most likely try that one first.
|
||
render() { | ||
const classes = this.context.styleManager.render(styleSheet); | ||
return ( | ||
<div> | ||
<Button onClick={this.handleOpen}>Open Drawer</Button> | ||
<Button onClick={this.handleTopOpen}>Open Top Drawer</Button> | ||
<Button onClick={this.handleLeftOpen}>Open Left Drawer</Button> |
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 think that we can remove Drawer
from the button wording, that's obvious and making it harder to read.
<ListItemText primary="Spam" /> | ||
</ListItem> | ||
</List> | ||
<div className={classes.remainder} /> |
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 not sure we need a remainder
.
onRequestClose={this.handleTopClose} | ||
onClick={this.handleTopClose} | ||
> | ||
<List className={classes.listFull} padding={false}> |
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 property changed, it's disablePadding
</ListItem> | ||
</List> | ||
<Divider /> | ||
<List className={classes.listFull} padding={false}> |
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 think that we should keep the children of the list DRY. Please use an intermediary constant.
src/Drawer/Drawer.js
Outdated
@@ -126,7 +151,18 @@ export default class Drawer extends Component { | |||
const { theme: { dir }, render } = this.context.styleManager; | |||
const classes = render(styleSheet); | |||
const rtl = dir === 'rtl'; | |||
const anchor = anchorProp || (rtl ? 'right' : 'left'); | |||
const anchorClasses = { |
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.
We could have been using smart code, but I guess a mapping is simpler here 👍
- reordered buttons in drawer demo - removed drawer from button label in demo - eliminated remainder in demo - made use of constant for reused list - eliminated mapping, renamed classes to match acceptable values for anchor prop, apply appropriate class by using value of anchor as a key for the classes object
Thanks for reviewing, @oliviertassinari - I've pushed the requested changes. |
@@ -140,7 +169,7 @@ export default class Drawer extends Component { | |||
<Paper | |||
elevation={docked ? 0 : elevation} | |||
square | |||
className={classNames(classes.paper, paperClassName)} | |||
className={classNames(classes.paper, classes[anchor], paperClassName)} |
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.
Now, I would call that a smart code, I'm not sure it's better as harder to debug, but if that what you prefer, I'm in 👍 .
- should have full width list for top and bottom
@kgregory Thanks! |
The anchor property is not fully implemented. It appropriately sets the direction that the drawer should slide, but the drawer is always placed at the left of the viewport. This is because the initial position and height is not changed when anchor is right, top, or bottom.
Resolution: