-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
Responsive drawer #6535
Responsive drawer #6535
Conversation
* Add breakpointWidth * Breaks automatically Fix #1130
Fixing code style in progress.. |
* Strip trailing whitespace * Fix long lines * Use element width instead of window width
* Change 'rxjs/subscription' to 'rxjs/Subscription'
src/lib/sidenav/drawer.ts
Outdated
} | ||
this.close(); | ||
} | ||
if (this._element.nativeElement.offsetWidth > this.breakpointWidth) { |
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.
else
here sounds better.
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.
Didn't notice that, fixing.
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.
- Can you update your original post to mark it as fixing the issue?
- The team will require unit tests before merging
- I looked over the drawer/sidenav PR again, and am now not so sure it's a public facing change... Maybe @mmalerba can comment on the correct usage going forward?
src/lib/sidenav/drawer.ts
Outdated
@@ -325,6 +328,27 @@ export class MdDrawerContainer implements AfterContentInit { | |||
/** Event emitted when the drawer backdrop is clicked. */ | |||
@Output() backdropClick = new EventEmitter<void>(); | |||
|
|||
/** | |||
* Width of the container at which it breaks | |||
* e.g., breakpointWidth="500" |
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.
Maybe just,
/** Breakpoint width (in px) at which the sidenav collapses. */
src/lib/sidenav/drawer.ts
Outdated
* Width of the container at which it breaks | ||
* e.g., breakpointWidth="500" | ||
*/ | ||
@Input() breakpointWidth: number; |
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.
src/lib/sidenav/drawer.ts
Outdated
* Note that this only works when the window is rezied. | ||
* If you resize it some other way, call _updateDrawer(). | ||
*/ | ||
_updateDrawer: Subscription | null = null; |
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.
Maybe rename this to _updateDrawerSubscription
and then pull out a method named _updateDrawer
that can still manually be used? Or just rename it and update the comment.
src/lib/sidenav/drawer.ts
Outdated
ngOnDestroy() { | ||
if (this._updateDrawer) { | ||
this._updateDrawer.unsubscribe(); | ||
this._updateDrawer = null; |
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 don't think setting to null
is necessary since the component is being destroyed
src/lib/sidenav/drawer.ts
Outdated
set breakpointChangeMode(value: boolean) { | ||
this._breakpointChangeMode = coerceBooleanProperty(value); | ||
} | ||
private _breakpointChangeMode: boolean = true; |
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.
Type should be implicit
private _breakpointChangeMode = true;
src/lib/sidenav/drawer.ts
Outdated
observableOf(null); | ||
|
||
this._updateDrawer = startWith.call(resize, null).subscribe(() => { | ||
if (this._element.nativeElement.offsetWidth < this.breakpointWidth) { |
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 haven't checked, but this needs to be consistent with any other responsive behavior in this lib or in flex-layout (i.e. <
vs <=
)
* coerce width * change comments * change _updateDrawer to _updateDrawerSubscription and add separate method
…rial2 into responsive-drawer
comments addressed |
src/lib/sidenav/drawer.ts
Outdated
|
||
/** Whether the drawer changes modes when collapsing. */ | ||
@Input() | ||
get breakpointChangeMode(): boolean { return this._breakpointChangeMode; } | ||
get breakpointChangeMode() { return this._breakpointChangeMode; } |
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.
Just a quick question... why did you remove the return type 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.
It wasn't on the number one, so I removed it here
/** Breakpoint width (in px) at which the sidenav collapses. */ | ||
|
||
@Input() | ||
get breakpointWidth() { return this._breakpointWidth; } |
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.
@jelbourn have you added anything to cdk yet for dealing with breakpoints?
@@ -48,6 +48,18 @@ | |||
</div> | |||
</md-sidenav-container> | |||
|
|||
<h2>Responsive Drawer</h2> | |||
|
|||
<md-sidenav-container class="demo-sidenav-container" breakpointWidth="600" breakpointChangeMode> |
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 so sure about this API, it doesn't seem to give much flexibility. You can't control what modes it switches between and you can't disable the auto-close/open feature
@willshowell the split between sidenav and drawer is to allow us to add features that make sense for a true global sidenav to the |
@mmalerba not yet; that will be @josephperrott's first task next week In general I'd like to have one consistent API pattern for defining responsive behaviors for all components |
@mcparadip With the merge of #6772, an API is now available to manage watching breakpoints. You should be able to rebase and use this to work on making the drawer responsive. |
Got it. Will work on it in a while |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
New version of #6525
Fixes #1130