Skip to content
This repository has been archived by the owner on Sep 26, 2024. It is now read-only.

Commit

Permalink
feat: Removing the votes feature (#518)
Browse files Browse the repository at this point in the history
* first pass removing votes feature

* remove vote files

* npm run format

* fix lint

* fix build

* fix build again
  • Loading branch information
bdougie authored Apr 1, 2024
1 parent 247841d commit 8db6b23
Show file tree
Hide file tree
Showing 16 changed files with 38 additions and 431 deletions.
10 changes: 5 additions & 5 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ module.exports = {
},
],
"array-element-newline": ["error", "consistent"],
"arrow-parens": ["error", "as-needed"],
"arrow-parens": ["warn", "as-needed"],
"arrow-spacing": "error",
"block-spacing": ["error", "always"],
"brace-style": ["error", "1tbs"],
Expand Down Expand Up @@ -345,7 +345,7 @@ module.exports = {
"react/jsx-closing-bracket-location": "error",
"react/jsx-closing-tag-location": "error",
"react/jsx-curly-brace-presence": ["error", "never"],
"react/jsx-curly-newline": ["error", "consistent"],
"react/jsx-curly-newline": ["warn", "consistent"],
"react/jsx-equals-spacing": ["error", "never"],
"react/jsx-first-prop-new-line": ["error", "multiline-multiprop"],
"react/jsx-fragments": ["error", "syntax"],
Expand All @@ -364,13 +364,13 @@ module.exports = {
},
],
"react/jsx-max-props-per-line": [
"error",
"warn",
{
maximum: 1,
},
],
"react/jsx-newline": [
"error",
"warn",
{
prevent: false,
},
Expand All @@ -385,7 +385,7 @@ module.exports = {
},
],
"react/jsx-one-expression-per-line": [
"error",
"warn",
{
allow: "literal",
},
Expand Down
6 changes: 0 additions & 6 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import Hero from "./components/Hero";
import apiFetcher from "./hooks/useSWR";

import getAppVersion from "./lib/appVersion";
import VotedRepoListWrap from "./components/VotedRepoListWrap";
import RecentRepoListWrap from "./components/RecentRepoListWrap";
import SecondaryNav from "./components/SecondaryNav";
import HotRepositories from "./components/HotRepositories";
Expand Down Expand Up @@ -53,11 +52,6 @@ const App = (): JSX.Element => {
<HotRepositories />

<Routes>
<Route
element={<VotedRepoListWrap />}
path="myVotes"
/>

<Route
element={<RecentRepoListWrap />}
path="/"
Expand Down
30 changes: 9 additions & 21 deletions src/components/Hero.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const Hero = () => {
if (!hasFocus) {
searchBoxRef.current?.focus();
setFocus(true);
const results = await fetchRecommendations("stars", 3, null, searchTerm);
const results = await fetchRecommendations(3, searchTerm);

setFetchedData(results);
} else {
Expand All @@ -47,7 +47,7 @@ const Hero = () => {
useKey("MetaLeft", "KeyK", containerRef);

useDidUpdate(async () => {
const results = await fetchRecommendations("stars", 3, null, searchTerm);
const results = await fetchRecommendations(3, searchTerm);

setFetchedData(results);
}, [searchTerm]);
Expand All @@ -57,27 +57,18 @@ const Hero = () => {
<div>
<h1 className="font-Lexend text-4xl md:text-5xl text-center text-lightSlate leading-tight tracking-tight">
{`Find `}

<span className="bg-gradient-to-r from-gradFirst via-gradMiddle to-gradLast bg-clip-text text-transparent">

Check warning on line 60 in src/components/Hero.tsx

View workflow job for this annotation

GitHub Actions / Test and lint / Code standards

JSX element should start in a new line
Open-Source Repositories
</span>

<br />

Check warning on line 63 in src/components/Hero.tsx

View workflow job for this annotation

GitHub Actions / Test and lint / Code standards

JSX element should start in a new line
to contribute today
</h1>
</div>

<Combobox
as="div"
value={comboBoxSelection}
onChange={setComboBoxSelection}
>
<Combobox as="div" value={comboBoxSelection} onChange={setComboBoxSelection}>

Check warning on line 68 in src/components/Hero.tsx

View workflow job for this annotation

GitHub Actions / Test and lint / Code standards

Prop `value` must be placed on a new line
<div className="mt-11 px-4 py-2.5 bg-white shadow-2xl rounded-2xl md:min-w-[26.375rem] flex justify-between">
<div className="flex items-center gap-x-2.5">
<img
alt="search icon"
src={searchNormal}
/>
<img alt="search icon" src={searchNormal} />

Check warning on line 71 in src/components/Hero.tsx

View workflow job for this annotation

GitHub Actions / Test and lint / Code standards

Prop `src` must be placed on a new line

<Combobox.Button ref={comboButtonRef}>
<Combobox.Input
Expand All @@ -87,12 +78,13 @@ const Hero = () => {
placeholder="Search repositories"
type="text"
value={searchTerm}
onChange={e => setValueDebounced(e.target.value)}
onChange={(e) => setValueDebounced(e.target.value)}

Check warning on line 81 in src/components/Hero.tsx

View workflow job for this annotation

GitHub Actions / Test and lint / Code standards

Unexpected parentheses around single function argument
onFocus={() => setFocus(true)}
onBlur={() =>
setTimeout(() => {
setFocus(false);
}, 200)}
}, 200)
}

Check warning on line 87 in src/components/Hero.tsx

View workflow job for this annotation

GitHub Actions / Test and lint / Code standards

Unexpected newline before '}'
onKeyUp={(event: React.KeyboardEvent) => {
if (event.key === "Enter") {
window.open(comboBoxSelection, "_blank", "noreferrer");
Expand All @@ -102,11 +94,7 @@ const Hero = () => {
</Combobox.Button>
</div>

<img
alt="command k"
className="pt-1.5"
src={cmdKIcon}
/>
<img alt="command k" className="pt-1.5" src={cmdKIcon} />

Check warning on line 97 in src/components/Hero.tsx

View workflow job for this annotation

GitHub Actions / Test and lint / Code standards

Prop `className` must be placed on a new line
</div>

<div className="mt-2.5">
Expand All @@ -117,7 +105,7 @@ const Hero = () => {
<p className="text-gray-500 text-sm font-semibold">Repository</p>
</div>

{fetchedData.map(data => (
{fetchedData.map((data) => (

Check warning on line 108 in src/components/Hero.tsx

View workflow job for this annotation

GitHub Actions / Test and lint / Code standards

Unexpected parentheses around single function argument
<Combobox.Option
key={data.full_name}
as="a"
Expand Down
35 changes: 4 additions & 31 deletions src/components/HotRepoCard.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import { useEffect, useState } from "react";
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";
Expand All @@ -10,7 +7,6 @@ import humanizeNumber from "../lib/humanizeNumber";

import StackedAvatar from "./StackedAvatar";
import useRepo from "../hooks/useRepo";
import useVotedRepos from "../hooks/useVotedRepos";
import useContributions from "../hooks/useContributions";

const bugReportLink = "https://github.com/open-sauced/hot/issues/new?assignees=&title=fix:";
Expand All @@ -20,15 +16,9 @@ export declare interface HotRepoCardProps {
}

const HotRepoCard = ({ repoName }: HotRepoCardProps): JSX.Element => {
const { votedReposIds, checkVoted, voteHandler } = useVotedRepos();
const { repo, isLoading, isError } = useRepo(repoName);
const [isVoted, setIsVoted] = useState(false);
const { data: contributions } = useContributions(repoName);

useEffect(() => {
repo && setIsVoted(checkVoted(repo.id));
}, [votedReposIds, repo]);

if (isError) {
return (
<div className="p-4 border rounded-2xl bg-white w-full space-y-1 relative flex flex-col justify-between">
Expand All @@ -37,9 +27,11 @@ const HotRepoCard = ({ repoName }: HotRepoCardProps): JSX.Element => {
<div className="flex justify-center">
<a
className="bg-cheesyYellow text-grey rounded-xl font-bold hover:text-saucyRed transition-all duration-300 mr-3 p-2 flex w-5/6 h-fit justify-center"
href={`${String(`${bugReportLink} repo not found [${repoName}]&body=Please take a look why this ${repoName} not founded`)}`}
rel="noreferrer"
target="_blank"
href={`${String(
`${bugReportLink} repo not found [${repoName}]&body=Please take a look why this ${repoName} not founded`,
)}`}
>
Report a bug
</a>
Expand All @@ -59,8 +51,7 @@ const HotRepoCard = ({ repoName }: HotRepoCardProps): JSX.Element => {
);
}

const { id, full_name, name, description, issues, stars } = repo!;
const repo_id = parseInt(`${id}`);
const { full_name, name, description, issues, stars } = repo!;
const owner = full_name.replace(`/${String(name)}`, "").trim();

return (
Expand All @@ -77,24 +68,6 @@ const HotRepoCard = ({ repoName }: HotRepoCardProps): JSX.Element => {
{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 ${
isVoted ? "bg-lightOrange01" : "bg-lightSlate01"
} ${isVoted ? "text-saucyRed border-saucyRed " : "text-lightSlate11 border-lightSlate06 "}`}
onClick={async () => voteHandler(0, repo_id)}
>
<span>
{isVoted ? "voted" : "upvote"}
</span>

{isVoted
? (
<RiCheckboxCircleFill className="" />)
: (
<FaArrowAltCircleUp className="fill-lightSlate09" />
)}
</button>
</div>

<div className="flex flex-col pb-10">
Expand Down
25 changes: 6 additions & 19 deletions src/components/ListRepositories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,9 @@ const ListRepositories = ({
return (
<div className="mx-auto max-w-7xl px-4 mt-10">
<div className="flex flex-col gap-y-5 overflow-hidden mb-12">
{Array.from(Array(25).keys()).map(item => (
<div
key={item}
className="p-4 border rounded-2xl bg-white w-full space-y-1 relative"
>
<Skeleton
enableAnimation
count={4}
/>
{Array.from(Array(25).keys()).map((item) => (

Check warning on line 24 in src/components/ListRepositories.tsx

View workflow job for this annotation

GitHub Actions / Test and lint / Code standards

Unexpected parentheses around single function argument
<div key={item} className="p-4 border rounded-2xl bg-white w-full space-y-1 relative">

Check warning on line 25 in src/components/ListRepositories.tsx

View workflow job for this annotation

GitHub Actions / Test and lint / Code standards

Prop `className` must be placed on a new line
<Skeleton enableAnimation count={4} />
</div>
))}
</div>
Expand All @@ -43,22 +37,15 @@ const ListRepositories = ({
<div className="flex items-center gap-x-2.5">
<BsFillCalendar2Fill className="w-8 h-8 text-white" />

{activeLink && (
<h1 className="text-2xl text-white font-semibold">
{title}
</h1>
)}
{activeLink && <h1 className="text-2xl text-white font-semibold">{title}</h1>}
</div>

{fetchedData.map((item, i) => (
<RepoList
key={`${item.full_name}_${i}`}
data={item}
/>
<RepoList key={`${item.full_name}_${i}`} data={item} />
))}
</div>

{fetchedData.length > 0 && activeLink !== "myVotes" && hasNextPage && (
{fetchedData.length > 0 && hasNextPage && (
<div className="flex justify-center">
<button
className="bg-white text-gray-700 mt-4 mb-4 text-base border-gray-400 border font-normal py-1 px-4 rounded"
Expand Down
3 changes: 0 additions & 3 deletions src/components/RecentRepoListWrap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import Skeleton from "react-loading-skeleton";
export enum RepoOrderByEnum {
popular = "stars",
recent = "created_at",
upvoted = "votesCount",
discussed = "issues",
myVotes = "myVotes",
}
Expand Down Expand Up @@ -51,7 +50,6 @@ const RecentRepoListWrap = (): JSX.Element => {
const thisWeekData = data.filter(repo => repo.created_at && new Date(repo.created_at) > lastSunday);

thisWeekData.sort((a, b) => (new Date(a.created_at!) > new Date(b.created_at!) ? 1 : -1));
thisWeekData.sort((a, b) => (a.votesCount! > b.votesCount! ? -1 : 1));
setThisWeek(thisWeekData);

const lastWeekData = data.filter(
Expand Down Expand Up @@ -102,7 +100,6 @@ const RecentRepoListWrap = (): JSX.Element => {
)
: (
<>

{thisWeek && thisWeek.length > 0 && (
<ListRepositories
activeLink={activeLink}
Expand Down
Loading

0 comments on commit 8db6b23

Please sign in to comment.