From 6347bbabff85c7f8c40eefed65322ee03d9dc2a3 Mon Sep 17 00:00:00 2001 From: Sudeep Hazra Date: Sun, 2 Jun 2024 05:22:54 +0530 Subject: [PATCH] Added signature icons for Medium, GitHub and YouTube (#2484) * Added signature icons for Medium, GitHub and YouTube * Reverted location of icons to Mailspring assets --- .../composer-signature/lib/constants.ts | 30 ++++++- .../composer-signature/lib/templates.tsx | 82 +++++++++++++++++++ 2 files changed, 111 insertions(+), 1 deletion(-) diff --git a/app/internal_packages/composer-signature/lib/constants.ts b/app/internal_packages/composer-signature/lib/constants.ts index 1a7e2ba2e..5ad0144e6 100644 --- a/app/internal_packages/composer-signature/lib/constants.ts +++ b/app/internal_packages/composer-signature/lib/constants.ts @@ -43,6 +43,18 @@ export const DataShape = [ key: 'linkedinURL', label: localized('LinkedIn URL'), }, + { + key: 'mediumURL', + label: localized('Medium Handle'), + }, + { + key: 'githubURL', + label: localized('GitHub Username'), + }, + { + key: 'youtubeURL', + label: localized('YouTube'), + }, { key: 'twitterHandle', label: localized('Twitter Handle'), @@ -61,7 +73,7 @@ export const DataShape = [ export const ResolveSignatureData = data => { data = { ...data }; - ['websiteURL', 'facebookURL'].forEach(key => { + ['websiteURL', 'facebookURL', 'youtubeURL'].forEach(key => { if (data[key] && !data[key].includes(':')) { data[key] = `http://${data[key]}`; } @@ -74,6 +86,22 @@ export const ResolveSignatureData = data => { } } + // sanitize medium handle + if (data.mediumURL) { + if (!data.mediumURL.includes('medium.com')) { + if (!data.mediumURL.startsWith('@')) { + data.mediumURL = `@${data.mediumURL}`; + } + data.mediumURL = `https://www.medium.com/${data.mediumURL}`; + } + } + + // sanitize github username + if (data.githubURL) { + if (!data.githubURL.includes('github.com')) { + data.githubURL = `https://www.github.com/${data.githubURL}`; + } + } // sanitize twitter handle if (data.twitterHandle) { if (data.twitterHandle.includes('/')) { diff --git a/app/internal_packages/composer-signature/lib/templates.tsx b/app/internal_packages/composer-signature/lib/templates.tsx index f73d0f0b4..bb2e8b635 100644 --- a/app/internal_packages/composer-signature/lib/templates.tsx +++ b/app/internal_packages/composer-signature/lib/templates.tsx @@ -11,6 +11,34 @@ const FB_SHARE = ( alt="Facebook" /> ); + +const MEDIUM_SHARE = ( + Medium +); + +const GITHUB_SHARE = ( + Github +); + +const YOUTUBE_SHARE = ( + YouTube +); + const TWITTER_SHARE = ( )} + {props.mediumURL && ( + + {MEDIUM_SHARE} + + )} + {props.githubURL && ( + + {GITHUB_SHARE} + + )} + {props.youtubeURL && ( + + {YOUTUBE_SHARE} + + )} {props.twitterHandle && ( )} + {props.mediumURL && ( + + {MEDIUM_SHARE} + + )} + {props.githubURL && ( + + {GITHUB_SHARE} + + )} + {props.youtubeURL && ( + + {YOUTUBE_SHARE} + + )} {props.linkedinURL && (