This repository was archived by the owner on Sep 11, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 819
Open map in a dialog when it is clicked #7465
Merged
andybalaam
merged 10 commits into
develop
from
psf-618-expand-location-on-timeline-when-clicked
Jan 7, 2022
+287
−68
Merged
Changes from 4 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
0bed0f6
Prevent panning and zooming of map on timeline
andybalaam 3a8099d
Show error in timeline when map fails to load
andybalaam 84990c5
Open map in a dialog when it is clicked
andybalaam e3fc6a2
Fix lint errors
andybalaam f49da8b
Provide a colour for the external dialog close button that is visible…
andybalaam cee37d1
Location map size -> 80vw/vh
andybalaam a5991af
Prevent dialog styling affecting map attribution button using CSS
andybalaam 1e1efcf
Correct selectors for not(.maplibregl)
andybalaam dc66856
Merge develop into psf-618-expand-location-on-timeline-when-clicked (…
andybalaam 046ac90
Fix bad merge
andybalaam File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 @@ | ||
/* | ||
Copyright 2022 The Matrix.org Foundation C.I.C. | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
.mx_LocationViewDialog_wrapper .mx_Dialog { | ||
padding: 0px; | ||
|
||
/* Unset contain and position to allow the close button | ||
to appear outside the dialog */ | ||
contain: unset; | ||
position: unset; | ||
} | ||
|
||
.mx_LocationViewDialog { | ||
/* subtract 0.5px to prevent single-pixel margin due to rounding */ | ||
width: calc(79vw - 0.5px); | ||
height: calc(79vh - 0.5px); | ||
overflow: hidden; | ||
|
||
.mx_Dialog_header { | ||
margin: 0px; | ||
padding: 0px; | ||
position: unset; | ||
|
||
.mx_Dialog_title { | ||
display: none; | ||
} | ||
|
||
.mx_Dialog_cancelButton { | ||
z-index: 4010; | ||
position: absolute; | ||
right: 5vw; | ||
top: 5vh; | ||
width: 20px; | ||
height: 20px; | ||
background-color: $background; | ||
} | ||
} | ||
|
||
.mx_MLocationBody .mx_MLocationBody_map { | ||
width: 79vw; | ||
height: 79vh; | ||
andybalaam marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
} |
This file contains hidden or 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,92 @@ | ||
/* | ||
Copyright 2022 The Matrix.org Foundation C.I.C. | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
import React from 'react'; | ||
import { MatrixEvent } from 'matrix-js-sdk/src/models/event'; | ||
|
||
import { replaceableComponent } from "../../../utils/replaceableComponent"; | ||
import BaseDialog from "../dialogs/BaseDialog"; | ||
import { IDialogProps } from "../dialogs/IDialogProps"; | ||
import { createMap, LocationBodyContent, locationEventGeoUri, parseGeoUri } from '../messages/MLocationBody'; | ||
|
||
interface IProps extends IDialogProps { | ||
mxEvent: MatrixEvent; | ||
} | ||
|
||
interface IState { | ||
error: Error; | ||
} | ||
|
||
@replaceableComponent("views.location.LocationViewDialog") | ||
export default class LocationViewDialog extends React.Component<IProps, IState> { | ||
private coords: GeolocationCoordinates; | ||
|
||
constructor(props: IProps) { | ||
super(props); | ||
|
||
this.coords = parseGeoUri(locationEventGeoUri(this.props.mxEvent)); | ||
this.state = { | ||
error: undefined, | ||
}; | ||
} | ||
|
||
componentDidMount() { | ||
if (this.state.error) { | ||
return; | ||
} | ||
|
||
createMap( | ||
this.coords, | ||
true, | ||
this.getBodyId(), | ||
this.getMarkerId(), | ||
(e: Error) => this.setState({ error: e }), | ||
); | ||
|
||
// Set class mx_Dialog_nonDialogButton on all buttons inside | ||
// the map container. This prevents our CSS from styling the | ||
// attribution button as if it were a dialog submit/cancel button. | ||
const container: Element = document.getElementById(this.getBodyId()); | ||
container.querySelectorAll("button").forEach( | ||
(b: Element) => b.classList.add("mx_Dialog_nonDialogButton"), | ||
); | ||
andybalaam marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
private getBodyId = () => { | ||
return `mx_LocationViewDialog_${this.props.mxEvent.getId()}`; | ||
}; | ||
|
||
private getMarkerId = () => { | ||
return `mx_MLocationViewDialog_marker_${this.props.mxEvent.getId()}`; | ||
}; | ||
|
||
render() { | ||
return ( | ||
<BaseDialog | ||
className='mx_LocationViewDialog' | ||
onFinished={this.props.onFinished} | ||
fixedWidth={false} | ||
> | ||
<LocationBodyContent | ||
mxEvent={this.props.mxEvent} | ||
bodyId={this.getBodyId()} | ||
markerId={this.getMarkerId()} | ||
error={this.state.error} | ||
/> | ||
</BaseDialog> | ||
); | ||
} | ||
} |
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.