-
-
Notifications
You must be signed in to change notification settings - Fork 45
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
Access AppLayout.showDrawer externally #279
Comments
Hi @erlenddahl, thanks for checking out Svelte UX. That's an interesting use case with AppLayout, and something we want to support. Right now (as you've seen) <script>
import { showDrawer } from 'svelte-ux';
</script> and give you control externally, much like AppBar and NavItem do, although this will likely cause a quick flash of the drawer since the default value is based on the browser windows/breakpoint. Trying to think of a way to define this default, but also allow it to be per-page. One thought I'm having is settings({
navDrawer: {
default: $page.url.pagename === '/' ? false : window.innerWidth >= breakpoints.md
}) The tricky thing will be initially navigating to a sub page (ex. const { showDrawer } = getSettings();
$showDrawer = false; Let me think on this a little, but I think moving this to settings is the way to go, at least as an initial step. I need to think how this will support per-page default and such.. |
Great! And yes, I've been checking out Svelte UX, and I am now happily using multiple of the components. Very nice library! I realize that I can create my own with and custom logic, but using an gives me everything (apart from showDrawer) for free, so that would be perfect.Seeing it transition in/out when switching pages is, perhaps, not ideal, but completely fine for me. Let me know if you need anything from me -- otherwise I'll await your thinking. |
Thanks for the amazing library! |
Hey @plutonium-239 👋 thanks for the kind words. I did move the import { getSettings } from 'svelte-ux';
const { showDrawer } = getSettings();
$showDrawer = true; // show
$showDrawer = false; // hide You could probably hide the drawer within As of right now the store is initialized based on the window width, but exposing this initialization as a callback should provide the added flexibility, although if you were to revisit you would either want to also use the |
In some cases, for example on a landing page, it is useful to be able to start the side with the drawer hidden, but still allow the user to open it.
Therefore, it would be very useful to make showDrawer in AppLayout a bindable attribute, or accessible from the outside in some other way, so that it is possible to programmatically show or hide the drawer.
(And very sorry if this is actually possible already, I couldn't see anything about it in the documentation, and I can't seem to find any available fields in the source code either.)
The text was updated successfully, but these errors were encountered: