-
Notifications
You must be signed in to change notification settings - Fork 1k
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
14 changed files
with
469 additions
and
43 deletions.
There are no files selected for viewing
103 changes: 103 additions & 0 deletions
103
__fixtures__/test-project-rsc-kitchen-sink/web/src/ClientApp.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,103 @@ | ||
import { VirtualClientRouter } from '@redwoodjs/router/dist/client-router' | ||
// @ts-expect-error - something with the types for our vite package is off | ||
import { renderFromRscServer } from '@redwoodjs/vite/client' | ||
import { FatalErrorBoundary, RedwoodProvider } from '@redwoodjs/web' | ||
import { RedwoodApolloProvider } from '@redwoodjs/web/apollo' | ||
|
||
import FatalErrorPage from './pages/FatalErrorPage/FatalErrorPage' | ||
|
||
import './index.css' | ||
import './scaffold.css' | ||
|
||
// const NavigationLayout = renderFromRscServer('NavigationLayout') | ||
const NavigationLayout = ({ children }: { children: React.ReactNode }) => { | ||
return ( | ||
<> | ||
<h1>ClientApp NavigationLayout</h1> | ||
{children} | ||
</> | ||
) | ||
} | ||
|
||
const wrappers = { | ||
NavigationLayout, | ||
} | ||
|
||
const serializedRoutes = { | ||
pathRouteMap: { | ||
'/': { | ||
redirect: null, | ||
name: 'home', | ||
path: '/', | ||
whileLoadingPage: undefined, | ||
page: 'HomePage', | ||
sets: [ | ||
{ | ||
id: '1', | ||
wrappers: ['NavigationLayout'], | ||
isPrivate: false, | ||
props: {}, | ||
}, | ||
], | ||
}, | ||
'/about': { | ||
redirect: null, | ||
name: 'about', | ||
path: '/about', | ||
whileLoadingPage: undefined, | ||
page: 'AboutPage', | ||
sets: [ | ||
{ | ||
id: '1', | ||
wrappers: ['NavigationLayout'], | ||
isPrivate: false, | ||
props: {}, | ||
}, | ||
], | ||
}, | ||
}, | ||
hasHomeRoute: true, | ||
NotFoundPage: 'NotFoundPage', | ||
activeRoutePath: '/', | ||
} | ||
|
||
const analyzedRoutes = { | ||
pathRouteMap: Object.fromEntries( | ||
Object.entries(serializedRoutes.pathRouteMap).map(([path, route]) => [ | ||
path, | ||
{ | ||
...route, | ||
page: renderFromRscServer(route.page), | ||
|
||
sets: route.sets.map((set) => { | ||
return { | ||
...set, | ||
// wrappers: set.wrappers.map((w) => renderFromRscServer(w)), | ||
wrappers: set.wrappers.map((w) => wrappers[w]), | ||
} | ||
}), | ||
}, | ||
]) | ||
), | ||
hasHomeRoute: serializedRoutes.hasHomeRoute, | ||
NotFoundPage: serializedRoutes.NotFoundPage | ||
? renderFromRscServer(serializedRoutes.NotFoundPage) | ||
: null, | ||
activeRoutePath: serializedRoutes.activeRoutePath, | ||
} | ||
|
||
const App = () => { | ||
console.log('ClientApp') | ||
|
||
return ( | ||
<FatalErrorBoundary page={FatalErrorPage}> | ||
<RedwoodProvider titleTemplate="%PageTitle | %AppTitle"> | ||
<RedwoodApolloProvider> | ||
<VirtualClientRouter analyzedRoutes={analyzedRoutes} /> | ||
</RedwoodApolloProvider> | ||
</RedwoodProvider> | ||
</FatalErrorBoundary> | ||
) | ||
} | ||
|
||
export default App |
3 changes: 2 additions & 1 deletion
3
__fixtures__/test-project-rsc-kitchen-sink/web/src/entry.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
39 changes: 3 additions & 36 deletions
39
...res__/test-project-rsc-kitchen-sink/web/src/layouts/NavigationLayout/NavigationLayout.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 |
---|---|---|
@@ -1,42 +1,9 @@ | ||
import { namedRoutes as routes } from '@redwoodjs/router/dist/namedRoutes' | ||
|
||
import './NavigationLayout.css' | ||
|
||
type NavigationLayoutProps = { | ||
interface NavigationLayoutProps { | ||
children?: React.ReactNode | ||
rnd?: number | ||
} | ||
|
||
const Link = (props: any) => { | ||
return <a href={props.to}>{props.children}</a> | ||
} | ||
|
||
const NavigationLayout = ({ children, rnd }: NavigationLayoutProps) => { | ||
return ( | ||
<div className="navigation-layout"> | ||
<nav> | ||
<ul> | ||
<li> | ||
<Link to={routes.home()}>Home</Link> | ||
</li> | ||
<li> | ||
<Link to={routes.about()}>About</Link> | ||
</li> | ||
<li> | ||
<Link to={routes.userExamples()}>User Examples</Link> | ||
</li> | ||
<li> | ||
<Link to={routes.emptyUsers()}>Empty Users</Link> | ||
</li> | ||
<li> | ||
<Link to={routes.multiCell()}>Multi Cell</Link> | ||
</li> | ||
</ul> | ||
</nav> | ||
<div id="rnd">{Math.round(rnd * 100)}</div> | ||
<main>{children}</main> | ||
</div> | ||
) | ||
const NavigationLayout = ({ children }: NavigationLayoutProps) => { | ||
return <>{children}</> | ||
} | ||
|
||
export default NavigationLayout |
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.