Skip to content

Commit 3773b64

Browse files
🎨 ✨ Modal added and code formatted
1 parent f975565 commit 3773b64

File tree

8 files changed

+192
-41
lines changed

8 files changed

+192
-41
lines changed

‎components/Card.tsx

Lines changed: 41 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
import { emojify } from '@twuni/emojify';
2-
import { GoStar, GoRepoForked, GoIssueOpened } from 'react-icons/go';
2+
import {
3+
GoStar,
4+
GoRepoForked,
5+
GoAlertFill,
6+
GoIssueOpened
7+
} from 'react-icons/go';
38
import { RepoItem } from 'types';
9+
import ReportModal from './ReportModal';
410

511
interface Props {
612
repo: RepoItem;
@@ -11,30 +17,45 @@ function Card({ repo }: Props) {
1117
<section className="shadow-sm card bg-2023-void-2 ring-1 ring-2023-manga-3 transition duration-300 hover:scale-105 hover:shadow-2xl hover:shadow-2023-bavarian-gold-2/30">
1218
<div className="relative card-body p-6">
1319
<div className="flex-1">
14-
<div className="flex gap-4 items-center justify-start">
15-
<a
16-
className="border-2 rounded-full h-14 aspect-square p-1.5 border-neutral-100"
17-
href={repo.owner.html_url}
18-
title={repo.owner.login}
19-
target="_blank"
20-
rel="noreferrer"
21-
>
22-
<img
23-
src={repo.owner.avatar_url}
24-
alt={repo.owner.login}
25-
className="rounded-full"
26-
/>
27-
</a>
28-
<h2 className="text-3xl cursor-pointer hover:underline text-2023-bavarian-gold-2 whitespace-nowrap overflow-hidden text-ellipsis max-w-full">
20+
<div className="flex items-center justify-between">
21+
<div className="flex gap-4 items-center justify-start">
2922
<a
30-
href={repo.html_url}
31-
title={repo.name}
23+
className="border-2 rounded-full h-14 aspect-square p-1.5 border-neutral-100"
24+
href={repo.owner.html_url}
25+
title={repo.owner.login}
3226
target="_blank"
3327
rel="noreferrer"
3428
>
35-
{repo.name}
29+
<img
30+
src={repo.owner.avatar_url}
31+
alt={repo.owner.login}
32+
className="rounded-full"
33+
/>
3634
</a>
37-
</h2>
35+
<h2 className="text-3xl cursor-pointer hover:underline text-2023-bavarian-gold-2 whitespace-pre-wrap text-ellipsis overflow-hidden">
36+
<a
37+
href={repo.html_url}
38+
title={repo.name}
39+
target="_blank"
40+
rel="noreferrer"
41+
>
42+
{repo.name}
43+
</a>
44+
</h2>
45+
</div>
46+
<button
47+
className="hover:bg-2023-bavarian-red-2 p-2 text-center stat-title items-center inline-flex rounded-lg transition ease-linear duration-200"
48+
onClick={() => {
49+
const modal = document.getElementById(
50+
'modal'
51+
) as HTMLDialogElement;
52+
if (modal) {
53+
modal.showModal();
54+
}
55+
}}
56+
>
57+
<GoAlertFill className="text-2023-manga-2 outline-none border-none text-lg" />
58+
</button>
3859
</div>
3960

4061
<h6 className="my-5 text-2023-manga-2 text-lg">

‎components/Header.tsx

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,23 @@ import { BsPeopleFill } from 'react-icons/bs';
77

88
import Search, { SearchProps } from './Search';
99

10-
1110
const SearchBar = (props: SearchProps) => {
1211
const router = useRouter();
1312

14-
return (router.pathname === '/repos/[language]' && (
15-
<Search {...props} />
16-
)
17-
)
18-
}
13+
return router.pathname === '/repos/[language]' && <Search {...props} />;
14+
};
1915

2016
function Header() {
2117
return (
2218
<header className="border-b-[0.5px] border-dashed border-b-2023-manga-3 mb-5">
2319
<div className="container mx-auto px-4 py-2">
2420
<div className="justify-between shadow-lg navbar">
2521
<Link href="/">
26-
<img src="/hacktoberfest.svg" alt="Hacktoberfest" className="h-12 w-auto sm:h-auto" />
22+
<img
23+
src="/hacktoberfest.svg"
24+
alt="Hacktoberfest"
25+
className="h-12 w-auto sm:h-auto"
26+
/>
2727
</Link>
2828

2929
<SearchBar searchBarWrapperStyles="hidden sm:inline-flex flex-1 max-w-md px-6" />
@@ -33,7 +33,7 @@ function Header() {
3333
href="/contributors"
3434
className="btn btn-square btn-ghost umami--click--contributors-button "
3535
>
36-
<BsPeopleFill size="1.5rem" color='white' title="Contributors" />
36+
<BsPeopleFill size="1.5rem" color="white" title="Contributors" />
3737
</Link>
3838

3939
<a
@@ -42,15 +42,15 @@ function Header() {
4242
rel="noreferrer"
4343
className="btn btn-square btn-ghost umami--click--github-button ml-"
4444
>
45-
<IoLogoGithub size="1.5rem" color='white' title="GitHub" />
45+
<IoLogoGithub size="1.5rem" color="white" title="GitHub" />
4646
</a>
4747
</div>
48-
</div>
48+
</div>
4949

5050
<SearchBar searchBarWrapperStyles="sm:hidden px-2 mb-3" />
5151
</div>
5252
</header>
5353
);
5454
}
5555

56-
export default Header;
56+
export default Header;

‎components/ReportModal.tsx

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
import { FormEvent } from 'react';
2+
import { useState } from 'react';
3+
import { GoStop } from 'react-icons/go';
4+
5+
function ReportModal() {
6+
const [message, setMessage] = useState('');
7+
const handleSubmit = (e: FormEvent) => {
8+
console.log(message);
9+
// Handle db request here
10+
};
11+
const handleCloseCLick = () => {
12+
const modal = document.getElementById('modal') as HTMLDialogElement;
13+
if (modal) {
14+
modal.close();
15+
}
16+
};
17+
return (
18+
<>
19+
<div>
20+
<dialog id="modal" className="modal modal-bottom sm:modal-middle">
21+
<div className="modal-box md:w-11/12 w-full max-w-2xl">
22+
<h3 className="font-bold text-4xl block mb-2 text-2023-manga-2">
23+
Report This Repository
24+
</h3>
25+
<div className="modal-action flex flex-col">
26+
<p className="text-2023-manga-3 text-lg">
27+
Please provide as much detail as possible to explain why you are
28+
reporting this repository.
29+
<span className="flex gap-2 items-center font-extralight text-sm mt-2 text-2023-bavarian-red-1">
30+
<GoStop className="font-extrabold" />
31+
Note that we may remove the repository
32+
</span>
33+
</p>
34+
35+
<form method="dialog" onSubmit={handleSubmit}>
36+
<textarea
37+
id="reportReason"
38+
name="message"
39+
placeholder="Why do want to report this repository......"
40+
className="textarea-lg textarea textarea-bordered textarea-ghost rounded-md w-full p-2 focus:outline-2023-bavarian-red-1 mt-6 -ml-2 text-white"
41+
onChange={e => setMessage(e.target.value)}
42+
required
43+
/>
44+
<div className="flex mt-4 justify-end items-center ml-6 p-2 space-x-4">
45+
<button className="btn glass shadow-md bg-2023-bavarian-red-2 text-xl text-2023-manga-2 hover:bg-2023-bavarian-red-3">
46+
Report
47+
</button>
48+
</div>
49+
</form>
50+
<button
51+
className="btn btn-md text-sxl btn-circle btn-ghost absolute right-2 top-2"
52+
onClick={handleCloseCLick}
53+
>
54+
✕
55+
</button>
56+
</div>
57+
</div>
58+
<form method="dialog" className="modal-backdrop">
59+
<button className="cursor-default">close</button>
60+
</form>
61+
</dialog>
62+
</div>
63+
</>
64+
);
65+
}
66+
67+
export default ReportModal;

‎components/StarsFilter.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,17 @@ export default function StarsFilter() {
1414
startStars: !router.query.startStars
1515
? ''
1616
: +(router.query.startStars as string),
17-
endStars: !router.query.endStars
18-
? ''
19-
: +(router.query.endStars as string)
17+
endStars: !router.query.endStars ? '' : +(router.query.endStars as string)
2018
}
2119
});
2220

2321
const onSubmit: SubmitHandler<FormValues> = ({ startStars, endStars }) => {
2422
let query;
25-
if (typeof endStars === 'number' && typeof startStars === 'number' && endStars < startStars) {
23+
if (
24+
typeof endStars === 'number' &&
25+
typeof startStars === 'number' &&
26+
endStars < startStars
27+
) {
2628
reset({ startStars, endStars: '' });
2729
query = { startStars };
2830
const { endStars, ...rest } = router.query;

‎package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
"eslint-config-next": "13.5.2",
4141
"postcss": "^8.4.30",
4242
"prettier": "^3.0.3",
43+
"prettier-plugin-tailwindcss": "^0.5.5",
4344
"tailwindcss": "^3.3.3",
4445
"typescript": "5.2.2"
4546
}

‎pages/_app.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import '../styles/globals.css';
1010

1111
import type { AppProps } from 'next/app';
1212
import Footer from 'components/Footer';
13+
import ReportModal from 'components/ReportModal';
1314

1415
function MyApp({ Component, pageProps, router }: AppProps) {
1516
return (
@@ -39,6 +40,7 @@ function MyApp({ Component, pageProps, router }: AppProps) {
3940
<NextNProgress color="#ffd74d" options={{ showSpinner: false }} />
4041
<Component {...pageProps} />
4142
<Footer />
43+
<ReportModal />
4244
</motion.div>
4345
);
4446
}

‎pnpm-lock.yaml

Lines changed: 58 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎xata.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
// Generated by Xata Codegen 0.26.7. Please do not edit.
2-
import { buildClient } from "@xata.io/client";
2+
import { buildClient } from '@xata.io/client';
33
import type {
44
BaseClientOptions,
55
SchemaInference,
6-
XataRecord,
7-
} from "@xata.io/client";
6+
XataRecord
7+
} from '@xata.io/client';
88

9-
const tables = [{ name: "reports", columns: [] }] as const;
9+
const tables = [{ name: 'reports', columns: [] }] as const;
1010

1111
export type SchemaTables = typeof tables;
1212
export type InferredTypes = SchemaInference<SchemaTables>;
1313

14-
export type Reports = InferredTypes["reports"];
14+
export type Reports = InferredTypes['reports'];
1515
export type ReportsRecord = Reports & XataRecord;
1616

1717
export type DatabaseSchema = {
@@ -22,7 +22,7 @@ const DatabaseClient = buildClient();
2222

2323
const defaultOptions = {
2424
databaseURL:
25-
"https://Usman-Sabuwala-s-workspace-u2kcvd.us-east-1.xata.sh/db/project-finder-hf",
25+
'https://Usman-Sabuwala-s-workspace-u2kcvd.us-east-1.xata.sh/db/project-finder-hf'
2626
};
2727

2828
export class XataClient extends DatabaseClient<DatabaseSchema> {

0 commit comments

Comments
 (0)