-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
projects: add project tiles for map including a fixed overlay for mob…
…ile view
- Loading branch information
Showing
9 changed files
with
211 additions
and
22 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,6 +55,7 @@ | |
flex: 1; | ||
} | ||
|
||
.projects-list__map, | ||
.modul-geomap, | ||
.geomap-main, | ||
.geomap-container, | ||
|
54 changes: 53 additions & 1 deletion
54
meinberlin/assets/scss/components_user_facing/_projects_map.scss
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,3 +1,55 @@ | ||
.projects-map { | ||
height: 100%; | ||
height: 100%; | ||
|
||
.leaflet-bottom.leaflet-left { | ||
position: static; | ||
} | ||
} | ||
|
||
.project-overlay-control { | ||
background: $white; | ||
position: absolute; | ||
bottom: 1.5em; | ||
left: 1.5em; | ||
right: 1.5em; | ||
z-index: 1000; | ||
padding: 0.5em; | ||
|
||
@media screen and (min-width: $breakpoint-tablet) { | ||
display: none; | ||
} | ||
|
||
.project-tile__image { | ||
height: 175px; | ||
} | ||
|
||
a { | ||
color: $text-base; | ||
} | ||
} | ||
|
||
.projects-map__popup { | ||
display: none; | ||
|
||
@media screen and (min-width: $breakpoint-tablet) { | ||
display: block; | ||
|
||
} | ||
|
||
.leaflet-popup-content-wrapper { | ||
border-radius: 0; | ||
} | ||
|
||
.leaflet-popup-content { | ||
margin: 1em; | ||
} | ||
|
||
.leaflet-popup-content a { | ||
color: $text-base; | ||
} | ||
|
||
.leaflet-popup-tip-container { | ||
display: none; | ||
} | ||
} | ||
|
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,76 @@ | ||
import React from 'react' | ||
import L from 'leaflet' | ||
import ReactDOM from 'react-dom' | ||
import { | ||
createContainerComponent, | ||
createControlHook, | ||
createElementHook, | ||
createElementObject, | ||
extendContext | ||
} from '@react-leaflet/core' | ||
import ProjectTile from './ProjectTile' | ||
|
||
// Create the custom control class | ||
const ProjectMapOverlayControl = L.Control.extend({ | ||
options: { | ||
position: 'bottomleft' | ||
}, | ||
|
||
onAdd: function (map) { | ||
this._map = map | ||
this._container = L.DomUtil.create('div', 'project-overlay-control') | ||
|
||
if (this._content) { | ||
this._container.appendChild(this._content) | ||
} | ||
|
||
L.DomEvent.disableClickPropagation(this._container) | ||
L.DomEvent.disableScrollPropagation(this._container) | ||
|
||
return this._container | ||
}, | ||
|
||
onRemove: function (map) { | ||
if (this._container) { | ||
ReactDOM.unmountComponentAtNode(this._container) | ||
L.DomUtil.remove(this._container) | ||
this._container = null | ||
} | ||
}, | ||
|
||
addTo: function (map) { | ||
L.Control.prototype.addTo.call(this, map) | ||
this._container.classList.remove('leaflet-control') | ||
return this | ||
} | ||
}) | ||
|
||
const useProjectMapOverlayElement = createElementHook((props, context) => { | ||
const { position, children } = props | ||
|
||
const control = new ProjectMapOverlayControl({ position }) | ||
|
||
// Create a div for React content | ||
const contentDiv = L.DomUtil.create('div') | ||
ReactDOM.render(children, contentDiv) | ||
control._content = contentDiv | ||
|
||
return createElementObject(control, extendContext(context, { | ||
overlayContainer: control | ||
})) | ||
}) | ||
|
||
const useProjectMapOverlay = createControlHook(useProjectMapOverlayElement) | ||
const ProjectMapOverlayContainer = createContainerComponent(useProjectMapOverlay) | ||
|
||
const ProjectMapOverlay = ({ project, topicChoices, position = 'bottomleft', ...props }) => { | ||
return project | ||
? ( | ||
<ProjectMapOverlayContainer position={position} {...props}> | ||
<ProjectTile project={project} isHorizontal isMapTile topicChoices={topicChoices} /> | ||
</ProjectMapOverlayContainer> | ||
) | ||
: null | ||
} | ||
|
||
export default ProjectMapOverlay |
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