generated from edmundhung/remix-cloudflare-template
-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: limit root loader to be session specific
- Loading branch information
1 parent
5b1707f
commit 0b5e116
Showing
18 changed files
with
78 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import type { LoaderFunction, ShouldReloadFunction } from 'remix'; | ||
import { Outlet, json, useLoaderData, useLocation } from 'remix'; | ||
import clsx from 'clsx'; | ||
import Progress from '~/components/Progress'; | ||
import SidebarNavigation from '~/components/SidebarNavigation'; | ||
import { Context } from '~/types'; | ||
import { useSessionData } from '~/hooks'; | ||
|
||
export let loader: LoaderFunction = async ({ context }) => { | ||
const { resourceStore } = context as Context; | ||
const guide = await resourceStore.getData(); | ||
|
||
return json({ | ||
lists: guide.metadata.lists, | ||
}); | ||
}; | ||
|
||
export const unstable_shouldReload: ShouldReloadFunction = ({ submission }) => { | ||
return typeof submission !== 'undefined'; | ||
}; | ||
|
||
export default function Layout() { | ||
const { lists } = useLoaderData(); | ||
const { profile } = useSessionData(); | ||
const location = useLocation(); | ||
const isMenuOpened = | ||
new URLSearchParams(location.search).get('open') === 'menu'; | ||
|
||
return ( | ||
<> | ||
<Progress /> | ||
<nav | ||
className={clsx( | ||
'z-30 xl:block w-full lg:w-96 xl:w-64 border-r', | ||
isMenuOpened ? 'absolute xl:relative bg-gray-900' : 'hidden', | ||
)} | ||
> | ||
<SidebarNavigation profile={profile} lists={lists} /> | ||
</nav> | ||
<main className={clsx('flex-1', { 'hidden lg:block': isMenuOpened })}> | ||
<Outlet /> | ||
</main> | ||
</> | ||
); | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters