generated from taylorbryant/gatsby-starter-tailwind
-
-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
330 additions
and
124 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
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,25 @@ | ||
import { DataLayersDisplayState } from './GlobalMap' | ||
|
||
export interface MapToolbarProps { | ||
layerState: DataLayersDisplayState | ||
onChange: (newLayerState: DataLayersDisplayState) => void | ||
} | ||
|
||
/** | ||
* Toolbar for filtering/toggling data layers | ||
*/ | ||
export const MapToolbar: React.FC<MapToolbarProps> = ({ onChange, layerState }) => { | ||
const { cragGroups } = layerState | ||
return ( | ||
<div className='absolute top-20 md:top-6 left-0 w-screen flex flex-col items-center justify-center'> | ||
<ul className='p-2.5 flex items-center gap-2 bg-base-200 rounded-box shadow-md'> | ||
<li className='flex items-center gap-2'> | ||
<input | ||
type='checkbox' className='checkbox' checked={cragGroups} | ||
onChange={() => onChange({ ...layerState, cragGroups: !cragGroups })} | ||
/> Crag groups | ||
</li> | ||
</ul> | ||
</div> | ||
) | ||
} |
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 |
---|---|---|
@@ -1,45 +1,88 @@ | ||
import { Source, Layer } from 'react-map-gl' | ||
import { DataLayersDisplayState } from './GlobalMap' | ||
|
||
interface OBCustomLayersProps { | ||
layersState: DataLayersDisplayState | ||
} | ||
/** | ||
* OpenBeta custom map tiles. | ||
* - Crags: crag markers and labels | ||
* - Crag groups: polygon boundaries for crag groups (TBD) | ||
*/ | ||
export const OBCustomLayers: React.FC = () => { | ||
export const OBCustomLayers: React.FC<OBCustomLayersProps> = ({ layersState }) => { | ||
const { cragGroups } = layersState | ||
return ( | ||
<Source | ||
id='crags-source' // can be any unique id | ||
type='vector' | ||
tiles={[ | ||
'https://maptiles.openbeta.io/crags/{z}/{x}/{y}.pbf' | ||
]} | ||
attribution='© OpenBeta contributors' | ||
> | ||
<Layer | ||
id='crags' // can be any unique id. Must match the id in ReactMapGL.interactiveLayerIds | ||
type='symbol' | ||
source-layer='crags' // source-layer is the layer name in the vector tileset | ||
layout={{ | ||
'icon-anchor': 'center', | ||
'text-field': ['get', 'name'], | ||
'text-size': 12, | ||
'text-font': ['Segoe UI', 'Roboto', 'Ubuntu', 'Helvetica Neue', 'Oxygen', 'Cantarell', 'sans-serif'], | ||
'icon-image': 'circle-dot', | ||
'icon-size': ['interpolate', ['linear'], ['zoom'], 8, 0.5, 18, 1], | ||
'text-variable-anchor': ['bottom', 'top', 'left', 'right'], | ||
'text-radial-offset': ['interpolate', ['linear'], ['zoom'], 6, 0.25, 16, 1], | ||
'text-optional': true, | ||
'icon-padding': 8, | ||
'symbol-sort-key': ['match', ['string', ['get', 'media']], ['[]'], 1, 0] | ||
}} | ||
paint={{ | ||
'icon-color': ['match', ['string', ['get', 'media']], ['[]'], '#111827', '#881337'], | ||
'text-halo-blur': 1, | ||
'text-halo-width': 2, | ||
'text-color': ['match', ['string', ['get', 'media']], ['[]'], '#111827', '#881337'], | ||
'text-halo-color': '#f8fafc' | ||
}} | ||
/> | ||
</Source> | ||
<> | ||
<Source | ||
id='crags-source2' // can be any unique id | ||
type='vector' | ||
tiles={[ | ||
'https://maptiles.openbeta.io/crag-groups/{z}/{x}/{y}.pbf' | ||
]} | ||
maxzoom={8} | ||
attribution='© OpenBeta contributors' | ||
> | ||
|
||
<Layer | ||
id='crag-group-boundaries' // can be any unique id. Must match the id in ReactMapGL.interactiveLayerIds | ||
type='line' | ||
source-layer='crag-groups' // source-layer is the layer name in the vector tileset | ||
paint={{ | ||
'line-color': '#ec407a', | ||
'line-width': ['interpolate', ['linear'], ['zoom'], 8, 1, 19, 4], | ||
'line-opacity': 0.8 | ||
}} | ||
layout={{ | ||
visibility: cragGroups ? 'visible' : 'none' | ||
}} | ||
/> | ||
</Source> | ||
<Source | ||
id='crags-source1' // can be any unique id | ||
type='vector' | ||
tiles={[ | ||
'https://maptiles.openbeta.io/crags/{z}/{x}/{y}.pbf' | ||
]} | ||
maxzoom={11} | ||
attribution='© OpenBeta contributors' | ||
> | ||
<Layer | ||
id='crag-markers' // can be any unique id. Must match the id in ReactMapGL.interactiveLayerIds | ||
type='circle' | ||
source-layer='crags' // source-layer is the layer name in the vector tileset | ||
paint={{ | ||
'circle-radius': { stops: [[8, 2], [18, 4]] }, | ||
'circle-color': '#ff6e40', | ||
'circle-blur': 0.2, | ||
'circle-stroke-width': 1, | ||
'circle-stroke-color': '#546e7a', | ||
'circle-stroke-opacity': 0.8 | ||
}} | ||
minzoom={6} | ||
/> | ||
<Layer | ||
id='crag-name-labels' // can be any unique id. Must match the id in ReactMapGL.interactiveLayerIds | ||
type='symbol' | ||
source-layer='crags' // source-layer is the layer name in the vector tileset | ||
layout={{ | ||
'icon-anchor': 'center', | ||
'text-field': ['get', 'name'], | ||
'text-size': { stops: [[8, 10], [12, 12]] }, | ||
'text-font': ['Segoe UI', 'Roboto', 'Ubuntu', 'Helvetica Neue', 'Oxygen', 'Cantarell', 'sans-serif'], | ||
'text-variable-anchor': ['bottom', 'top', 'left', 'right'], | ||
'text-radial-offset': ['interpolate', ['linear'], ['zoom'], 16, 0.5], | ||
'text-optional': true, | ||
'symbol-sort-key': ['match', ['string', ['get', 'media']], ['[]'], 1, 0] | ||
}} | ||
paint={{ | ||
'icon-color': ['match', ['string', ['get', 'media']], ['[]'], '#111827', '#881337'], | ||
'text-halo-blur': 1, | ||
'text-halo-width': 2, | ||
'text-color': ['match', ['string', ['get', 'media']], ['[]'], '#111827', '#881337'], | ||
'text-halo-color': '#f8fafc' | ||
}} | ||
/> | ||
</Source> | ||
</> | ||
) | ||
} |
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,28 @@ | ||
import * as Popover from '@radix-ui/react-popover' | ||
|
||
import { ActiveFeature, CragFeatureProperties, CragGroupFeatureProps } from '../TileTypes' | ||
import { CragPanelContent } from './CragPanelContent' | ||
import { CragGroupPanelContent } from './CragGroupPanelContent' | ||
|
||
/** | ||
* Area info panel | ||
*/ | ||
export const AreaInfoDrawer: React.FC<{ feature: ActiveFeature | null, onClose?: () => void }> = ({ feature, onClose }) => { | ||
if (feature == null) return null | ||
let ContentComponent = null | ||
switch (feature.type) { | ||
case 'crags': | ||
ContentComponent = <CragPanelContent {...(feature.data as CragFeatureProperties)} /> | ||
break | ||
case 'crag-groups': | ||
ContentComponent = <CragGroupPanelContent {...(feature.data as CragGroupFeatureProps)} /> | ||
} | ||
return ( | ||
<Popover.Root open={feature != null}> | ||
<Popover.Anchor className='absolute top-3 left-3 z-50' /> | ||
<Popover.Content align='start' className='hover:outline-none'> | ||
{ContentComponent} | ||
</Popover.Content> | ||
</Popover.Root> | ||
) | ||
} |
Oops, something went wrong.