-
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MemberFeatures: show all members for some relations (#228)
- Loading branch information
Showing
7 changed files
with
128 additions
and
23 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
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,73 @@ | ||
import React from 'react'; | ||
import { Box, Typography } from '@material-ui/core'; | ||
import Router from 'next/router'; | ||
import { getOsmappLink, getUrlOsmId } from '../../services/helpers'; | ||
import { useFeatureContext } from '../utils/FeatureContext'; | ||
import { Feature } from '../../services/types'; | ||
import { getLabel } from '../../helpers/featureLabel'; | ||
import { useUserThemeContext } from '../../helpers/theme'; | ||
import { useMobileMode } from '../helpers'; | ||
import Maki from '../utils/Maki'; | ||
|
||
const Item = ({ feature }: { feature: Feature }) => { | ||
const { currentTheme } = useUserThemeContext(); | ||
const mobileMode = useMobileMode(); | ||
const { setPreview } = useFeatureContext(); | ||
const { properties, tags, osmMeta } = feature; | ||
const handleClick = (e) => { | ||
e.preventDefault(); | ||
setPreview(null); | ||
Router.push(`/${getUrlOsmId(osmMeta)}${window.location.hash}`); | ||
}; | ||
const handleHover = () => | ||
feature.center && setPreview({ ...feature, noPreviewButton: true }); | ||
|
||
return ( | ||
<li> | ||
<a | ||
href={`/${getUrlOsmId(osmMeta)}`} | ||
onClick={handleClick} | ||
onMouseEnter={mobileMode ? undefined : handleHover} | ||
onMouseLeave={() => setPreview(null)} | ||
> | ||
<Maki | ||
ico={properties.class} | ||
title={`${Object.keys(tags).length} keys / ${ | ||
properties.class ?? '' | ||
} / ${properties.subclass}`} | ||
invert={currentTheme === 'dark'} | ||
/> | ||
{getLabel(feature)} | ||
</a> | ||
</li> | ||
); | ||
}; | ||
|
||
export const MemberFeatures = () => { | ||
const { | ||
feature: { memberFeatures, tags }, | ||
} = useFeatureContext(); | ||
|
||
if (!memberFeatures?.length) { | ||
return null; | ||
} | ||
|
||
const heading = | ||
tags.climbing === 'crag' | ||
? 'Routes' | ||
: tags.climbing === 'area' | ||
? 'Crags' | ||
: 'Subitems'; | ||
return ( | ||
<Box mt={4}> | ||
<Typography variant="overline" display="block" color="textSecondary"> | ||
{heading} | ||
</Typography> | ||
<ul> | ||
{memberFeatures.map((item) => ( | ||
<Item key={getOsmappLink(item)} feature={item} /> | ||
))} | ||
</ul> | ||
</Box> | ||
); | ||
}; |
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
fa4d465
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:
osmapp – ./
osmapp.vercel.app
osmapp.org
osmapp-osm-app-team.vercel.app
osmapp-git-master-osm-app-team.vercel.app