mirror of
https://github.com/element-hq/element-web
synced 2024-11-26 03:05:51 +03:00
Display the user's avatar when they shared their location (#7424)
This commit is contained in:
parent
d25d325387
commit
70dc03552c
3 changed files with 53 additions and 12 deletions
|
@ -14,9 +14,30 @@ See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
.mx_MLocationBody_map {
|
.mx_MLocationBody {
|
||||||
|
.mx_MLocationBody_map {
|
||||||
width: 450px;
|
width: 450px;
|
||||||
height: 300px;
|
height: 300px;
|
||||||
|
|
||||||
border-radius: $timeline-image-border-radius;
|
border-radius: $timeline-image-border-radius;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mx_MLocationBody_markerBorder {
|
||||||
|
width: 31px;
|
||||||
|
height: 31px;
|
||||||
|
border-radius: 50%;
|
||||||
|
background-color: $accent;
|
||||||
|
filter: drop-shadow(0px 3px 5px rgba(0, 0, 0, 0.2));
|
||||||
|
|
||||||
|
.mx_BaseAvatar {
|
||||||
|
margin-top: 2px;
|
||||||
|
margin-left: 2px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.mx_MLocationBody_pointer {
|
||||||
|
position: absolute;
|
||||||
|
bottom: -3px;
|
||||||
|
left: 12px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
3
res/img/location/pointer.svg
Normal file
3
res/img/location/pointer.svg
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
<svg width="9" height="4" viewBox="0 0 9 4" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<path d="M4.5 4L0.602887 0.25L8.39711 0.250001L4.5 4Z" fill="#0DBD8B"/>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 171 B |
|
@ -23,6 +23,7 @@ import SdkConfig from '../../../SdkConfig';
|
||||||
import { replaceableComponent } from "../../../utils/replaceableComponent";
|
import { replaceableComponent } from "../../../utils/replaceableComponent";
|
||||||
import { IBodyProps } from "./IBodyProps";
|
import { IBodyProps } from "./IBodyProps";
|
||||||
import { _t } from '../../../languageHandler';
|
import { _t } from '../../../languageHandler';
|
||||||
|
import MemberAvatar from '../avatars/MemberAvatar';
|
||||||
|
|
||||||
interface IState {
|
interface IState {
|
||||||
error: Error;
|
error: Error;
|
||||||
|
@ -32,7 +33,6 @@ interface IState {
|
||||||
export default class MLocationBody extends React.Component<IBodyProps, IState> {
|
export default class MLocationBody extends React.Component<IBodyProps, IState> {
|
||||||
private map: maplibregl.Map;
|
private map: maplibregl.Map;
|
||||||
private coords: GeolocationCoordinates;
|
private coords: GeolocationCoordinates;
|
||||||
private description: string;
|
|
||||||
|
|
||||||
constructor(props: IBodyProps) {
|
constructor(props: IBodyProps) {
|
||||||
super(props);
|
super(props);
|
||||||
|
@ -49,8 +49,6 @@ export default class MLocationBody extends React.Component<IBodyProps, IState> {
|
||||||
this.state = {
|
this.state = {
|
||||||
error: undefined,
|
error: undefined,
|
||||||
};
|
};
|
||||||
|
|
||||||
this.description = loc?.description ?? content['body'];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
|
@ -65,13 +63,12 @@ export default class MLocationBody extends React.Component<IBodyProps, IState> {
|
||||||
zoom: 13,
|
zoom: 13,
|
||||||
});
|
});
|
||||||
|
|
||||||
new maplibregl.Popup({
|
new maplibregl.Marker({
|
||||||
closeButton: false,
|
element: document.getElementById(this.getMarkerId()),
|
||||||
closeOnClick: false,
|
anchor: 'bottom',
|
||||||
closeOnMove: false,
|
offset: [0, -1],
|
||||||
})
|
})
|
||||||
.setLngLat(coordinates)
|
.setLngLat(coordinates)
|
||||||
.setHTML(this.description)
|
|
||||||
.addTo(this.map);
|
.addTo(this.map);
|
||||||
|
|
||||||
this.map.on('error', (e)=>{
|
this.map.on('error', (e)=>{
|
||||||
|
@ -88,6 +85,10 @@ export default class MLocationBody extends React.Component<IBodyProps, IState> {
|
||||||
return `mx_MLocationBody_${this.props.mxEvent.getId()}`;
|
return `mx_MLocationBody_${this.props.mxEvent.getId()}`;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private getMarkerId = () => {
|
||||||
|
return `mx_MLocationBody_marker_${this.props.mxEvent.getId()}`;
|
||||||
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const error = this.state.error ?
|
const error = this.state.error ?
|
||||||
<div className="mx_EventTile_tileError mx_EventTile_body">
|
<div className="mx_EventTile_tileError mx_EventTile_body">
|
||||||
|
@ -97,6 +98,22 @@ export default class MLocationBody extends React.Component<IBodyProps, IState> {
|
||||||
return <div className="mx_MLocationBody">
|
return <div className="mx_MLocationBody">
|
||||||
<div id={this.getBodyId()} className="mx_MLocationBody_map" />
|
<div id={this.getBodyId()} className="mx_MLocationBody_map" />
|
||||||
{ error }
|
{ error }
|
||||||
|
<div className="mx_MLocationBody_marker" id={this.getMarkerId()}>
|
||||||
|
<div className="mx_MLocationBody_markerBorder">
|
||||||
|
<MemberAvatar
|
||||||
|
member={this.props.mxEvent.sender}
|
||||||
|
width={27}
|
||||||
|
height={27}
|
||||||
|
viewUserOnClick={false}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<img
|
||||||
|
className="mx_MLocationBody_pointer"
|
||||||
|
src={require("../../../../res/img/location/pointer.svg")}
|
||||||
|
width="9"
|
||||||
|
height="5"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
</div>;
|
</div>;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue