From e8bbd77af259c891a19429de6345b8cbb42eaa15 Mon Sep 17 00:00:00 2001 From: Joao Heringer Date: Wed, 5 Feb 2025 17:08:01 -0300 Subject: [PATCH 1/4] Show Calendly in Contacts if available --- web/packages/hovercards/playground/core.ts | 7 +++++++ web/packages/hovercards/src/core.ts | 8 ++++++++ 2 files changed, 15 insertions(+) diff --git a/web/packages/hovercards/playground/core.ts b/web/packages/hovercards/playground/core.ts index ffbc83a..30f5e34 100644 --- a/web/packages/hovercards/playground/core.ts +++ b/web/packages/hovercards/playground/core.ts @@ -48,6 +48,13 @@ addEventListener( 'DOMContentLoaded', () => { url: 'https://instagram.com/jc.heringer', isHidden: false, }, + { + type: 'calendly', + label: 'Calendly', + icon: 'https://gravatar.com/icons/calendly.svg', + url: 'https://calendly.com/joao-heringer', + isHidden: true, + }, { type: 'wordpress', label: 'WordPress', diff --git a/web/packages/hovercards/src/core.ts b/web/packages/hovercards/src/core.ts index 1050581..5204f11 100644 --- a/web/packages/hovercards/src/core.ts +++ b/web/packages/hovercards/src/core.ts @@ -27,6 +27,7 @@ export type ContactInfo = Partial< { email: string; contact_form: string; calendar: string; + calendly: string; } >; export interface PaymentLink { @@ -292,6 +293,11 @@ export default class Hovercards { const hovercard = dc.createElement( 'div' ); hovercard.className = `gravatar-hovercard${ additionalClass ? ` ${ additionalClass }` : '' }`; + const calendly = verifiedAccounts.find( ( l ) => l.type === 'calendly' && ! l.isHidden ); + if ( contactInfo && calendly ) { + contactInfo.calendly = calendly.url; + } + const trackedProfileUrl = escUrl( addQueryArg( profileUrl, 'utm_source', 'hovercard' ) ); const username = escHtml( displayName ); const isEditProfile = ! description && myHash === hash; @@ -510,6 +516,7 @@ export default class Hovercards { cell_phone: 'icons/mobile-phone.svg', contact_form: 'icons/envelope.svg', calendar: 'icons/calendar.svg', + calendly: 'icons/calendly.svg', }; const getUrl = ( type: string, value: string ) => { @@ -518,6 +525,7 @@ export default class Hovercards { return `mailto:${ value }`; case 'contact_form': case 'calendar': + case 'calendly': return value.startsWith( 'http' ) ? value : `https://${ value }`; default: return null; From e8dee924570b5b1e62a83545d3be03169611f9c9 Mon Sep 17 00:00:00 2001 From: Joao Heringer Date: Wed, 5 Feb 2025 17:19:28 -0300 Subject: [PATCH 2/4] Playground data --- web/packages/hovercards/playground/core.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/web/packages/hovercards/playground/core.ts b/web/packages/hovercards/playground/core.ts index 30f5e34..2b02bc9 100644 --- a/web/packages/hovercards/playground/core.ts +++ b/web/packages/hovercards/playground/core.ts @@ -53,7 +53,7 @@ addEventListener( 'DOMContentLoaded', () => { label: 'Calendly', icon: 'https://gravatar.com/icons/calendly.svg', url: 'https://calendly.com/joao-heringer', - isHidden: true, + isHidden: false, }, { type: 'wordpress', @@ -64,12 +64,12 @@ addEventListener( 'DOMContentLoaded', () => { }, ], contactInfo: { - home_phone: '', - work_phone: '', - cell_phone: '12312312312', - email: 'email@email.com', - contact_form: '', - calendar: 'https://calendar.com', + // home_phone: '', + // work_phone: '', + // cell_phone: '12312312312', + // email: 'email@email.com', + // contact_form: '', + //calendar: 'https://calendar.com', }, payments: { links: [], From 487439fb4ad4bf2610c04d8b237bd5f8cdfbafc5 Mon Sep 17 00:00:00 2001 From: Joao Heringer Date: Wed, 5 Feb 2025 17:20:13 -0300 Subject: [PATCH 3/4] Playground data --- web/packages/hovercards/playground/core.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/web/packages/hovercards/playground/core.ts b/web/packages/hovercards/playground/core.ts index 2b02bc9..411180e 100644 --- a/web/packages/hovercards/playground/core.ts +++ b/web/packages/hovercards/playground/core.ts @@ -64,12 +64,12 @@ addEventListener( 'DOMContentLoaded', () => { }, ], contactInfo: { - // home_phone: '', - // work_phone: '', - // cell_phone: '12312312312', - // email: 'email@email.com', - // contact_form: '', - //calendar: 'https://calendar.com', + home_phone: '', + work_phone: '', + cell_phone: '12312312312', + email: 'email@email.com', + contact_form: '', + calendar: 'https://calendar.com', }, payments: { links: [], From b952a143a0e65265a3257fb49d09267ee2660dbb Mon Sep 17 00:00:00 2001 From: Joao Heringer Date: Thu, 6 Feb 2025 10:49:13 -0300 Subject: [PATCH 4/4] Use better variable name --- web/packages/hovercards/src/core.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/packages/hovercards/src/core.ts b/web/packages/hovercards/src/core.ts index 5204f11..7d12f10 100644 --- a/web/packages/hovercards/src/core.ts +++ b/web/packages/hovercards/src/core.ts @@ -293,7 +293,7 @@ export default class Hovercards { const hovercard = dc.createElement( 'div' ); hovercard.className = `gravatar-hovercard${ additionalClass ? ` ${ additionalClass }` : '' }`; - const calendly = verifiedAccounts.find( ( l ) => l.type === 'calendly' && ! l.isHidden ); + const calendly = verifiedAccounts.find( ( account ) => account.type === 'calendly' && ! account.isHidden ); if ( contactInfo && calendly ) { contactInfo.calendly = calendly.url; }