Skip to content

Commit

Permalink
style: Webpage box link in marker
Browse files Browse the repository at this point in the history
  • Loading branch information
purplebugs committed Nov 6, 2024
1 parent 3504c94 commit aa95f24
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 1 deletion.
37 changes: 36 additions & 1 deletion src/alpaca-map-marker.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ export default class AlpacaMapMarker extends LitElement {
count: { type: Number },
city: { type: String },
address: { type: String },
url_full: { type: String },
url_pretty: { type: String },
directions: { type: String },
highlight: {
type: String,
Expand All @@ -30,6 +32,8 @@ export default class AlpacaMapMarker extends LitElement {
this.count;
this.city;
this.address;
this.url_full;
this.url_pretty;
this.directions;
this.highlight = false;
}
Expand Down Expand Up @@ -62,6 +66,37 @@ export default class AlpacaMapMarker extends LitElement {
return html`${nothing}`;
}

renderLinkToWebPage() {
if (this.url_full === null || this.url_full === undefined) {
return html`${nothing}`;
}

if (this.url_pretty === null || this.url_pretty === undefined) {
return html`${nothing}`;
}

return html`
<a
href="${this.url_full}"
target="_blank"
rel="noreferrer"
title="${this.url_pretty}"
onclick="event.stopPropagation()"
>
<div class="farm-marker-link">
<address class="webpage">
<alpaca-map-icon icon="car" class="icon"></alpaca-map-icon
><span class="text">Webpage</span
><alpaca-map-icon
icon="arrowUpRightFromSquare"
class="icon link-arrow"
></alpaca-map-icon>
</address>
</div>
</a>
`;
}

createRenderRoot() {
// Turns off shadow DOM.
// Since AlpacaMapMarker is not used externally, only by AlpacaMap then we want to inherit all styling, so turn off shadow DOM.
Expand Down Expand Up @@ -91,7 +126,7 @@ export default class AlpacaMapMarker extends LitElement {
<address>${this.address}</address>
</div>
${this.renderLinkToFarmPage()}
${this.renderLinkToFarmPage()} ${this.renderLinkToWebPage()}
<a
href="${this.directions}"
Expand Down
4 changes: 4 additions & 0 deletions src/alpaca-map.js
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,10 @@ export default class AlpacaMap extends LitElement {
"address",
farm?.location?.google?.formatted_address
);

content.setAttribute("url_full", farm?.url?.full);
content.setAttribute("url_pretty", farm?.url?.pretty);

content.setAttribute(
"directions",
farm?.location?.google?.directions_url_href
Expand Down
1 change: 1 addition & 0 deletions src/styles-map-marker.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ export default css`
.city address,
.farm-info,
.webpage,
.directions {
display: flex;
flex-basis: auto;
Expand Down

0 comments on commit aa95f24

Please sign in to comment.