Skip to content

Commit 452892c

Browse files
authored
Merge pull request #158 from Automattic/update/handle-calendly
Show Calendly in Contacts if available
2 parents 7be807e + b952a14 commit 452892c

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

web/packages/hovercards/playground/core.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,13 @@ addEventListener( 'DOMContentLoaded', () => {
4848
url: 'https://instagram.com/jc.heringer',
4949
isHidden: false,
5050
},
51+
{
52+
type: 'calendly',
53+
label: 'Calendly',
54+
icon: 'https://gravatar.com/icons/calendly.svg',
55+
url: 'https://calendly.com/joao-heringer',
56+
isHidden: false,
57+
},
5158
{
5259
type: 'wordpress',
5360
label: 'WordPress',

web/packages/hovercards/src/core.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export type ContactInfo = Partial< {
2727
email: string;
2828
contact_form: string;
2929
calendar: string;
30+
calendly: string;
3031
} >;
3132

3233
export interface PaymentLink {
@@ -292,6 +293,11 @@ export default class Hovercards {
292293
const hovercard = dc.createElement( 'div' );
293294
hovercard.className = `gravatar-hovercard${ additionalClass ? ` ${ additionalClass }` : '' }`;
294295

296+
const calendly = verifiedAccounts.find( ( account ) => account.type === 'calendly' && ! account.isHidden );
297+
if ( contactInfo && calendly ) {
298+
contactInfo.calendly = calendly.url;
299+
}
300+
295301
const trackedProfileUrl = escUrl( addQueryArg( profileUrl, 'utm_source', 'hovercard' ) );
296302
const username = escHtml( displayName );
297303
const isEditProfile = ! description && myHash === hash;
@@ -512,6 +518,7 @@ export default class Hovercards {
512518
cell_phone: 'icons/mobile-phone.svg',
513519
contact_form: 'icons/envelope.svg',
514520
calendar: 'icons/calendar.svg',
521+
calendly: 'icons/calendly.svg',
515522
};
516523

517524
const getUrl = ( type: string, value: string ) => {
@@ -520,6 +527,7 @@ export default class Hovercards {
520527
return `mailto:${ value }`;
521528
case 'contact_form':
522529
case 'calendar':
530+
case 'calendly':
523531
return value.startsWith( 'http' ) ? value : `https://${ value }`;
524532
default:
525533
return null;

0 commit comments

Comments
 (0)