Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore/remove imports #43

Merged
merged 2 commits into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading