Skip to content

Commit

Permalink
Merge pull request #43 from chimobi-justice/chore/remove-imports
Browse files Browse the repository at this point in the history
Chore/remove imports
  • Loading branch information
chimobi-justice authored Nov 18, 2024
2 parents e4a9308 + 5679e08 commit 493dc63
Show file tree
Hide file tree
Showing 7 changed files with 286 additions and 236 deletions.
24 changes: 24 additions & 0 deletions src/helpers/getSocialMediaIcon.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { FaFacebook, FaGithub, FaInstagram, FaLinkedin, FaXTwitter, FaYoutube } from "react-icons/fa6";
import { GiWorld } from "react-icons/gi";

export const getSocialMediaIcon = (platform: string, size?: string) => {
if (!platform) return null;

if (platform.includes("Youtube")) {
return <FaYoutube size={size || "20px"} />;
} else if (platform.includes("Twitter")) {
return <FaXTwitter size={size || "20px"} />;
} else if (platform.includes("GitHub")) {
return <FaGithub size={size || "20px"} />;
} else if (platform.includes("LinkedIn")) {
return <FaLinkedin size={size || "20px"} />;
} else if (platform.includes("Website")) {
return <GiWorld size={size || "20px"} />;
} else if (platform.includes("Facebook")) {
return <FaFacebook size={size || "20px"} />;
} else if (platform.includes("Instagram")) {
return <FaInstagram size={size || "20px"} />;
}

return null;
};
30 changes: 14 additions & 16 deletions src/pages/Articles/show/index.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { FunctionComponent } from 'react'
import { Link, useParams } from 'react-router-dom'
import { Avatar, Box, Flex, HStack, Image, Text } from '@chakra-ui/react'
import { FaGithub, FaXTwitter } from 'react-icons/fa6'
import { GiWorld } from 'react-icons/gi'
import { Helmet } from 'react-helmet-async'

import ArticleHeroSection from '@pages/Articles/HeroSection'
Expand All @@ -21,6 +19,8 @@ import { useCreateFollowUser } from '@hooks/user/useCreateFollowUser'
import { useCreateOnFollowUser } from '@hooks/user/useCreateUnFollowUser'
import useScrollToTop from '@hooks/useScrollToTop'
import { useUser } from '@context/userContext'
import { ISocial } from 'src/types'
import { getSocialMediaIcon } from '@helpers/getSocialMediaIcon'

const ShowArticle: FunctionComponent = () => {
const { id } = useParams();
Expand Down Expand Up @@ -52,21 +52,19 @@ const ShowArticle: FunctionComponent = () => {

const renderAuthorSocialLinks = () => (
<HStack spacing={3} my="10px" justify="center">
{data?.data?.author?.info_details?.gitHub && (
<Link to={`https://www.github.com/${data?.data?.author?.info_details?.gitHub}`} target="_blank" rel="noopener noreferrer">
<FaGithub fontSize="24px" style={{ marginBottom: '5px' }} />
</Link>
)}
{data?.data?.author?.info_details?.twitter && (
<Link to={`https://x.com/${data?.data?.author?.info_details?.twitter}`} target="_blank" rel="noopener noreferrer">
<FaXTwitter fontSize="24px" style={{ marginBottom: '5px' }} />
</Link>
)}
{data?.data?.author?.info_details?.website && (
<Link to={`${data?.data?.author?.info_details?.website}`} target="_blank" rel="noopener noreferrer">
<GiWorld fontSize="24px" style={{ marginBottom: '5px' }} />
{data?.data?.author?.info_details?.socials?.map((social: ISocial) => (
<Link
to={social?.link}
target="_blank"
rel="noopener noreferrer"
>
<Text
fontSize={{ base: "15px", md: "18px" }}
>
{getSocialMediaIcon(social.platform, "24px")}
</Text>
</Link>
)}
))}
</HStack>
);

Expand Down
40 changes: 6 additions & 34 deletions src/pages/Users/Profile/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ import {
Image,
Text
} from '@chakra-ui/react'
import { FaGithub, FaXTwitter } from 'react-icons/fa6'
import { GiWorld } from 'react-icons/gi'
import { Helmet } from 'react-helmet-async'

import { FollowCard, Button } from '@components/index'
import CoverPic from '@assets/images/cover.jpg'
import { useUser } from '@context/userContext'
import { colors } from '../../../colors'
import { ISocial } from 'src/types'
import { getSocialMediaIcon } from '@helpers/getSocialMediaIcon'

const Profile: FunctionComponent = () => {
const { user } = useUser();
Expand Down Expand Up @@ -96,47 +96,19 @@ const Profile: FunctionComponent = () => {
spacing={3}
my={"10px"}
>
{user?.data?.gitHub && (
{user?.data?.socials?.map((social: ISocial) => (
<Link
to={`https://www.github.com/${user?.data?.gitHub}`}
to={social?.link}
target="_blank"
rel="noopener noreferrer"
>
<Text
fontSize={{ base: "15px", md: "18px" }}
>
<FaGithub style={{ fontSize: "24px", marginBottom: "5px" }} />
{getSocialMediaIcon(social.platform, "24px")}
</Text>
</Link>
)}

{user?.data?.twitter && (
<Link
to={`https://x.com/${user?.data?.twitter}`}
target="_blank"
rel="noopener noreferrer"
>
<Text
fontSize={{ base: "15px", md: "18px" }}
>
<FaXTwitter style={{ fontSize: "24px", marginBottom: "5px" }} />
</Text>
</Link>
)}

{user?.data?.website && (
<Link
to={user?.data?.website}
target="_blank"
rel="noopener noreferrer"
>
<Text
fontSize={{ base: "15px", md: "18px" }}
>
<GiWorld style={{ fontSize: "24px", marginBottom: "5px" }} />
</Text>
</Link>
)}
))}
</HStack>
</Box>

Expand Down
Loading

0 comments on commit 493dc63

Please sign in to comment.