Skip to content

Commit 81f092d

Browse files
refactor: results to new component
1 parent 02594e2 commit 81f092d

File tree

3 files changed

+44
-29
lines changed

3 files changed

+44
-29
lines changed

src/app/page.tsx

Lines changed: 3 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22

33
import { useEffect, useState } from "react";
44
import { FollowerListSchema, FollowingListSchema } from "@/lib/types";
5-
import { Github, RotateCw} from "lucide-react";
5+
import { Github } from "lucide-react";
66
import ExtractNamesFromJson from "@/lib/extractNamesFromJson";
77
import Compare from "@/lib/comparison";
88
import HeroSection from "@/components/HeroSection";
9+
import ResultsSection from "@/components/ResultsSection";
910
export default function Home() {
1011
const [followers, setFollowers] = useState<string[]>([]);
1112
const [following, setFollowing] = useState<string[]>([]);
@@ -75,33 +76,7 @@ export default function Home() {
7576
{!hasProcessedDifference ? (
7677
<HeroSection onDrop={onDrop} hasProcessedFollowers={hasProcessedFollowers} hasProcessedFollowing={hasProcessedFollowing}></HeroSection>
7778
) : (
78-
<section className="flex flex-col items-center">
79-
<button
80-
onClick={handleReset}
81-
aria-label="Reset Button"
82-
className="py-4 transform transition hover:rotate-90 cursor-pointer "
83-
>
84-
<RotateCw size={40}></RotateCw>
85-
</button>
86-
<p className="text-2xl mb-6 text-center">
87-
Accounts that don&apos;t follow you back - {userDifference.length}
88-
</p>
89-
90-
<ol className="flex flex-row flex-wrap container mx-auto gap-1.5 sm:gap-2.5 justify-center">
91-
{userDifference.map((userName) => (
92-
<li key={userName} aria-label={userName}>
93-
<a
94-
className="text-s m-1 inline-block rounded-full border-2 border-l-8 bg-slate-100 px-3 py-1 text-border cursor-pointer transition transform hover:scale-110"
95-
href={`https://www.instagram.com/${userName}/`}
96-
target="_blank"
97-
rel="noopener noreferrer"
98-
>
99-
{userName}
100-
</a>
101-
</li>
102-
))}
103-
</ol>
104-
</section>
79+
<ResultsSection handleReset={handleReset} userDifference={userDifference}></ResultsSection>
10580
)}
10681
</main>
10782

src/components/ResultsSection.tsx

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import React from "react";
2+
import { RotateCw } from "lucide-react";
3+
import { ResultsSectionProps } from "@/lib/types";
4+
5+
export default function ResultsSection({handleReset, userDifference} : ResultsSectionProps) {
6+
return (
7+
<section className="flex flex-col items-center">
8+
<button
9+
onClick={handleReset}
10+
aria-label="Reset Button"
11+
className="py-4 transform transition hover:rotate-90 cursor-pointer "
12+
>
13+
<RotateCw size={40}></RotateCw>
14+
</button>
15+
<p className="text-2xl mb-6 text-center">
16+
Accounts that don&apos;t follow you back - {userDifference.length}
17+
</p>
18+
19+
<ol className="flex flex-row flex-wrap container mx-auto gap-1.5 sm:gap-2.5 justify-center">
20+
{userDifference.map((userName) => (
21+
<li key={userName} aria-label={userName}>
22+
<a
23+
className="text-s m-1 inline-block rounded-full border-2 border-l-8 bg-slate-100 px-3 py-1 text-border cursor-pointer transition transform hover:scale-110"
24+
href={`https://www.instagram.com/${userName}/`}
25+
target="_blank"
26+
rel="noopener noreferrer"
27+
>
28+
{userName}
29+
</a>
30+
</li>
31+
))}
32+
</ol>
33+
</section>
34+
);
35+
}

src/lib/types.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,16 @@ export type FollowerList = z.infer<typeof FollowerListSchema>;
3535

3636

3737
// =========== //
38-
// Interface for Hero Section
38+
// Component Interfaces
3939
// =========== //
4040

4141
export interface HeroSectionProps{
4242
hasProcessedFollowers : boolean;
4343
hasProcessedFollowing : boolean;
4444
onDrop: (acceptedFiles: File[]) => void;
45+
}
46+
47+
export interface ResultsSectionProps{
48+
handleReset: () => void;
49+
userDifference: string[];
4550
}

0 commit comments

Comments
 (0)