-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
210 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
135 changes: 135 additions & 0 deletions
135
components/PullRequests/ProfilePullRequestsSection/PRCheerCard.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
import * as React from "react"; | ||
import { | ||
Avatar, | ||
Box, | ||
Button, | ||
Divider, | ||
Flex, | ||
HStack, | ||
Icon, | ||
Image, | ||
Link, | ||
SimpleGrid, | ||
Stack, | ||
Text, | ||
VStack, | ||
useColorModeValue, | ||
} from "@chakra-ui/react"; | ||
import { BiGitPullRequest } from "react-icons/bi"; | ||
import { BsGithub } from "react-icons/bs"; | ||
import { MdIosShare } from "react-icons/md"; | ||
import { PullRequest } from "../../../types/PullRequest"; | ||
import download from "downloadjs"; | ||
import { toPng } from "html-to-image"; | ||
import { useRef } from "react"; | ||
|
||
const PRCheerCard = (props: PullRequest) => { | ||
const [poweredBy, setPoweredBy] = React.useState("none"); | ||
const domEl = useRef<HTMLDivElement>(null); | ||
const pull = props; | ||
|
||
const downloadPNG = () => { | ||
setPoweredBy("normal"); | ||
if (domEl.current) { | ||
toPng(domEl.current).then(function (dataUrl) { | ||
download(dataUrl, "my-node.png"); | ||
setPoweredBy("none"); | ||
}); | ||
} | ||
}; | ||
let boxBg = useColorModeValue("white !important", "#111c44 !important"); | ||
let mainText = useColorModeValue("gray.800", "white"); | ||
let secondaryText = useColorModeValue("gray.400", "gray.400"); | ||
|
||
return ( | ||
<Box> | ||
<VStack mx={"auto"} alignItems={"center"}> | ||
<Flex | ||
id="domEl" | ||
ref={domEl} | ||
direction="column" | ||
alignItems="center" | ||
rounded="md" | ||
position="relative" | ||
bg={useColorModeValue("white", "gray.700")} | ||
shadow={{ md: "base" }} | ||
> | ||
<Flex bg={boxBg} alignItems="center" direction="column"> | ||
<Image | ||
src="https://i.ibb.co/xmP2pS6/Profile.png" | ||
alt="Graded pic" | ||
borderRadius="20px" | ||
width="100%" | ||
/> | ||
<Flex flexDirection="column" mb="30px"> | ||
<Image | ||
src={pull.author?.avatarUrl} | ||
alt={pull.author?.login} | ||
border="5px solid red" | ||
mx="auto" | ||
borderColor={boxBg} | ||
width="128px" | ||
height="128px" | ||
mt="-38px" | ||
borderRadius="50%" | ||
/> | ||
|
||
<Text | ||
color={secondaryText} | ||
textAlign="center" | ||
fontSize="sm" | ||
fontWeight="500" | ||
> | ||
{pull.author?.login} | ||
</Text> | ||
<Text | ||
fontWeight="600" | ||
color={mainText} | ||
textAlign="center" | ||
fontSize="xl" | ||
> | ||
{" "} | ||
Yay! I made an open source contribution. | ||
</Text> | ||
</Flex> | ||
</Flex> | ||
<Flex direction="column" bg={boxBg} px={5}> | ||
<HStack py="6px"> | ||
<Text color="muted"> | ||
<Icon as={BsGithub} color="blue.500" mr={2} /> | ||
</Text> | ||
<Text color="muted">{pull.repository?.nameWithOwner}</Text> | ||
</HStack> | ||
<HStack py="6px"> | ||
<Text color="muted"> | ||
<Icon as={BiGitPullRequest} color="blue.500" mr={2} /> | ||
</Text> | ||
<Text color="muted">{pull.title}</Text> | ||
</HStack> | ||
|
||
<Text pt="24px" fontSize="lg" textAlign="center" fontWeight="bold"> | ||
#HacktoberFest2022 | ||
</Text> | ||
|
||
<Box alignSelf={"center"} display={"flex"} fontSize="sm" mt={"10"}> | ||
<Text fontSize="8px" pt={4} color={"gray.400"}> | ||
made with 💖 by hacktobered.com | ||
</Text> | ||
</Box> | ||
</Flex> | ||
</Flex> | ||
<Button | ||
as="a" | ||
leftIcon={<MdIosShare fontWeight={"bold"} />} | ||
colorScheme="teal" | ||
variant="solid" | ||
onClick={() => downloadPNG()} | ||
> | ||
Share | ||
</Button> | ||
</VStack> | ||
</Box> | ||
); | ||
}; | ||
|
||
export default PRCheerCard; |
63 changes: 63 additions & 0 deletions
63
components/PullRequests/ProfilePullRequestsSection/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import * as React from "react"; | ||
import { | ||
Box, | ||
Divider, | ||
Heading, | ||
SimpleGrid, | ||
Stack, | ||
Text, | ||
} from "@chakra-ui/react"; | ||
import { useEffect, useState } from "react"; | ||
import { Card } from "../../common/Card"; | ||
import PRCheerCard from "./PRCheerCard"; | ||
import { SearchResults } from "../../../types/SearchResults"; | ||
import { UserCardPropType } from "../../../types/UserCardPropType"; | ||
import { apiWrapper } from "../../../apiWrapper"; | ||
import { useSession } from "next-auth/react"; | ||
|
||
export const ProfilePullRequestsSection = (props: UserCardPropType) => { | ||
const [searchData, setSearchData] = useState<SearchResults>(); | ||
const { data: session, status } = useSession(); | ||
|
||
async function fetchPR(accessToken: any, login: string) { | ||
const pullData = await apiWrapper.fetchUserPullRequests(accessToken, login); | ||
if (pullData) { | ||
setSearchData({ | ||
issueCount: pullData.issueCount, | ||
edges: pullData.edges, | ||
}); | ||
} | ||
} | ||
useEffect(() => { | ||
if (session) { | ||
fetchPR(session.accessToken, props.user.login); | ||
} | ||
}, [session, props.user.login]); | ||
|
||
return ( | ||
<> | ||
{!!searchData?.issueCount && ( | ||
<> | ||
<Divider py={4} /> | ||
<Text mt={8} fontWeight={"400"}> | ||
🎉🎉🎉 {searchData?.issueCount} public Pull Requests found | ||
</Text> | ||
</> | ||
)} | ||
<SimpleGrid columns={{ base: 1, md: 2 }} spacing="8"> | ||
{searchData?.edges && | ||
searchData?.edges.map((pullRequest) => ( | ||
<Box | ||
key={pullRequest.node.number} | ||
maxW="4xl" | ||
bg={"white"} | ||
{...props} | ||
mt={8} | ||
> | ||
<PRCheerCard {...pullRequest.node} /> | ||
</Box> | ||
))} | ||
</SimpleGrid> | ||
</> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bd413c3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
hacktobered – ./
hacktobered-git-main-hacktobered-team.vercel.app
hacktobered-hacktobered-team.vercel.app
hacktobered.vercel.app