-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: loading and template file convention (#456)
- Loading branch information
Showing
26 changed files
with
244 additions
and
37 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
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
16 changes: 1 addition & 15 deletions
16
packages/react-server/examples/basic/src/routes/test/loading/[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
3 changes: 3 additions & 0 deletions
3
packages/react-server/examples/basic/src/routes/test/loading/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,3 @@ | ||
export default function LoadingPage() { | ||
return <div className="antd-spin size-10" data-testid="/test/loading" />; | ||
} |
5 changes: 5 additions & 0 deletions
5
packages/react-server/examples/basic/src/routes/test/template/[p1]/[p2]/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,5 @@ | ||
import type React from "react"; | ||
|
||
export default function Layout(props: React.PropsWithChildren) { | ||
return props.children; | ||
} |
3 changes: 3 additions & 0 deletions
3
packages/react-server/examples/basic/src/routes/test/template/[p1]/[p2]/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,3 @@ | ||
export default function Page() { | ||
return <div>/template/[p1]/[p2]/page.tsx</div>; | ||
} |
10 changes: 10 additions & 0 deletions
10
packages/react-server/examples/basic/src/routes/test/template/[p1]/[p2]/template.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,10 @@ | ||
import { MountCount } from "../../_client"; | ||
|
||
export default function Template(props: React.PropsWithChildren) { | ||
return ( | ||
<div className="border p-2"> | ||
<MountCount name="[p1]/[p2]/template.tsx" /> | ||
{props.children} | ||
</div> | ||
); | ||
} |
5 changes: 5 additions & 0 deletions
5
packages/react-server/examples/basic/src/routes/test/template/[p1]/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,5 @@ | ||
import type React from "react"; | ||
|
||
export default function Layout(props: React.PropsWithChildren) { | ||
return props.children; | ||
} |
3 changes: 3 additions & 0 deletions
3
packages/react-server/examples/basic/src/routes/test/template/[p1]/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,3 @@ | ||
export default function Page() { | ||
return <div>/template/[p1]/page.tsx</div>; | ||
} |
10 changes: 10 additions & 0 deletions
10
packages/react-server/examples/basic/src/routes/test/template/[p1]/template.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,10 @@ | ||
import { MountCount } from "../_client"; | ||
|
||
export default function Template(props: React.PropsWithChildren) { | ||
return ( | ||
<div className="border p-2"> | ||
<MountCount name="[p1]/template.tsx" /> | ||
{props.children} | ||
</div> | ||
); | ||
} |
24 changes: 24 additions & 0 deletions
24
packages/react-server/examples/basic/src/routes/test/template/_client.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,24 @@ | ||
"use client"; | ||
|
||
import { defaultDict, once, tinyassert } from "@hiogawa/utils"; | ||
import React from "react"; | ||
|
||
const countMap = defaultDict(() => 0); | ||
|
||
export function MountCount(props: { name: string }) { | ||
const elRef = React.useRef<HTMLElement>(null); | ||
|
||
React.useEffect( | ||
once(() => { | ||
tinyassert(elRef.current); | ||
elRef.current.textContent = String(++countMap[props.name]); | ||
}), | ||
[], | ||
); | ||
|
||
return ( | ||
<div> | ||
{props.name} [mount: <span ref={elRef} />] | ||
</div> | ||
); | ||
} |
23 changes: 23 additions & 0 deletions
23
packages/react-server/examples/basic/src/routes/test/template/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,23 @@ | ||
import type React from "react"; | ||
import { NavMenu } from "../../../components/nav-menu"; | ||
|
||
export default function Layout(props: React.PropsWithChildren) { | ||
return ( | ||
<div className="flex flex-col gap-2 p-2"> | ||
<h3 className="font-bold">Test Template</h3> | ||
<NavMenu | ||
className="grid grid-cols-1 gap-1" | ||
links={[ | ||
"/test/template", | ||
"/test/template/x", | ||
"/test/template/x/a", | ||
"/test/template/x/b", | ||
"/test/template/y", | ||
"/test/template/y/a", | ||
"/test/template/y/b", | ||
]} | ||
/> | ||
{props.children} | ||
</div> | ||
); | ||
} |
3 changes: 3 additions & 0 deletions
3
packages/react-server/examples/basic/src/routes/test/template/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,3 @@ | ||
export default function Page() { | ||
return <div>/template/page.tsx</div>; | ||
} |
10 changes: 10 additions & 0 deletions
10
packages/react-server/examples/basic/src/routes/test/template/template.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,10 @@ | ||
import { MountCount } from "./_client"; | ||
|
||
export default function Template(props: React.PropsWithChildren) { | ||
return ( | ||
<div className="border p-2"> | ||
<MountCount name="template.tsx" /> | ||
{props.children} | ||
</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
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
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
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
Oops, something went wrong.