Hey @DJ_Corbett – following up with a solution that I think should get you moving in the right direction.
Phone Clickable on Desktop and Mobile
To make Phone clickable on Desktop and Mobile, you can override your card’s template.hbs file. Today in the Theme, we have different styling and actions on desktop and mobile; so when we override the template, let’s remove the conditional configuration and use a single div for the phone number for both desktop and mobile (near line 132):
{{#*inline 'phone'}}
{{#if card.phone}}
<div class="HitchhikerProfessionalLocation-phone">
<a class="HitchhikerProfessionalLocation-desktopMobile"
href="tel:{{card.phone}}"
data-eventtype="TAP_TO_CALL"
data-eventoptions='{{json card.phoneEventOptions}}'
target="_top">
{{card.phone}}
</a>
</div>
{{/if}}
{{/inline}}
You should then target this new class and style it as needed in your answers.scss
file.
Address Clickable on Desktop and Mobile
You will need to add a function to your card’s component.js file which you can then call in your template.hbs file.
Within your component.js dataForRender
, add the below function (repurposed from our standard Get Directions formatter):
const addr = profile['address'];
if (!addr) {
return '';
}
const line2 = addr.line2 ? ` ${addr.line2},` : ``;
const region = addr.region ? ` ${addr.region}` : ``;
const rawQuery = `${addr.line1},${line2} ${addr.city},${region} ${addr.postalCode} ${addr.countryCode}`;
const query = encodeURIComponent(rawQuery);
let directionsUrl = `https://www.google.com/maps/search/?api=1&query=${query}&output=classic`;
if (profile.googlePlaceId) {
directionsUrl += `&query_place_id=${profile.googlePlaceId}`;
}
And within return{}
mappings below the function, make sure you add in getDirectionsUrl
so that we can leverage it in the template.hbs file:
directionsUrl,
Lastly, in your template.hbs file, we can set up the href and reference card.directionsUrl
near line 72:
{{#*inline 'address'}}
{{#if card.address}}
<div class="HitchhikerProfessionalLocation-address">
<a class="HitchhikerProfessionalLocation-addressClick"
href={{card.directionsUrl}}
data-eventtype="DRIVING_DIRECTIONS"
data-eventoptions='{{json card.EventOptions}}'
target="_blank">
{{{card.address}}}
</a>
</div>
{{/if}}
{{/inline}}
Similar to the clickable phone number, you’ll want to style a hover state in answers.scss
for the address to make it clear to the user that it’s clickable.
Hope this helps!
Sam