This repository was archived by the owner on Sep 26, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 150
feat: use async hooks and beta api #296
Merged
Merged
Changes from 7 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
2a60a34
Merge remote-tracking branch 'origin/main' into beta
0-vortex 4499bd3
build: add swr and beta api configuration
0-vortex 05eb2c9
feat: add open-sauced minimal react loading skeleton
0-vortex 46d0e8b
refactor: make swr config global and add default api fetcher
0-vortex 1be1501
refactor: rename recommendation to repo
0-vortex ad38973
feat: implement global votes array
0-vortex 18d7509
refactor: correct linter double rule and improve type checks
0-vortex c80993f
feat: add global vote handler to use voted repos
0-vortex eeb08f9
refactor: implement vote handler in posts list without working count
0-vortex 6a2dbc8
fix: make votes work in post list
0-vortex 35192f7
fix: correct all vote scenarios
0-vortex cea471d
refactor: improve app loading component and remove redundant state
0-vortex File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
VITE_SUPABASE_URL=https://lkkownkrbkmblczeoyqb.supabase.co | ||
VITE_SUPABASE_API_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJvbGUiOiJhbm9uIiwiaWF0IjoxNjQyNDU2MTc0LCJleHAiOjE5NTgwMzIxNzR9.c6nlkT05GnNacQ6OYuGcjBsILmGsSDwEEtN2zZVXFgY | ||
VITE_POSTHOG_ID=phc_DFcN3mLP4ocKAUBKr5xyMbAnPwcl93q41ZmhoLG7GCv | ||
VITE_POSTHOG_ID=phc_DFcN3mLP4ocKAUBKr5xyMbAnPwcl93q41ZmhoLG7GCv | ||
VITE_API_URL=https://beta.api.opensauced.pizza/v1 |
This file contains hidden or 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,134 @@ | ||
import { RiCheckboxCircleFill } from "react-icons/ri"; | ||
import { FaArrowAltCircleUp } from "react-icons/fa"; | ||
import { AiOutlineStar } from "react-icons/ai"; | ||
import { BiGitPullRequest } from "react-icons/bi"; | ||
import { VscIssues } from "react-icons/vsc"; | ||
import Skeleton from "react-loading-skeleton"; | ||
import { getAvatarLink } from "../lib/github"; | ||
import humanizeNumber from "../lib/humanizeNumber"; | ||
import StackedAvatar from "./StackedAvatar"; | ||
import useRepo from "../hooks/useRepo"; | ||
import useVotedRepos from "../hooks/useVotedRepos"; | ||
|
||
export declare interface HotRepoCardProps { | ||
repoName: string; | ||
} | ||
|
||
const HotRepoCard = ({ repoName }: HotRepoCardProps): JSX.Element => { | ||
const { checkVoted } = useVotedRepos(); | ||
|
||
const { repo, isLoading, isError } = useRepo(repoName); | ||
|
||
if (isError) { | ||
return ( | ||
<div className="p-4 border rounded-2xl bg-white w-full space-y-1 relative"> | ||
{`${repoName} failed to load`} | ||
</div> | ||
); | ||
} | ||
|
||
if (isLoading) { | ||
return ( | ||
<div className="p-4 border rounded-2xl bg-white w-full space-y-1 relative"> | ||
<Skeleton | ||
enableAnimation | ||
count={5} | ||
/> | ||
</div> | ||
); | ||
} | ||
|
||
const { id, full_name, name, description, issues, stars, contributions } = repo!; | ||
const owner = full_name.replace(`/${String(name)}`, "").trim(); | ||
|
||
return ( | ||
<div className="p-4 border rounded-2xl bg-white w-full space-y-1 relative"> | ||
<div className="flex justify-between w-full"> | ||
<div className="flex space-x-1 items-center"> | ||
<img | ||
alt="Hot Repo Icon" | ||
className="h-4 w-4 rounded-md overflow-hidden" | ||
src={getAvatarLink(owner)} | ||
/> | ||
|
||
<span className="text-sm font-medium text-lightSlate11"> | ||
{owner} | ||
</span> | ||
</div> | ||
|
||
<button | ||
className={`px-2 py-0.5 border rounded-lg flex justify-center items-center space-x-1 text-xs transition-all duration-200 ${ | ||
checkVoted(id) ? "bg-lightOrange01" : "bg-lightSlate01" | ||
} ${checkVoted(id) ? "text-saucyRed border-saucyRed " : "text-lightSlate11 border-lightSlate06 "}`} | ||
|
||
// onClick={() => voteHandler(votesCount, id)} | ||
> | ||
<span> | ||
{checkVoted(id) ? "voted" : "upvote"} | ||
</span> | ||
|
||
{checkVoted(id) | ||
? ( | ||
<RiCheckboxCircleFill className="" />) | ||
0-vortex marked this conversation as resolved.
Show resolved
Hide resolved
|
||
: ( | ||
<FaArrowAltCircleUp className="fill-lightSlate09" /> | ||
)} | ||
</button> | ||
</div> | ||
|
||
<div className="flex flex-col pb-10"> | ||
<a | ||
className="text-xl font-semibold" | ||
href={`https://app.opensauced.pizza/repos/${full_name}`} | ||
rel="noopener noreferrer" | ||
target="_blank" | ||
> | ||
{name} | ||
</a> | ||
|
||
<p className="text-gray-500 font-medium text-xs w-5/6"> | ||
{description} | ||
</p> | ||
</div> | ||
|
||
<div className="flex items-center justify-between absolute bottom-3 inset-x-0 px-4"> | ||
<div className="flex space-x-3 text-xs"> | ||
<div className="flex text-sm space-x-1 justify-center items-center"> | ||
<VscIssues | ||
className="fill-lightSlate10" | ||
size={16} | ||
/> | ||
|
||
<span className="text-lightSlate11"> | ||
{humanizeNumber(issues)} | ||
</span> | ||
</div> | ||
|
||
<div className="flex text-sm space-x-1 justify-center items-center"> | ||
<AiOutlineStar | ||
className="fill-lightSlate10" | ||
size={16} | ||
/> | ||
|
||
<span className="text-lightSlate11"> | ||
{humanizeNumber(stars)} | ||
</span> | ||
</div> | ||
|
||
<div className="flex text-sm space-x-1 justify-center items-center"> | ||
<BiGitPullRequest | ||
className="fill-lightSlate10" | ||
size={16} | ||
/> | ||
|
||
<span className="text-lightSlate11">0</span> | ||
</div> | ||
</div> | ||
|
||
<StackedAvatar contributors={contributions} /> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default HotRepoCard; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.