Skip to content

Commit

Permalink
Add international toc to home page (#1002)
Browse files Browse the repository at this point in the history
* feat: add international toc
* fix: logo on old nav should be a pointer
  • Loading branch information
vnugent authored Oct 30, 2023
1 parent e394b6e commit 3a2e2a9
Show file tree
Hide file tree
Showing 6 changed files with 114 additions and 10 deletions.
38 changes: 38 additions & 0 deletions src/app/components/InternationalToC.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import Link from 'next/link'
import { SectionContainer } from './ui/SectionContainer'
import { INTERNATIONAL_DATA, ToCCountry } from './international-data'
import { ToCAreaEntry } from './USAToC'

/**
* International table of content
*/
export const InternationalToC: React.FC = () => {
return (
<SectionContainer header={<h2>International</h2>}>
<div className='columns-3xs gap-x-10'>
{
INTERNATIONAL_DATA.map(country =>
<CountryCard key={country.uuid} country={country} />
)
}
</div>
</SectionContainer>
)
}

const CountryCard: React.FC<{ country: ToCCountry }> = ({ country }) => {
const { areaName, uuid, children } = country
return (
<div className='mb-10 break-inside-avoid-column break-inside-avoid'>
<Link href={`/crag/${uuid}`}>
<span className=' font-semibold'>{areaName}</span>
</Link>
<hr className='mb-2 border-1 border-base-content/60' />
<div className='flex flex-col'>
{
children.map(area => <ToCAreaEntry key={area.uuid} {...area} />)
}
</div>
</div>
)
}
24 changes: 15 additions & 9 deletions src/app/components/USAToC.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
import Link from 'next/link'
import { ArrowRightCircleIcon } from '@heroicons/react/24/solid'
import { getUSATableOfContent } from '@/js/graphql/getPopularAreasUSA'

import { SectionContainer } from './ui/SectionContainer'
/**
* USA table of content
*/
export const USAToC: React.FC = async () => {
const toc = await getUSATableOfContent()
return (
<section className='block w-full px-4 2xl:px-0 mx-auto max-w-5xl xl:max-w-7xl'>
<Link href='/crag/1db1e8ba-a40e-587c-88a4-64f5ea814b8e' className='flex flex-row items-center gap-2'><h2>USA</h2><ArrowRightCircleIcon className='w-4 h-4' /></Link>
<hr className='mb-6 border-2 border-base-content' />
<SectionContainer
header={
<Link href='/crag/1db1e8ba-a40e-587c-88a4-64f5ea814b8e' className='flex flex-row items-center gap-2'>
<h2>USA</h2><ArrowRightCircleIcon className='w-4 h-4' />
</Link>
}
>
<div className='columns-3xs gap-x-10'>
{Array.from(toc.values()).map(state => {
const { name, uuid, totalClimbs, areas } = state
Expand All @@ -24,15 +28,17 @@ export const USAToC: React.FC = async () => {
</Link>
<hr className='mb-2 border-1 border-base-content/60' />
<div className='flex flex-col'>
{areas.map(area => {
const { uuid, areaName } = area
return (<Link key={uuid} className='text-xs hover:underline' href={`/crag/${uuid}`} prefetch={false}>{areaName}</Link>)
})}
{
areas.map((area) => <ToCAreaEntry key={area.uuid} {...area} />)
}
</div>
</div>
)
})}
</div>
</section>
</SectionContainer>
)
}

export const ToCAreaEntry: React.FC<{ uuid: string, areaName: string }> =
({ uuid, areaName }) => (<Link key={uuid} className='text-xs hover:underline' href={`/crag/${uuid}`} prefetch={false}>{areaName}</Link>)
43 changes: 43 additions & 0 deletions src/app/components/international-data.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { AreaType } from '@/js/types'

export type ToCArea = Pick<AreaType, 'uuid' | 'areaName'>
export type ToCCountry = Pick<AreaType, 'uuid' | 'areaName'> & {
children: ToCArea[]
}

export const INTERNATIONAL_DATA: ToCCountry[] = [
{
areaName: 'Canada',
uuid: '2996145f-e1ba-5b56-9da8-30c64ccc3776',
children: [{
uuid: 'a354b580-870b-5444-9f11-2c0e78995841',
areaName: 'Squamish'
},
{
uuid: '4624f40a-b644-5256-9287-aa19002ce00f',
areaName: 'Powell River'
},
{
uuid: 'a33bf360-9bf1-5d0f-b082-9ef3a51aa231',
areaName: 'Skaha'
},
{
uuid: '26913742-ffc5-5c8f-834b-7f0cd1b58d81',
areaName: 'The Bugaboos'
},
{
uuid: 'fa6ebe07-759f-5a35-b715-c39bbb8424d2',
areaName: 'Lake Louise'
}
]
},
{
areaName: 'South Africa',
uuid: '1d33c773-e381-5b8a-a13f-3dfd7991732b',
children: [{
uuid: '4ed6c976-ee02-564a-801e-20ccc10e6e26',
areaName: 'Rocklands'
}
]
}
]
15 changes: 15 additions & 0 deletions src/app/components/ui/SectionContainer.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { ReactNode } from 'react'

interface Props {
header: ReactNode
children: ReactNode
}
export const SectionContainer: React.FC<Props> = ({ header, children }) => {
return (
<section className='block w-full px-4 2xl:px-0 mx-auto max-w-5xl xl:max-w-7xl'>
{header}
<hr className='mb-6 border-2 border-base-content' />
{children}
</section>
)
}
2 changes: 2 additions & 0 deletions src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { RecentEdits, RecentEditsSkeleton } from './components/RecentEdits'
import { FinancialContributors } from './components/FinancialContributors'
import { RecentTags } from './components/RecentTags'
import { USAToC } from './components/USAToC'
import { InternationalToC } from './components/InternationalToC'

/**
* Cache duration in seconds
Expand All @@ -30,6 +31,7 @@ export default async function Home (): Promise<any> {
</div>
</div>
<RecentTags />
<InternationalToC />
<USAToC />
<FinancialContributors />
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/components/DesktopAppBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export default function DesktopAppBar ({ showFilterBar = true }: DesktopAppBarPr
<header className='sticky top-0 z-10'>
<DesktopNavBar
branding={
<Link href='/' legacyBehavior>
<Link href='/'>
<LogoWithText className='h-[36px]' />
</Link>
}
Expand Down

1 comment on commit 3a2e2a9

@vercel
Copy link

@vercel vercel bot commented on 3a2e2a9 Oct 30, 2023

Choose a reason for hiding this comment

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

Please sign in to comment.