-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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 updates #684
Drawer updates #684
Conversation
@tungi52 Looks like you've been busy. 👍 Ill take a look now. |
@tungi52 This is looking great. 👍 First off I am not a drawer expert. But that may be an advantage in helping us make these drawers as understandable as possible to the end user. As a start could you add a bit more description to the examples so I am completely clear on behaviours for each type of drawer. Also I think the temporary drawer should close on clicking an item within for demonstration purposes. This is question - In clipped mode should the drawer overlap the main content rather than push it over. This may be by design so maybe this is just for my understanding. |
@mikes-gh Thanks. You are right, docs should be improved, they are very minimal now. |
@tungi52 Yes it will help me review if the docs are done first as they are a design document. After that we can get into a code review |
Hi @tungi52 sorry for slow reply had other work to do. Looking good. I understand all the concepts. I did have to look up how clipped worked in Material UI. but that was it. I would expect responsive drawer to be clipped by default but it seems an anti-pattern to have a boolean that is true default. Others may have an opinion but its just a setting at the end of the day. I am going to start to dig into the code now. |
I don't think so. A good default value (no matter the value) should be what most will expect when they don't touch the setting |
@tungi52 Just exploring this 😄 |
I realise you are fixing everyone else's design here but one thing I really thought should be addressed is that |
@mikes-gh I admit that this is the most problematic part of the code. MainContent and AppBar should be changed depends on the drawer state. This is part of the current behaviour, so I wanted to keep it. As you wrote, DrawerContainer is the new link between Drawer, Layout, AppBar and MainContent and this link provide this functionality. But this dependency is not necessary, with Fixed parameter one can decouple it from the Layout and use in any container (this only works for persistent drawers at the moment - I don't know for others it has a meaning at all). |
@tungi52 OK lets leave aside the Layout App bar dependencies for now. Could you decouple NavLink please and make a callback in NavMenu. NavMenu or any of its constituents definitely shouldnt know about drawer. |
Ok, I understand. Can you give me an advice? In general Drawer does not know there is NavMenu inside it so I have no idea how to start. How a drawer should register to an event from NavMenu? Or cascading some common object instead of the drawer itself? |
NavMenu would have a callback Parameter OnNavigate. |
I guess its up-to the the developer to wire this up. Best demonstrated in a sample. But NavLink shouldn't be calling drawer directly. Since Drawer is often going to have NavMenu inside we just need to make sure its easy to wire them up. |
Yes I know this, a really helpful write. But for me a combination of option 2 and 3 could work (or make a new service?). Point 1 is not possible, because Drawer and NavMenu don't know about each other directly. Only in the user code, but I think the idea behind the current solution was that on navigation the drawer should close automatically. Or did I misunderstand you? |
Yes its just an open close thing. |
I think we just need a sample showing it as its a common senario and get rid of the Drawer code in NavLink |
NavMenu and Drawer dont need to know about each other thats up to the developer IMO |
I am not sure. what about this: let drawer send down a cascaded value of INavigationEventReceiver or something similar and let NavLink call this on navigation? Other links, buttons etc could implement the same |
@henon Do you think this is not a simple docs exercise? Plus the developer may want to do different things on navigate. as well as close the drawer (or keep it open). Do you think we need a default behaviour for NavMenu inside drawer? |
Ok, you have a point there, Mike. |
Just putting it out there. Always open to ideas. As always its a balance between complete flexibility and making it easy for simple senarios. I guess there are lots of senarios of what drawer could contain. It could be like a complete reporting parameter area so I dont think we should try to tie this together. For this simple senario of NavMenu closes opens the drawer we can show in the docs I think. |
I pushed 2 commits. The first one contains some additional features requested in #388 and #627. I replaced the Clipped parameter with an enum, so now there are more options to control this behaviour. Here I can accept some other ideas for naming :) |
@tungi52 if you're doing any docs be aware of this https://github.com/Garderoben/MudBlazor/pull/688 |
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.
@tungi52 Thats my first scan. Ive got todo some other bits now. There is a great deal of work in this PR thank you. Apologies if Im dipping in and out of it.
src/MudBlazor.Docs/Pages/Components/Drawer/Examples/DrawerClippingExample.razor
Show resolved
Hide resolved
src/MudBlazor.Docs/Pages/Components/Drawer/Examples/DrawerClippingExample.razor
Outdated
Show resolved
Hide resolved
Is the breakpoint for responsive drawer configurable? Are the two special breakpoints Breakpoint.None and Breakpoint.Always also supported? They sound crazy but they actually make sense sometimes, i.e. if you want to force smallscreen behavior even if the screen is big or if you want to suppress it even if the screen is small. Does it make sense or not? |
@henon I think it is not supported as ealier, but there new variants (temporary, persistent) which are not depends on the screen size. IMO this solve these issues and developers can find the best one which fits their needs. Also I planning other variants too (mini, floating) but later. |
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 made an API review so we keep all publicly accessible functions consistent with the rest of the lib. After applying these little changes I think we can merge or what do you think @tungi52 ?
@tungi52 Looking close now.
|
Also there is some grammar in the examples that needs changing. Obviously this is much harder if english is not your first language so one of us can do this after the merge. Just flagging it here as a TODO |
Ok this is a design question I think. Currently responsive drawer saves the large state, which is null by default. This help to restore the original state after resize (I think gitter works similarly). So for now this is "expected", but I understand what your problem with it. Maybe a parameter like PreserveOpenState? @henon |
@tungi52 Gitter actually closes the drawer on mouse out so by the time you goto make the screen bigger the drawer is already closed. |
@mikes-gh I think I change it like the saved state only matters when we resize from small to large and the drawer is closed. |
Sure, this is a very good idea! I am pretty sure our users will want both, so making it configurable is always the best option. |
@mikes-gh: in MockResizeListener we can add functions to initiate virtual screen size/breakpoint change events from within the test case. It should then be easy to check if certain CSS classes were applied as expected. |
@tungi52 Do you think this is ready now? Seems good to me. We can write the tests and tighten up grammar on the docs later. |
@Garderoben I think it is ready. |
Thanks a ton for this great work @tungi52 ! |
Thanks @tungi52 this was a lot of work 👍 |
It looks like there is an issue with the generated class name and what is in the compiled css. With the following code, the class '.mud-main-drawer-open-persistent-md-left' is put on the '.mud-main-content'. That class does nothing. When I looked in the PR code, I found that removing the '-md' fixed it for me. I tried various Breakpoint settings and they all have this issue. <MudLayout>
<MudAppBar></MudAppBar>
<MudDrawer ClipMode="DrawerClipMode.Always"
Open="true"
Variant="DrawerVariant.Persistent">
<MudNavMenu>
<MudNavLink Match="NavLinkMatch.All" Href="/settings">@Localizer[SettingsResources.General]</MudNavLink>
<MudNavLink Match="NavLinkMatch.All" Href="/settings/price">@Localizer[SettingsResources.Price]</MudNavLink>
<MudNavLink Match="NavLinkMatch.All" Href="/settings/map">@Localizer[SettingsResources.Map]</MudNavLink>
<MudNavLink Match="NavLinkMatch.All" Href="/settings/wiki">@Localizer[SettingsResources.Wiki]</MudNavLink>
<MudNavLink Match="NavLinkMatch.All" Href="/settings/chat">@Localizer[SettingsResources.Chat]</MudNavLink>
<MudNavLink Match="NavLinkMatch.All" Href="/settings/stash">@Localizer[SettingsResources.Stash]</MudNavLink>
</MudNavMenu>
</MudDrawer>
<MudMainContent>
<MudContainer>
@ChildContent
</MudContainer>
</MudMainContent>
</MudLayout> |
@tungi52 I pre-released the drawer in https://www.nuget.org/packages/MudBlazor/1.2.4.12-dev which is what leMicin used. Maybe I made an error when packaging? |
@henon if you used dotnet pack I dont see how. Are we saying this could be an scss compiler issue? |
no, no it's my fault. I found a small problem in css. How can I fix it? Pushing a new commit in this PR is ok? |
make a new PR and link it here |
@mikes-gh , When I look at the scss code inside src/MudBlazor/Styles/layout/_main.scss (lines: 33-48). It really looks like there is not class name that includes the breakpoint in it. The GetDrawerClass() method in src/MudBlazor/Components/Main/MudMainContent.razor does include the breakpoint in the compiled class name. There is a mismatch between the two, which is what I tried to explain with pictures. |
@leMicin the css fixes are in pre-release https://www.nuget.org/packages/MudBlazor/1.2.4.13-dev |
Update drawer implementation and examples trying to cover some of requests and reported bugs. I'm pretty sure this PR doesn't solve all the problems, but I think it could be a good start. Important changes:
@Garderoben @henon @mikes-gh Can you take a look at it and test it? I highly appreciate your help.
Breaking changes: