-
Notifications
You must be signed in to change notification settings - Fork 49
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
Save Menu State? #2
Comments
I am sorry for my late.
No need to apologize.
You can use localstorage to persist user settings something like const setup = () => {
function getSidebarStateFromLocalStorage() {
// if it already there, use it
if (window.localStorage.getItem('isSidebarOpen')) {
return JSON.parse(window.localStorage.getItem('isSidebarOpen'))
}
// else return the initial state you want
return (
false
)
}
function setSidebarStateToLocalStorage(value) {
window.localStorage.setItem('isSidebarOpen', value)
}
return {
loading: true,
isSidebarOpen: getSidebarStateFromLocalStorage(),
toggleSidbarMenu() {
this.isSidebarOpen = !this.isSidebarOpen
setSidebarStateToLocalStorage(this.isSidebarOpen)
},
isSettingsPanelOpen: false,
isSearchBoxOpen: false,
}
} i hope this helps and this what you want.
quick fix for that using x-cloak x-cloak reference in html <aside
x-cloak
x-transition:enter="transition transform duration-300"
x-transition:enter-start="-translate-x-full opacity-30 ease-in"
x-transition:enter-end="translate-x-0 opacity-100 ease-out"
... in css [x-cloak] { display: none; } see this demo on code pen I hope this helps you, if not or if there is any other problem, ask in any time. Sorry if there something wrong in my English, it's not my first language |
This is perfect, thank you for the help! |
First off, thanks for sharing this clean design. :)
I'm new to tailwindcss and alpinejs so I apologize if these questions are outside the scope of the code shared here.
How do I save the isSidebarOpen state?
Upon reload the menu Flashes open then to a closed state each time the page is reloaded.
Note: I am using Rails 6.1, Turbolinks, webpack
Any assistance with these 2 issues would be very helpful.
Thank you,
The text was updated successfully, but these errors were encountered: