-
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.
- Loading branch information
1 parent
26db213
commit 8780d7a
Showing
5 changed files
with
27 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,18 @@ | ||
import * as React from 'react'; | ||
import type { WrapRootElementBrowserArgs, WrapPageElementBrowserArgs } from 'gatsby' | ||
|
||
import { Shell } from './src/components/shell'; | ||
import { SSRSetup } from './src/components/ssr-setup'; | ||
import { Theme } from './src/components/theme'; | ||
|
||
export const wrapRootElement = ({ element }) => { | ||
export const wrapRootElement = ({ element }: WrapRootElementBrowserArgs) => { | ||
return ( | ||
<SSRSetup> | ||
<Theme>{element}</Theme> | ||
</SSRSetup> | ||
); | ||
}; | ||
|
||
export const wrapPageElement = ({ element, props }) => ( | ||
export const wrapPageElement = ({ element, props }: WrapPageElementBrowserArgs) => ( | ||
<Shell {...props}>{element}</Shell> | ||
); |
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,20 +1,21 @@ | ||
import { SSRProvider } from '@fluentui/react-utilities'; | ||
import { createDOMRenderer, RendererProvider } from '@griffel/react'; | ||
import * as React from 'react'; | ||
import type { WrapRootElementNodeArgs, WrapPageElementNodeArgs } from 'gatsby' | ||
|
||
import { Shell } from './src/components/shell'; | ||
import { Theme } from './src/components/theme'; | ||
|
||
const renderer = createDOMRenderer(); | ||
|
||
export const wrapRootElement = ({ element }) => ( | ||
export const wrapRootElement = ({ element }: WrapRootElementNodeArgs) => ( | ||
<RendererProvider renderer={renderer}> | ||
<SSRProvider> | ||
<Theme>{element}</Theme> | ||
</SSRProvider> | ||
</RendererProvider> | ||
); | ||
|
||
export const wrapPageElement = ({ element, props }) => ( | ||
export const wrapPageElement = ({ element, props }: WrapPageElementNodeArgs) => ( | ||
<Shell {...props}>{element}</Shell> | ||
); |
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 +1,2 @@ | ||
export { Shell } from './shell'; | ||
export type { ShellProps } from './shell.types'; |
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,11 @@ | ||
import type { PageProps } from 'gatsby'; | ||
import type { ReactNode } from 'react'; | ||
|
||
/** | ||
* @description ShellProps is a type that extends the PageProps type from Gatsby and adds a children property. Shell is | ||
* used in Gatsby browser and SSR configs to wrap the page component. `wrapPageElement` is used in Gatsby browser and | ||
* SSR configs to add the Shell to the page component. It passes PageProps to the Shell component, but unlike Gatsby | ||
* pages, Shell does indeed have children, so we are removing the children property 9set to `undefined` from PageProps | ||
* and adding it to ShellProps. | ||
*/ | ||
export type ShellProps = Omit<PageProps, 'children'> & { children: ReactNode }; |