-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
97 additions
and
8 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
5 changes: 5 additions & 0 deletions
5
apps/bible/app/bible/routing/intercepting-routes/@modal/(.)todo/[todo-id]/loading.tsx
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,5 @@ | ||
import { Heading } from '@/components/typography/heading' | ||
|
||
export default function Loading() { | ||
return <Heading level="4">Loading todo by id in modal..</Heading> | ||
} |
30 changes: 30 additions & 0 deletions
30
apps/bible/app/bible/routing/intercepting-routes/@modal/(.)todo/[todo-id]/modal.tsx
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,30 @@ | ||
'use client' | ||
|
||
import { type ElementRef, useEffect, useRef } from 'react' | ||
import { useRouter } from 'next/navigation' | ||
import { createPortal } from 'react-dom' | ||
|
||
export function Modal({ children }: { children: React.ReactNode }) { | ||
const router = useRouter() | ||
const dialogRef = useRef<ElementRef<'dialog'>>(null) | ||
|
||
useEffect(() => { | ||
if (!dialogRef.current?.open) { | ||
dialogRef.current?.showModal() | ||
} | ||
}, []) | ||
|
||
function onDismiss() { | ||
router.back() | ||
} | ||
|
||
return createPortal( | ||
<div className="modal-backdrop"> | ||
<dialog ref={dialogRef} className="modal" onClose={onDismiss}> | ||
{children} | ||
<button onClick={onDismiss} className="close-button" /> | ||
</dialog> | ||
</div>, | ||
document.getElementById('modal-root')! | ||
) | ||
} |
6 changes: 6 additions & 0 deletions
6
apps/bible/app/bible/routing/intercepting-routes/@modal/(.)todo/[todo-id]/page.tsx
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,6 @@ | ||
import { sleep } from '@/lib/utils' | ||
|
||
export default async function TodoByIdModalPage() { | ||
await sleep(2000) | ||
return <div>i am todo modal</div> | ||
} |
5 changes: 0 additions & 5 deletions
5
apps/bible/app/bible/routing/intercepting-routes/@modal/(...)todo/[id]/page.tsx
This file was deleted.
Oops, something went wrong.
3 changes: 3 additions & 0 deletions
3
apps/bible/app/bible/routing/intercepting-routes/@modal/default.tsx
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,3 @@ | ||
export default function Default() { | ||
return null | ||
} |
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,3 @@ | ||
export default function Default() { | ||
return null | ||
} |
15 changes: 15 additions & 0 deletions
15
apps/bible/app/bible/routing/intercepting-routes/layout.tsx
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,15 @@ | ||
import { PropsWithChildren, ReactNode } from 'react' | ||
|
||
type Props = PropsWithChildren & { | ||
modal: ReactNode | ||
} | ||
|
||
export default function InterceptingRoutesLayout({ children, modal }: Props) { | ||
return ( | ||
<div> | ||
{children} | ||
{modal} | ||
<div id="modal-root" /> | ||
</div> | ||
) | ||
} |
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,5 @@ | ||
import { Heading } from '@/components/typography/heading' | ||
|
||
export default function Loading() { | ||
return <Heading level="4">Loading todos...</Heading> | ||
} |
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 |
---|---|---|
@@ -1,5 +1,20 @@ | ||
const InterceptingRoutes = () => { | ||
return <div>hi</div> | ||
import { Stack } from '@/components/primitives/stack' | ||
import { todo } from '@/module/todo' | ||
import Link from 'next/link' | ||
|
||
const InterceptingRoutesPage = async () => { | ||
const { todos } = await todo.api.getTodos() | ||
return ( | ||
<Stack> | ||
{todos.map((item) => { | ||
return ( | ||
<Link href={`/bible/routing/intercepting-routes/todo/${item.id}`} key={item.id}> | ||
<todo.components.TodoCard {...item} /> | ||
</Link> | ||
) | ||
})} | ||
</Stack> | ||
) | ||
} | ||
|
||
export default InterceptingRoutes | ||
export default InterceptingRoutesPage |
5 changes: 5 additions & 0 deletions
5
apps/bible/app/bible/routing/intercepting-routes/todo/[todo-id]/loading.tsx
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,5 @@ | ||
import { Heading } from '@/components/typography/heading' | ||
|
||
export default function Loading() { | ||
return <Heading level="4">Loading todo by id in page..</Heading> | ||
} |
6 changes: 6 additions & 0 deletions
6
apps/bible/app/bible/routing/intercepting-routes/todo/[todo-id]/page.tsx
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,6 @@ | ||
import { sleep } from '@/lib/utils' | ||
|
||
export default async function TodoByIdPage() { | ||
await sleep(2000) | ||
return <div>hi</div> | ||
} |