angular / components

Component infrastructure and Material Design components for Angular
https://material.angular.io
MIT License
24.31k stars 6.72k forks source link

Navigation drawer - Mini variant behavior #1728

Open Daugoh opened 7 years ago

Daugoh commented 7 years ago

Feature request:

Add the "Mini variant" behavior of the Navigation drawer. As defined in the Google Material guidelines: https://material.google.com/patterns/navigation-drawer.html#navigation-drawer-behavior

What is the expected behavior?

When toggled, the navigation drawer change its width. It's not fully hidden.

What is the current behavior?

Only two states are available: displayed, hidden

What are the steps to reproduce?

Create a sidenav and toggle it on and off. The sidenav can only be opened or closed. No intermediate state.

What is the use-case or motivation for changing an existing behavior?

Desktop users need to quickly change the current view. The sliding effect of the sidenav could be annoying when used a lot. It's common for desktop apps to keep the navigation opened by default. But in some cases the icons are self explanatory so no need to display the associated labels.

Which versions of Angular, Material, OS, browsers are affected?

Angular2

Is there anything else we should know?

A similar feature request was submitted for Angular 1: https://github.com/angular/material/issues/3158

jelbourn commented 7 years ago

Is there any reason you couldn't control the width of the sidenav with css and toggle classes based on which width you want to display?

Daugoh commented 7 years ago

Hello @jelbourn

Thanks for your answer.

Yes I tried to do it manually. I can show/hide the texts with a CSS class or use a ngIf. It works but then I have a problem of alignment for my icons. They are not correctly centered.

So yes we can do it ourselves but I think it would be really useful to have it natively. And then just use an attribute like textVisible or iconOnly for instance ...

Regards

kuncevic commented 7 years ago

Is that feature has being planned yet? Is there any deadlines on that?

@daugoh have you come up with any proper soulution for this one?

Here is https://github.com/angular/material2/issues/2021 one of the ways http://plnkr.co/edit/LcRDIHNFjHKLFTaMdNEM?p=preview of doing that

MrNikunjPatel commented 7 years ago

Probably, You can manage it buy css for intermediate state as below. You might need some css overrides as per need.

` <md-sidenav #sidenav>

menu {{view.icon}} {{view.name}}
</md-sidenav>
<app-contacts></app-contacts>

`

/*left sidenav style override*/ md-sidenav { background-color: #f8921e; overflow: hidden; } md-nav-list a[md-list-item] { color: #fff; } md-nav-list a[md-list-item] .md-list-item{ padding: 0 10px !important; } .md-sidenav-over.md-sidenav-closed md-nav-list a[md-list-item] .md-list-text { display: none !important; } md-sidenav.md-sidenav-closed { transform: translate3d(0, 0, 0) !important; visibility: visible !important; min-width: 40px !important; }

Daugoh commented 7 years ago

@kuncevic So far I'm just using a quick workaround with a ngIf to show/hide the text

vtolstov commented 7 years ago

Any news?

vtolstov commented 7 years ago

@rajamarketing can you help me and provide css with @media query so i don't need to watch in angular componnet for window resize events and css applied automatic?

brunoracosta commented 7 years ago

Hi people, news?

Stoom commented 7 years ago

from @rajamarketing comment here is what I've come up with, be it sass complains but it compiles...

    md-sidenav {
        width: 200px;

        md-icon {
            padding-right: 20px !important;
        }

        &.mat-sidenav-closed {
            transform: translate3d(0, 0, 0) !important; 
            visibility: visible !important;
            min-width: 64px !important;
            width: 64px !important;

            &~ /deep/.mat-sidenav-content {
                margin-left: 64px !important;
            }
        }
    }
}
unstephenk commented 7 years ago

Any updates?

JanOschii commented 7 years ago

Seems like @daxsom has a solution. Any chance to get this with the next stable release?

Misiu commented 7 years ago

firebase and google analytics has this functionality. It would be awesome to have this build in and working by default

rui-cruz commented 6 years ago

yes pls!

Ravi-Rajpurohit commented 6 years ago

this may help .. https://github.com/Ravi-Rajpurohit/mini-md-sidenav

liri2006 commented 6 years ago

Would be extremely helpful to have this as a native feature. As for now it requires some hacky css to make it work both for desktop (mini-sidenav) and mobile (classic one), which are breaking with almost every release :)

matte00 commented 6 years ago

Any news?

haskelcurry commented 6 years ago

Yes, any news, please?

morten-kirstein commented 6 years ago

could be on the steps. I mentioned it to Thomas Burleson from the Angular Material team at Angular Connect. He said it shouldn't take long to make. Meanwhile, we could use the CSS hack method.

I'll just follow up on it.

51Ray commented 6 years ago

I hope and expect...

AyushiSrivastava20 commented 6 years ago

any stable release with these changes?

Melanie-M commented 6 years ago

Thanks to https://github.com/angular/material2/pull/8488 you can now use autosize in mat-sidenav-container, so you can resize the sidenav without css hacks.

Here's an example adapted from the "autosize sidenav" example: https://stackblitz.com/edit/angular-b4gmby

mackelito commented 6 years ago

@Melanie-M so just a question... If a remove "autosize"... I still see the same result?

Melanie-M commented 6 years ago

@mackelito I think without autosize the main content doesn't resize properly, the sidenav overlaps it instead. But so depending on what behavior you want, I guess it can work without autosize

gangsthub commented 6 years ago

Answering @jelbourn's comment from 2 years ago. It cannot be achieved easily with css: mat-sidenav-content gets it's margin-left from mat-sidenav and you have to add the autosize to the mat-sidenav-container (wich adds perf issues) and even if you hide manually the mat-list-item's labels, there are no fancy animations on the icons/labels out-of-the-box. I think this should be the library's responsibility, not user's (because you have to override a lot of css if you want to avoid the autosize attr, enable the animations, etc. on your own, being this decisions not future-proof)

isrmicha commented 6 years ago

must have feat

rellis-of-rhindleton commented 6 years ago

If autosize causes performance problems -- which isn't surprising if it makes the size get rechecked on every change cycle -- can we just get a method that will force resize manually?

The code is already in the component to do all the work, and we (usually) know when we want to make it resize. Seems fair to just expose a way to force it to happen when needed, and not bother with having it check all the time.

FWIW, we're getting around this by (at time to resize) turning on autosize via a ViewChild reference, then turning it off again a second later via setTimeout. It's hacky though.

kyusupov33 commented 6 years ago

must have :)

adamdyson commented 6 years ago

I am just going to leave this here in the hope that similar features are introduced in Angular. https://vuetifyjs.com/en/components/navigation-drawers#example-mini

ghost commented 6 years ago

https://stackoverflow.com/questions/48479524/how-to-impliment-a-sidenav-navigation-drawer-with-a-mini-variant/49884854?noredirect=1#comment90117208_49884854

Harkiratsingh026 commented 6 years ago

You can also check this link: https://medium.com/@harkiratsingh.026/angular-6-mini-variant-drawer-d5326be55dd1

IlCallo commented 5 years ago

@jelbourn are you guys open for a PR about this? Not easy to pinpoint the specs because in current Material Design guidelines the "mini" variant is nowhere to be found, but if you tell me old specs are ok, I can try a PR which just defines a 'mini' status with user-defined width value (with sensible default values).

This issue actually proposed some kind of API for it already #9640

jelbourn commented 5 years ago

At this point we would probably hold off on the mini variant to check with the Material Design team to see if they plan for this to still be part of the canon.

Misiu commented 5 years ago

@jelbourn any news from Material Design Team?

malcaESayYes commented 5 years ago

in css: /deep/.mat-drawer.mat-drawer-end[ng-reflect-opened=false]{ left: 35px !important; visibility: visible !important; }

it working!!!

but in prod - no....

mackelito commented 5 years ago

try this instead ::ng-deep .mat-drawer.mat-drawer-end[ng-reflect-opened=false]{

zipporaSay commented 5 years ago

ng-reflect-opened property not appearing in prod - after build (im wrote the last answer)

mackelito commented 5 years ago

@zipporaSay I would suggest you to have your own selector. When you close it add class "closed" an use that selector instead

IlCallo commented 5 years ago

/deep/ and ::ng-deep are deprecated because they break incapsulation, not really a good solution IMHO... Also, just setting the sidenav width should suffice to get what you're trying to do with that CSS

mackelito commented 5 years ago

Are there other ways to force styles to components outside the material components?

IlCallo commented 5 years ago

Not from a component to another AFAIK You should use global CSS rules (aka non-scoped CSS) for that, even if it's a lot less maintenable because it moves some rules relative to a component outside the component folder/files

danielheddelin commented 5 years ago

Okay, so it's been a little over 2 years. Any core team member who would like to comment on this?

Tyler-V commented 5 years ago

...this would be nice!

Fourie-r commented 5 years ago

+1 Must have here. Thanks

Lakston commented 5 years ago

Same here, we need this.

S-amuel commented 5 years ago

This is a good request, Any updates?

edit: Ravi-Rajpurohit's & Harkiratsingh026's links work great

lramondev commented 5 years ago

2 This is a good request, Any updates?

EagleInNight commented 5 years ago

Any updates? Need this

Rodrigo54 commented 5 years ago

the angular materials team is working together with the angular core team to launch the ivy compiler, do not expect any new feature until the ivy be released

jelbourn commented 5 years ago

(I'm going through the highest voted issues today an commenting on their status)

We still consider this something that we want to add, but it's still one of the lower-priority features in the backlog (compared to things like virtual scrolling for table, density theming, improving CDK documentation, etc.). As I mentioned in my recent ng-conf talk, we're doing some work now to integrate MDC Web into our components, so we would likely hold off on working on this until we have a better idea of what the MDC-based sidenav would look like.

mackelito commented 5 years ago

@jelbourn just so that we can get a grasp of what is to come and what is priority.. Is https://github.com/angular/components/projects/25 "up to date"?

Also how many devs are currently focusing on angular components?