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

Responsive drawer #6535

Closed
wants to merge 9 commits into from
Closed

Responsive drawer #6535

wants to merge 9 commits into from

Conversation

oliver-ni
Copy link

@oliver-ni oliver-ni commented Aug 17, 2017

New version of #6525

Fixes #1130

@oliver-ni oliver-ni requested a review from mmalerba as a code owner August 17, 2017 22:17
@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Aug 17, 2017
@oliver-ni
Copy link
Author

Fixing code style in progress..

* Strip trailing whitespace
* Fix long lines
* Use element width instead of window width
* Change 'rxjs/subscription' to 'rxjs/Subscription'
}
this.close();
}
if (this._element.nativeElement.offsetWidth > this.breakpointWidth) {
Copy link
Contributor

Choose a reason for hiding this comment

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

else here sounds better.

Copy link
Author

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.

@oliver-ni
Copy link
Author

@willshowell

Copy link
Contributor

@willshowell willshowell left a comment

Choose a reason for hiding this comment

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

  1. Can you update your original post to mark it as fixing the issue?
  2. The team will require unit tests before merging
  3. 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?

@@ -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"
Copy link
Contributor

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. */

* Width of the container at which it breaks
* e.g., breakpointWidth="500"
*/
@Input() breakpointWidth: number;
Copy link
Contributor

Choose a reason for hiding this comment

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

* Note that this only works when the window is rezied.
* If you resize it some other way, call _updateDrawer().
*/
_updateDrawer: Subscription | null = null;
Copy link
Contributor

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.

ngOnDestroy() {
if (this._updateDrawer) {
this._updateDrawer.unsubscribe();
this._updateDrawer = null;
Copy link
Contributor

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

set breakpointChangeMode(value: boolean) {
this._breakpointChangeMode = coerceBooleanProperty(value);
}
private _breakpointChangeMode: boolean = true;
Copy link
Contributor

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;

observableOf(null);

this._updateDrawer = startWith.call(resize, null).subscribe(() => {
if (this._element.nativeElement.offsetWidth < this.breakpointWidth) {
Copy link
Contributor

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
@oliver-ni
Copy link
Author

comments addressed


/** Whether the drawer changes modes when collapsing. */
@Input()
get breakpointChangeMode(): boolean { return this._breakpointChangeMode; }
get breakpointChangeMode() { return this._breakpointChangeMode; }
Copy link
Contributor

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?

Copy link
Author

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; }
Copy link
Contributor

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>
Copy link
Contributor

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

@mmalerba
Copy link
Contributor

@willshowell the split between sidenav and drawer is to allow us to add features that make sense for a true global sidenav to the md-sidenav component (e.g. some fixed positioning features) and leave the md-drawer as something that can be used to create subsections of your app that have their own side "drawers". Currently they're pretty much the same, but they will diverge. This change seems like it belongs in the sidenav only since I don't think the feature makes sense for the drawer-style usage

@jelbourn
Copy link
Member

@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

@josephperrott
Copy link
Member

@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.

@josephperrott josephperrott removed their assignment Oct 6, 2017
@oliver-ni
Copy link
Author

Got it. Will work on it in a while

@oliver-ni oliver-ni closed this Oct 7, 2017
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
cla: yes PR author has agreed to Google's Contributor License Agreement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

md-sidenav: make it automatically responsive
7 participants