Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: POC Next 13 global sections #2299

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

eduardoformiga
Copy link
Member

@eduardoformiga eduardoformiga commented May 2, 2024

What's the purpose of this pull request?

This PR was used to make experiments (POC) while migrating the global section to Next 13.
Along the way, we created and adjusted some tasks and added comments to guide the migration.

This PR is gigantic because most components were moved from the src folder to the app folder to make it Server Components, with a few updates to make them use the updated path.

As the Next complains about client components, we added the 'use client' to some components.
Also, other adjusts were made needed, as you can see in this PR

I suggest you see the comments below, which are linked to the files.

Copy link

vercel bot commented May 2, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
faststore-site ⬜️ Ignored (Inspect) Visit Preview May 2, 2024 9:56pm

Copy link

codesandbox-ci bot commented May 2, 2024

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

@@ -0,0 +1,174 @@
'use client'
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Client Component

@@ -0,0 +1,36 @@
'use client'
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Client Component

@@ -0,0 +1,56 @@
'use client'
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Client Component

@@ -0,0 +1,42 @@
'use client'
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Client Component

@@ -0,0 +1,120 @@
'use client'
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Client Component

@@ -0,0 +1,144 @@
'use client'
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Client Component

@@ -0,0 +1,17 @@
'use client'
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Client Component

@@ -0,0 +1,95 @@
'use client'
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Client Component

@@ -0,0 +1,16 @@
'use client'
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Client Component

@@ -0,0 +1,16 @@
'use client'
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Client Component

@@ -0,0 +1,29 @@
'use client'
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Client Component

@@ -0,0 +1,116 @@
'use client'
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Client Component - Temporary page code

@@ -0,0 +1,36 @@
'use client'
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Client Component

@@ -0,0 +1,67 @@
'use client'
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Client Component

@@ -0,0 +1,11 @@
'use client'
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Client Component

@@ -1,5 +1,6 @@
/// <reference types="next" />
/// <reference types="next/image-types/global" />
/// <reference types="next/navigation-types/compat/navigation" />
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

next automatically generate this

Comment on lines +44 to +52
// Make css order works as expected in Next 13. See https://github.com/vercel/next.js/issues/51030#issuecomment-2005254907
config.plugins.push(
new webpack.BannerPlugin({
banner: '@layer base, components, theme;',
test: /\.css$/,
raw: true,
entryOnly: false,
})
)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix styles order issue. see the comment

"name": "next"
}
],
"strictNullChecks": false
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needed to make Section Override work as previously.

SearchInput as UISearchInput,
SearchInputField as UISearchInputField,
} from '@faststore/ui'
import { useRouter } from 'next/navigation'
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'next/navigation' from next 13 instead of 'next/router'

Comment on lines +41 to +45
/* TODO: we should use DraftMode instead of preview mode in Next 13 */
}
const { sections } = await getPage<PageContentType>({
contentType: GLOBAL_SECTIONS_CONTENT_TYPE,
})
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a task in our backlog to use draft mode instead of previewData (hCMS).

Comment on lines +58 to +59
{/* TODO: we should use metadata api from Next 13 */}
{/* <DefaultSeo norobots={storeConfig.experimental.noRobots} /> */}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DefaultSeo doesn't work as expected in Next 13. We also have a task to use the native SEO (Metadata) API, instead.

Comment on lines +123 to +156
// BannerText: {
// Section: typeof BannerText
// components: {
// BannerText: ComponentOverrideDefinition<BannerTextProps, BannerTextProps>
// BannerTextContent: ComponentOverrideDefinition<
// BannerTextContentProps,
// BannerTextContentProps
// >
// }
// }
// Breadcrumb: {
// Section: typeof Breadcrumb
// components: {
// Breadcrumb: ComponentOverrideDefinition<BreadcrumbProps, BreadcrumbProps>
// Icon: ComponentOverrideDefinition<IconProps, IconProps>
// }
// }
// EmptyState: {
// Section: typeof EmptyState
// components: {
// EmptyState: ComponentOverrideDefinition<
// PropsWithChildren<EmptyStateProps>,
// EmptyStateProps
// >
// }
// }
// Hero: {
// Section: typeof Hero
// components: {
// Hero: ComponentOverrideDefinition<HeroProps, HeroProps>
// HeroImage: ComponentOverrideDefinition<HeroImageProps, HeroImageProps>
// HeroHeader: ComponentOverrideDefinition<HeroHeaderProps, HeroHeaderProps>
// }
// }
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should uncomment these lines as we migrate these sections into the pages.

Comment on lines +65 to +66
/** This type wizardry is here because the props won't behave correctly if nothing is done */
// @ts-ignore
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ts-ignore was needed to make the SectionOverride works as previously.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant