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.
feat: Neighboring (Left/Right) route navigation (#1068)
* feat: add neighboring route navagation
- Loading branch information
Showing
2 changed files
with
54 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import Grade from '@/js/grades/Grade' | ||
import { AreaType, Climb } from '@/js/types' | ||
import { removeTypenameFromDisciplines } from '@/js/utils' | ||
|
||
import clx from 'classnames' | ||
|
||
interface NeighboringRoutesNavProps { | ||
climbs: Array<Climb | null> | ||
parentArea: AreaType | ||
} | ||
|
||
export const NeighboringRoutesNav = ({ climbs, parentArea }: NeighboringRoutesNavProps): JSX.Element => { | ||
return ( | ||
<div className={clx('flex flex-row', (climbs[0] == null) ? 'justify-end' : 'justify-between')}> | ||
{climbs.map((climb, index) => { | ||
if (climb == null) { return ('') } | ||
const sanitizedDisciplines = removeTypenameFromDisciplines(climb.type) | ||
const gradeStr = new Grade( | ||
parentArea.gradeContext, | ||
climb.grades, | ||
sanitizedDisciplines, | ||
parentArea.metadata.isBoulder | ||
).toString() | ||
return ( | ||
<NeighboringRoute key={climb.id} climb={climb} gradeStr={gradeStr} isLeftRoute={index === 0} /> | ||
) | ||
})} | ||
</div> | ||
) | ||
} | ||
|
||
const NeighboringRoute: React.FC<{ climb: Climb, gradeStr: String | undefined, isLeftRoute: boolean }> = ({ climb, gradeStr, isLeftRoute }) => { | ||
const url = `/climbs/${climb.id}` | ||
const strictlySport = (climb.type?.sport ?? false) && | ||
!((climb.type?.trad ?? false) || (climb.type?.aid ?? false)) | ||
return ( | ||
<a className={clx('flex items-center', isLeftRoute ? 'flex-row' : ' flex-row-reverse')} href={url}> | ||
<div className={ | ||
clx('rounded-full h-6 w-6 grid place-content-center text-sm text-neutral-content flex-shrink-0', | ||
strictlySport ? 'bg-sport-climb-cue' : 'bg-neutral') | ||
} | ||
> | ||
{isLeftRoute ? '<' : '>'} | ||
</div> | ||
<div className='flex flex-col content-start ml-4 mr-4'> | ||
<div>{climb.name}</div> | ||
<div className='text-xs '>{gradeStr}</div> | ||
</div> | ||
</a> | ||
) | ||
} |
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
75ccd5e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
open-tacos – ./
tacos.openbeta.io
openbeta.io
open-tacos-openbeta-dev.vercel.app
openclimbmap.com
open-tacos-git-develop-openbeta-dev.vercel.app
www.openbeta.io