From 191d05256c66e8d1e86b6811e1a7cc4468305840 Mon Sep 17 00:00:00 2001 From: Kristof Csillag Date: Tue, 13 Feb 2024 13:00:22 +0100 Subject: [PATCH] Support more external / social link types --- .env | 3 +++ src/app/components/Social/index.tsx | 41 ++++++++++++++++++++++------- src/app/utils/externalLinks.ts | 6 +++++ src/global.d.ts | 3 +++ src/locales/en/translation.json | 5 +++- 5 files changed, 48 insertions(+), 10 deletions(-) diff --git a/.env b/.env index 662bf65cfc..32b480a144 100644 --- a/.env +++ b/.env @@ -14,3 +14,6 @@ REACT_APP_TESTNET_API=https://testnet.nexus.oasis.io/v1/ # REACT_APP_SOCIAL_DISCORD=https://oasis.io/discord # REACT_APP_SOCIAL_YOUTUBE=https://www.youtube.com/channel/UC35UFPcZ2F1wjPxhPrSsESQ # REACT_APP_SOCIAL_REDDIT=https://www.reddit.com/r/oasisnetwork/ +# REACT_APP_SOCIAL_LINKEDIN=https://www.linkedin.com/company/oasisprotocol +# REACT_APP_SOCIAL_DOCS=https://oasisprotocol.org/developers#overview +# REACT_APP_SOCIAL_HOME=https://oasisprotocol.org/ diff --git a/src/app/components/Social/index.tsx b/src/app/components/Social/index.tsx index e66433b349..62762dce10 100644 --- a/src/app/components/Social/index.tsx +++ b/src/app/components/Social/index.tsx @@ -1,4 +1,4 @@ -import { FC } from 'react' +import React, { FC } from 'react' import { useTranslation } from 'react-i18next' import Box from '@mui/material/Box' import Grid from '@mui/material/Unstable_Grid2' @@ -11,17 +11,23 @@ import twitter from './images/twitter.svg' import discord from './images/discord.svg' import youtube from './images/youtube.svg' import reddit from './images/reddit.svg' +import LinkedInIcon from '@mui/icons-material/LinkedIn' +import DocsIcon from '@mui/icons-material/MenuBook' +import HomeIcon from '@mui/icons-material/Cottage' import { COLORS } from '../../../styles/theme/colors' import { socialMedia } from '../../utils/externalLinks' +import { OverridableComponent } from '@mui/material/OverridableComponent' +import { SvgIconTypeMap } from '@mui/material/SvgIcon' type SocialLinkProps = { label: string href: string isMobile: boolean - img: string + imgSrc?: string + img?: OverridableComponent & { muiName: string } } -const SocialLink: FC = ({ label, href, isMobile, img }) => { +const SocialLink: FC = ({ label, href, isMobile, imgSrc, img }) => { return ( = ({ label, href, isMobile, img }) => { target="_blank" > - {label} + <> + {imgSrc && {label}} + {img && React.createElement(img, { sx: { fontSize: 50, margin: '-4px' } })} + {label} @@ -89,7 +98,7 @@ export const Social: FC = () => { isMobile={isMobile} label={t('social.telegram')} href={socialMedia.telegram} - img={telegram} + imgSrc={telegram} /> )} {socialMedia.twitter && ( @@ -97,7 +106,7 @@ export const Social: FC = () => { isMobile={isMobile} label={t('social.twitter')} href={socialMedia.twitter} - img={twitter} + imgSrc={twitter} /> )} {socialMedia.discord && ( @@ -105,7 +114,7 @@ export const Social: FC = () => { isMobile={isMobile} label={t('social.discord')} href={socialMedia.discord} - img={discord} + imgSrc={discord} /> )} {socialMedia.youtube && ( @@ -113,7 +122,7 @@ export const Social: FC = () => { isMobile={isMobile} label={t('social.youtube')} href={socialMedia.youtube} - img={youtube} + imgSrc={youtube} /> )} {socialMedia.reddit && ( @@ -121,9 +130,23 @@ export const Social: FC = () => { isMobile={isMobile} label={t('social.reddit')} href={socialMedia.reddit} - img={reddit} + imgSrc={reddit} /> )} + {socialMedia.linkedin && ( + + )} + {socialMedia.docs && ( + + )} + {socialMedia.home && ( + + )} diff --git a/src/app/utils/externalLinks.ts b/src/app/utils/externalLinks.ts index d1e989b955..64653ff22b 100644 --- a/src/app/utils/externalLinks.ts +++ b/src/app/utils/externalLinks.ts @@ -5,6 +5,9 @@ const customTwitter = process.env.REACT_APP_SOCIAL_TWITTER const customDiscord = process.env.REACT_APP_SOCIAL_DISCORD const customYouTube = process.env.REACT_APP_SOCIAL_YOUTUBE const customReddit = process.env.REACT_APP_SOCIAL_REDDIT +const customLinkedin = process.env.REACT_APP_SOCIAL_LINKEDIN +const customDocs = process.env.REACT_APP_SOCIAL_DOCS +const customHome = process.env.REACT_APP_SOCIAL_HOME const hasCustomSocialLinks = !!customTelegram || !!customTwitter || !!customDiscord || !!customYouTube || !!customReddit @@ -16,6 +19,9 @@ export const socialMedia = hasCustomSocialLinks discord: customDiscord, youtube: customYouTube, reddit: customReddit, + linkedin: customLinkedin, + docs: customDocs, + home: customHome, } : { telegram: 'https://t.me/oasisprotocolcommunity', diff --git a/src/global.d.ts b/src/global.d.ts index d5808e160c..c85df61b50 100644 --- a/src/global.d.ts +++ b/src/global.d.ts @@ -15,6 +15,9 @@ declare global { REACT_APP_SOCIAL_DISCORD?: string REACT_APP_SOCIAL_YOUTUBE?: string REACT_APP_SOCIAL_REDDIT?: string + READ_APP_SOCIAL_LINKEDIN?: string + READ_APP_SOCIAL_DOCS?: string + READ_APP_SOCIAL_HOME?: string } } } diff --git a/src/locales/en/translation.json b/src/locales/en/translation.json index 050556ee50..33efc8079f 100644 --- a/src/locales/en/translation.json +++ b/src/locales/en/translation.json @@ -286,7 +286,10 @@ "reddit": "Reddit", "telegram": "Telegram", "twitter": "X", - "youtube": "Youtube" + "youtube": "Youtube", + "linkedin": "LinkedIn", + "docs": "Documentation", + "home": "Home" }, "tableLayoutButton": { "changeView": "Change view"