From 47dd9e55227827e2da36aa8daa6cf8c44872599b Mon Sep 17 00:00:00 2001 From: Kamran Ahmed Date: Fri, 4 Nov 2022 16:53:59 +0400 Subject: [PATCH] Add buttons to share roadmaps on Hacker News, Reddit, Twitter, Facebook --- components/custom-ad.tsx | 2 +- components/icons/facebook-square.svg | 1 + components/icons/hackernews-square.svg | 1 + components/icons/reddit-square.svg | 1 + components/icons/twitter-square.svg | 1 + components/share-icons.tsx | 27 ++++++++++++++++++++++++++ pages/[roadmap]/index.tsx | 1 + pages/[roadmap]/interactive.tsx | 7 +++++-- 8 files changed, 38 insertions(+), 3 deletions(-) create mode 100644 components/icons/facebook-square.svg create mode 100644 components/icons/hackernews-square.svg create mode 100644 components/icons/reddit-square.svg create mode 100644 components/icons/twitter-square.svg create mode 100644 components/share-icons.tsx diff --git a/components/custom-ad.tsx b/components/custom-ad.tsx index 939e5517d..0ef5c0ff7 100644 --- a/components/custom-ad.tsx +++ b/components/custom-ad.tsx @@ -21,7 +21,7 @@ export const CustomAd = () => { bottom='15px' right='20px' zIndex={999} - display='flex' + display={['none', 'none', 'flex', 'flex']} maxWidth='330px' bg='white' boxShadow='0 1px 4px 1px hsla(0, 0%, 0%, .1)' diff --git a/components/icons/facebook-square.svg b/components/icons/facebook-square.svg new file mode 100644 index 000000000..a3ca5b2b9 --- /dev/null +++ b/components/icons/facebook-square.svg @@ -0,0 +1 @@ + diff --git a/components/icons/hackernews-square.svg b/components/icons/hackernews-square.svg new file mode 100644 index 000000000..855124880 --- /dev/null +++ b/components/icons/hackernews-square.svg @@ -0,0 +1 @@ + diff --git a/components/icons/reddit-square.svg b/components/icons/reddit-square.svg new file mode 100644 index 000000000..b0e32ba22 --- /dev/null +++ b/components/icons/reddit-square.svg @@ -0,0 +1 @@ + diff --git a/components/icons/twitter-square.svg b/components/icons/twitter-square.svg new file mode 100644 index 000000000..57dd14cdb --- /dev/null +++ b/components/icons/twitter-square.svg @@ -0,0 +1 @@ + diff --git a/components/share-icons.tsx b/components/share-icons.tsx new file mode 100644 index 000000000..8f1d1c501 --- /dev/null +++ b/components/share-icons.tsx @@ -0,0 +1,27 @@ +import { Box, Flex, Link } from '@chakra-ui/react'; +import HackerNewsIcon from 'components/icons/hackernews-square.svg'; +import FacebookIcon from 'components/icons/facebook-square.svg'; +import TwitterIcon from 'components/icons/twitter-square.svg'; +import RedditIcon from 'components/icons/reddit-square.svg'; +import { Icon } from '@chakra-ui/icons'; +import { getFacebookShareUrl, getHnShareUrl, getRedditShareUrl, getTwitterShareUrl } from '../lib/url'; + +type ShareIconProps = { + text: string; + url: string; +} + +export function ShareIcons(props: ShareIconProps) { + const { text, url } = props; + + return ( + + + + + + + + + ); +} diff --git a/pages/[roadmap]/index.tsx b/pages/[roadmap]/index.tsx index c1b3c47f8..a13926560 100644 --- a/pages/[roadmap]/index.tsx +++ b/pages/[roadmap]/index.tsx @@ -18,6 +18,7 @@ import { SIGNUP_EMAIL_INPUT_NAME, SIGNUP_FORM_ACTION } from '../signup'; import { BellIcon, EmailIcon } from '@chakra-ui/icons'; import { RelatedRoadmaps } from '../../components/related-roadmaps'; import { TeamsBanner } from '../../components/teams-banner'; +import { ShareIcons } from '../../components/share-icons'; type RoadmapProps = { roadmap: RoadmapType; diff --git a/pages/[roadmap]/interactive.tsx b/pages/[roadmap]/interactive.tsx index d70615d11..ab5d2bd99 100644 --- a/pages/[roadmap]/interactive.tsx +++ b/pages/[roadmap]/interactive.tsx @@ -1,5 +1,5 @@ import { useFetch } from 'use-http'; -import { useEffect, useRef, useState } from 'react'; +import React, { useEffect, useRef, useState } from 'react'; import { Box, Container } from '@chakra-ui/react'; import { wireframeJSONToSVG } from 'roadmap-renderer'; import { GlobalHeader } from '../../components/global-header'; @@ -13,6 +13,7 @@ import { RoadmapError } from '../../components/roadmap/roadmap-error'; import { RoadmapLoader } from '../../components/roadmap/roadmap-loader'; import { removeSortingInfo } from '../../lib/renderer'; import { TeamsBanner } from '../../components/teams-banner'; +import { ShareIcons } from '../../components/share-icons'; type RoadmapProps = { roadmap: RoadmapType; @@ -179,7 +180,7 @@ export function InteractiveRoadmapRenderer(props: RoadmapProps) { } return ( - + {(isLoading || isRendering) && }
+ + ); }