generated from taylorbryant/gatsby-starter-tailwind
-
-
Notifications
You must be signed in to change notification settings - Fork 130
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wip: migrate climb page to next13 structure
- Loading branch information
Showing
10 changed files
with
241 additions
and
32 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
56 changes: 56 additions & 0 deletions
56
src/app/(default)/climb/[[...slug]]/components/ClimbData.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,56 @@ | ||
import { ArrowsVertical } from '@phosphor-icons/react/dist/ssr' | ||
|
||
// import RouteGradeChip from '@/components/ui/RouteGradeChip' | ||
import RouteTypeChips from '@/components/ui/RouteTypeChips' | ||
import { ArticleLastUpdate } from '@/components/edit/ArticleLastUpdate' | ||
import { Climb } from '@/js/types' | ||
|
||
export const ClimbData: React.FC<Climb> = (props) => { | ||
const { name, type, safety, length, grades, fa: legacyFA, authorMetadata } = props | ||
console.log(safety, grades) | ||
return ( | ||
<> | ||
<h1 className='text-4xl md:text-5xl mr-10'> | ||
{name} | ||
</h1> | ||
<div className='mt-6'> | ||
<div className='flex items-center space-x-2 w-full'> | ||
{/* {gradeStr != null && ( | ||
<RouteGradeChip gradeStr={gradeStr} safety={safety} /> | ||
)} */} | ||
<RouteTypeChips type={type} /> | ||
</div> | ||
|
||
{length !== -1 && ( | ||
<div className='mt-6 inline-flex items-center justify-left border-2 border-neutral/80 rounded'> | ||
<ArrowsVertical className='h-5 w-5' /> | ||
<span className='bg-neutral/80 text-base-100 px-2 text-sm'>{length}m</span> | ||
</div> | ||
)} | ||
{/* {editMode && <TotalLengthInput />} */} | ||
|
||
<div className='mt-6'> | ||
<div className='text-sm font-medium text-base-content'>{trimLegacyFA(legacyFA)}</div> | ||
</div> | ||
|
||
{(authorMetadata.createdAt != null || authorMetadata.updatedAt != null) && ( | ||
<div className='mt-8 border-t border-b'> | ||
<ArticleLastUpdate {...authorMetadata} /> | ||
</div> | ||
)} | ||
|
||
{/* {!editMode && ( | ||
<div className='mt-8'> | ||
<TickButton climbId={climbId} name={name} grade={yds} /> | ||
</div> | ||
)} */} | ||
</div> | ||
</> | ||
) | ||
} | ||
|
||
const trimLegacyFA = (s: string): string => { | ||
if (s == null || s.trim() === '') return 'FA Unknown' | ||
if (s.startsWith('FA')) return s | ||
return 'FA ' + s | ||
} |
26 changes: 26 additions & 0 deletions
26
src/app/(default)/climb/[[...slug]]/components/ContentBlock.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,26 @@ | ||
import { Climb } from '@/js/types' | ||
|
||
export const ContentBlock: React.FC<Pick<Climb, 'content'>> = ({ content: { description, location, protection } }) => { | ||
return ( | ||
<> | ||
<div className='mb-3 flex justify-between items-center'> | ||
<h3>Description</h3> | ||
</div> | ||
{description} | ||
|
||
{(location?.trim() !== '') && ( | ||
<> | ||
<h3 className='mb-3 mt-6'>Location</h3> | ||
{location} | ||
</> | ||
)} | ||
|
||
{(protection?.trim() !== '') && ( | ||
<> | ||
<h3 className='mb-3 mt-6'>Protection</h3> | ||
{protection} | ||
</> | ||
)} | ||
</> | ||
) | ||
} |
29 changes: 29 additions & 0 deletions
29
src/app/(default)/climb/[[...slug]]/components/SiblingClimbs.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,29 @@ | ||
import { ClimbList } from '@/app/(default)/editArea/[slug]/general/components/climb/ClimbListForm' | ||
import { AreaType } from '@/js/types' | ||
|
||
/** | ||
* Show sibling climbs | ||
*/ | ||
export const SiblingClimbs: React.FC<{ parentArea: AreaType, climbId: string }> = ({ | ||
parentArea, | ||
climbId | ||
}) => { | ||
return ( | ||
<> | ||
<h4> | ||
Routes in{' '} | ||
{parentArea.areaName.includes(', The') | ||
? 'The '.concat(parentArea.areaName.slice(0, -5)) | ||
: parentArea.areaName} | ||
</h4> | ||
<hr className='mt-2 mb-2 border-1 border-base-content' /> | ||
<ClimbList | ||
gradeContext={parentArea.gradeContext} | ||
climbs={parentArea.climbs} | ||
areaMetadata={parentArea.metadata} | ||
routePageId={climbId} | ||
editMode={false} | ||
/> | ||
</> | ||
) | ||
} |
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,72 @@ | ||
import { notFound } from 'next/navigation' | ||
|
||
import { AreaCrumbs } from '@/components/breadcrumbs/AreaCrumbs' | ||
import { AreaPageContainer } from '../../components/ui/AreaPageContainer' | ||
import PhotoMontage, { UploadPhotoCTA } from '@/components/media/PhotoMontage' | ||
import { StickyHeaderContainer } from '../../components/ui/StickyHeaderContainer' | ||
import { parseUuidAsFirstParam } from '@/js/utils' | ||
import { PageWithCatchAllUuidProps } from '@/js/types/pages' | ||
import { getClimbById } from '@/js/graphql/api' | ||
import { ClimbData } from './components/ClimbData' | ||
import { ContentBlock } from './components/ContentBlock' | ||
import { Summary } from '../../components/ui/Summary' | ||
import { SiblingClimbs } from './components/SiblingClimbs' | ||
import { LazyAreaMap } from '@/components/maps/AreaMap' | ||
|
||
export default async function Page ({ params }: PageWithCatchAllUuidProps): Promise<any> { | ||
const climbId = parseUuidAsFirstParam({ params }) | ||
const climb = await getClimbById(climbId) | ||
if (climb == null) { | ||
notFound() | ||
} | ||
|
||
const photoList = climb.media | ||
|
||
const { | ||
id, ancestors, pathTokens | ||
} = climb | ||
return ( | ||
<AreaPageContainer | ||
photoGallery={ | ||
photoList.length === 0 | ||
? <UploadPhotoCTA /> | ||
: <PhotoMontage photoList={photoList} /> | ||
} | ||
// pageActions={<AreaPageActions areaName={areaName} uuid={uuid} />} | ||
breadcrumbs={ | ||
<StickyHeaderContainer> | ||
<AreaCrumbs pathTokens={pathTokens} ancestors={ancestors} /> | ||
</StickyHeaderContainer> | ||
} | ||
summary={{ | ||
left: <ClimbData {...climb} />, | ||
right: <ContentBlock content={climb.content} /> | ||
}} | ||
map={( | ||
<LazyAreaMap | ||
focused={null} | ||
selected={climb.parent.id} | ||
subAreas={[]} | ||
area={climb.parent} | ||
/>)} | ||
mapContainerClass='block lg:hidden h-[90vh] w-full' | ||
> | ||
<hr className='border-1 my-8' /> | ||
<Summary | ||
columns={{ | ||
left: <SiblingClimbs parentArea={climb.parent} climbId={id} />, | ||
right: ( | ||
<div className='hidden lg:min-h-[500px] lg:h-full lg:block lg:relative'> | ||
<LazyAreaMap | ||
focused={null} | ||
selected={climb.parent.id} | ||
subAreas={[]} | ||
area={climb.parent} | ||
/> | ||
</div>) | ||
}} | ||
/> | ||
<div className='mt-16' /> | ||
</AreaPageContainer> | ||
) | ||
} |
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
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,7 @@ | ||
export interface PageSlugType { | ||
slug: string [] | ||
} | ||
|
||
export interface PageWithCatchAllUuidProps { | ||
params: PageSlugType | ||
} |
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