Skip to content

Commit

Permalink
templates: change names of data variables to improve clarity between …
Browse files Browse the repository at this point in the history
…data and elements (#9912)

Renames `header` to `headerData` and other props to `data` so that it's
clearer for people learning Nextjs or React.
  • Loading branch information
paulpopus authored Dec 11, 2024
1 parent 4c57df6 commit 23e2f7b
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 18 deletions.
4 changes: 2 additions & 2 deletions templates/website/src/Footer/Component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import { CMSLink } from '@/components/Link'
import { Logo } from '@/components/Logo/Logo'

export async function Footer() {
const footer: Footer = await getCachedGlobal('footer', 1)()
const footerData: Footer = await getCachedGlobal('footer', 1)()

const navItems = footer?.navItems || []
const navItems = footerData?.navItems || []

return (
<footer className="border-t border-border bg-black dark:bg-card text-white">
Expand Down
6 changes: 3 additions & 3 deletions templates/website/src/Header/Component.client.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import { Logo } from '@/components/Logo/Logo'
import { HeaderNav } from './Nav'

interface HeaderClientProps {
header: Header
data: Header
}

export const HeaderClient: React.FC<HeaderClientProps> = ({ header }) => {
export const HeaderClient: React.FC<HeaderClientProps> = ({ data }) => {
/* Storing the value in a useState to avoid hydration errors */
const [theme, setTheme] = useState<string | null>(null)
const { headerTheme, setHeaderTheme } = useHeaderTheme()
Expand All @@ -35,7 +35,7 @@ export const HeaderClient: React.FC<HeaderClientProps> = ({ header }) => {
<Link href="/">
<Logo loading="eager" priority="high" className="invert dark:invert-0" />
</Link>
<HeaderNav header={header} />
<HeaderNav data={data} />
</div>
</header>
)
Expand Down
4 changes: 2 additions & 2 deletions templates/website/src/Header/Component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import React from 'react'
import type { Header } from '@/payload-types'

export async function Header() {
const header: Header = await getCachedGlobal('header', 1)()
const headerData: Header = await getCachedGlobal('header', 1)()

return <HeaderClient header={header} />
return <HeaderClient data={headerData} />
}
4 changes: 2 additions & 2 deletions templates/website/src/Header/Nav/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import { CMSLink } from '@/components/Link'
import Link from 'next/link'
import { SearchIcon } from 'lucide-react'

export const HeaderNav: React.FC<{ header: HeaderType }> = ({ header }) => {
const navItems = header?.navItems || []
export const HeaderNav: React.FC<{ data: HeaderType }> = ({ data }) => {
const navItems = data?.navItems || []

return (
<nav className="flex gap-3 items-center">
Expand Down
4 changes: 2 additions & 2 deletions templates/with-vercel-website/src/Footer/Component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import { CMSLink } from '@/components/Link'
import { Logo } from '@/components/Logo/Logo'

export async function Footer() {
const footer: Footer = await getCachedGlobal('footer', 1)()
const footerData: Footer = await getCachedGlobal('footer', 1)()

const navItems = footer?.navItems || []
const navItems = footerData?.navItems || []

return (
<footer className="border-t border-border bg-black dark:bg-card text-white">
Expand Down
6 changes: 3 additions & 3 deletions templates/with-vercel-website/src/Header/Component.client.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import { Logo } from '@/components/Logo/Logo'
import { HeaderNav } from './Nav'

interface HeaderClientProps {
header: Header
data: Header
}

export const HeaderClient: React.FC<HeaderClientProps> = ({ header }) => {
export const HeaderClient: React.FC<HeaderClientProps> = ({ data }) => {
/* Storing the value in a useState to avoid hydration errors */
const [theme, setTheme] = useState<string | null>(null)
const { headerTheme, setHeaderTheme } = useHeaderTheme()
Expand All @@ -35,7 +35,7 @@ export const HeaderClient: React.FC<HeaderClientProps> = ({ header }) => {
<Link href="/">
<Logo loading="eager" priority="high" className="invert dark:invert-0" />
</Link>
<HeaderNav header={header} />
<HeaderNav data={data} />
</div>
</header>
)
Expand Down
4 changes: 2 additions & 2 deletions templates/with-vercel-website/src/Header/Component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import React from 'react'
import type { Header } from '@/payload-types'

export async function Header() {
const header: Header = await getCachedGlobal('header', 1)()
const headerData: Header = await getCachedGlobal('header', 1)()

return <HeaderClient header={header} />
return <HeaderClient data={headerData} />
}
4 changes: 2 additions & 2 deletions templates/with-vercel-website/src/Header/Nav/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import { CMSLink } from '@/components/Link'
import Link from 'next/link'
import { SearchIcon } from 'lucide-react'

export const HeaderNav: React.FC<{ header: HeaderType }> = ({ header }) => {
const navItems = header?.navItems || []
export const HeaderNav: React.FC<{ data: HeaderType }> = ({ data }) => {
const navItems = data?.navItems || []

return (
<nav className="flex gap-3 items-center">
Expand Down

0 comments on commit 23e2f7b

Please sign in to comment.