Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 19 additions & 16 deletions assets/javascripts/discourse/components/user-location.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,24 @@
<div class="location-label">
{{this.userLocation}}
</div>
<div class="map-wrapper">
<button
class="widget-button btn btn-default btn-show-map btn-small btn-icon-text"
type="button"
{{on "click" this.toggleMap}}
>
{{d-icon "far-map"}}
{{#if this.showMapButtonLabel}}
{{this.mapButtonLabel}}
{{#if this.canShowMap}}
<div class="map-wrapper">
<button
class="widget-button btn btn-default btn-show-map btn-small btn-icon-text"
type="button"
{{on "click" this.toggleMap}}
>
{{d-icon "far-map"}}
{{#if this.showMapButtonLabel}}
{{this.mapButtonLabel}}
{{/if}}
</button>

{{#if this.showMap}}
<div class="map-container small">
<LocationsMap @mapType="user" @user={{@user}} />
</div>
{{/if}}
</button>
{{#if this.showMap}}
<div class="map-container small">
<LocationsMap @mapType="user" @user={{@user}} />
</div>
{{/if}}
</div>
</div>
{{/if}}
</div>
4 changes: 4 additions & 0 deletions assets/javascripts/discourse/components/user-location.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ export default class LocationMapComponent extends Component {
return locationText;
}

get canShowMap() {
return !document.querySelector(".leaflet-container");
}

@action
toggleMap() {
this.showMap = !this.showMap;
Expand Down
27 changes: 9 additions & 18 deletions assets/javascripts/discourse/lib/map-utilities.js.es6
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import { emojiUnescape } from "discourse/lib/text";
import DiscourseURL from "discourse/lib/url";
import getURL from "discourse-common/lib/get-url";

const generateMap = function (siteSettings, opts) {
const element = document.createElement("div");
Expand Down Expand Up @@ -129,30 +130,20 @@ const buildMarker = function (
const avatarSize = window.devicePixelRatio > 1 ? "60" : "30";
const userAvatar = rawMarker.options.avatar.replace("{size}", avatarSize);

const markerStyles = `
background-color: dimgrey;
width: 30px;
height: 30px;
display: block;
left: -18px;
top: -0px;
position: relative;
border-radius: 50% 50% 0;
transform: rotate(45deg);
border: 3px solid dimgrey;
z-index: 100;`;
const href = rawMarker.options.routeTo
? getURL(rawMarker.options.routeTo)
: null;

const avatarStyles = `
width: 100%;
border-radius: 50%;
transform: rotate(-45deg);`;
const html = href
? `<a href="${href}" class="avatar-marker" data-user-card="${rawMarker.options.title}"><img src="${userAvatar}" class="avatar"></a>`
: `<span class="avatar-marker" data-user-card="${rawMarker.options.title}"><img src="${userAvatar}" class="avatar"></span>`;

rawMarker.options["icon"] = L.divIcon({
className: "",
iconAnchor: [0, 44],
labelAnchor: [-25, 0],
popupAnchor: [10, -36],
html: `<span style="${markerStyles}" class="avatar-marker"><img src="${userAvatar}" style="${avatarStyles}" class="avatar"></span>`,
html,
});
}
const marker = L.marker(
Expand All @@ -164,7 +155,7 @@ const buildMarker = function (
);

if (rawMarker.options) {
if (rawMarker.options.routeTo) {
if (!avatarMarkerStyle && rawMarker.options.routeTo) {
marker.on("click", () => {
DiscourseURL.routeTo(rawMarker.options.routeTo);
});
Expand Down
23 changes: 20 additions & 3 deletions assets/stylesheets/common/locations.scss
Original file line number Diff line number Diff line change
Expand Up @@ -231,9 +231,26 @@
}

.leaflet-marker-icon {
.avatar-marker .avatar {
background-color: var(--secondary);
border: none !important;
.avatar-marker {
background-color: dimgrey;
width: 30px;
height: 30px;
display: block;
left: -18px;
top: -0px;
position: relative;
border-radius: 50% 50% 0;
transform: rotate(45deg);
border: 3px solid dimgrey;
z-index: 100;

.avatar {
width: 100%;
border-radius: 50%;
transform: rotate(-45deg);
background-color: var(--secondary);
border: none !important;
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion plugin.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true
# name: discourse-locations
# about: Tools for handling locations in Discourse
# version: 6.5.2
# version: 6.6.0
# authors: Angus McLeod, Robert Barrow
# contact_emails: development@pavilion.tech
# url: https://github.com/angusmcleod/discourse-locations
Expand Down