Skip to content

Commit

Permalink
refactor: refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
HereEast committed Feb 2, 2025
1 parent 9e86bad commit 7438513
Show file tree
Hide file tree
Showing 12 changed files with 134 additions and 137 deletions.
56 changes: 56 additions & 0 deletions src/components/About.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import { SmileIconSolid } from "./icons";

import { cn } from "~/utils/handlers";

export function About() {
const array = new Array(6).fill(0);

return (
<div className="w-full space-y-16">
<div className="space-y-6">
<p
className="text-center text-3xl font-medium sm:text-4xl"
style={{
lineHeight: "110%",
}}
>
This project is for anyone curious about the different paths people
take in their careers. It demystifies job titles, shares daily
routines, highlights and aspirations in a{" "}
<span className="text-gradient bg-[length:200%]">
simple Q&A format.
</span>
</p>
</div>

{/* Icons */}
<div className="space-y-6">
<div className="flex flex-wrap justify-center gap-3">
{array.map((_, index) => (
<div className={cn(index > 3 && "hidden sm:block")} key={index}>
<IconTile />
</div>
))}
</div>

<div className="flex justify-center">
<p className="text-gradient w-fit text-center font-medium leading-tight">
More awesome people are coming!
</p>
</div>
</div>
</div>
);
}

// Icon Tile
function IconTile() {
return (
<div className="group/icon relative flex size-20 shrink-0 items-center justify-center rounded-xl bg-stone-950 bg-[length:200%] transition hover:-translate-y-1 hover:animate-anime-sm hover:bg-gradient-base-diagonal">
<span className="absolute -top-10 flex h-8 w-6 items-center justify-center rounded-full bg-stone-200 text-base font-semibold text-stone-950 opacity-0 group-hover/icon:opacity-100">
?
</span>
<SmileIconSolid className="w-8 fill-stone-50" />
</div>
);
}
12 changes: 0 additions & 12 deletions src/components/IconTile.tsx

This file was deleted.

11 changes: 0 additions & 11 deletions src/components/Label.tsx

This file was deleted.

15 changes: 13 additions & 2 deletions src/components/PersonPreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { ReactNode } from "react";

import { PersonImage } from "./PersonImage";
import { Job, Name } from "./PersonCard";
import { Label } from "./Label";

import { IPerson } from "~/models/Person";

Expand Down Expand Up @@ -36,8 +35,20 @@ export function PersonPreview({ person }: PersonCardProps) {
);
}

// Sticky
// Label
interface LabelProps {
children: string;
}

function Label({ children }: LabelProps) {
return (
<div className="flex w-fit items-center justify-center rounded-full bg-brand-blue-600 py-0.5 pl-1.5 pr-2 text-base font-medium text-stone-50">
{children}
</div>
);
}

// Sticky
function StickyContainer({ children }: { children: ReactNode }) {
return (
<div className="sticky top-[56px] rounded-b-4xl bg-white pt-[15px] md:static md:rounded-4xl md:pt-0">
Expand Down
7 changes: 1 addition & 6 deletions src/components/ShareForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,7 @@ export function ShareForm({ className = "" }: ShareFormCardProps) {
/>
</div>

<Button
type="submit"
disabled={isSubmitting}
isAnimated={true}
className="h-20"
>
<Button disabled={isSubmitting} isAnimated={true} className="h-20">
<div className="flex items-center gap-1.5">
<span className="text-white transition duration-200 group-hover/button:-translate-x-0.5">
share the name
Expand Down
1 change: 0 additions & 1 deletion src/components/SubscribeForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ export function SubscribeForm() {
/>

<Button
type="submit"
disabled={isSubmitting}
className="h-12 animate-anime bg-[length:600%] px-10 hover:bg-gradient-base hover:text-stone-50 sm:w-fit"
>
Expand Down
2 changes: 1 addition & 1 deletion src/components/layouts/Header.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Link from "next/link";

import { ButtonLink } from "../ui/ButtonLink";
import { Logo } from "../Logo";
import { ButtonLink } from "../ui/ButtonLink";
import { ArrowTopRightSquare } from "../icons";

import { PAGE } from "~/utils/types";
Expand Down
59 changes: 9 additions & 50 deletions src/components/layouts/HomePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,21 @@ import { Loader } from "../Loader";
import { PersonCard } from "../PersonCard";
import { ShareForm } from "../ShareForm";
import { SubscribeForm } from "../SubscribeForm";
import { PageContainer } from "./PageContainer";
import { PageLayout } from "./PageLayout";
import { Backlog } from "../Backlog";
import { IconTile } from "../IconTile";
import { About } from "../About";

import { usePeople } from "~/hooks";
import { cn } from "~/utils/handlers";

export function HomePage() {
const { data: people, isLoading } = usePeople();

return (
<PageContainer className="mx-auto py-8 pb-16">
<PageLayout>
{isLoading && <Loader />}

{!isLoading && people && (
<section className="mb-16 flex justify-center">
<section className="mb-16">
<div className="grid w-full grid-cols-[repeat(auto-fit,minmax(260px,1fr))] place-content-center gap-4">
{people?.map((person, index) => (
<div key={index}>
Expand All @@ -31,11 +30,13 @@ export function HomePage() {
)}

<section id="about" className="mb-20">
<About />
<div className="w-full">
<About />
</div>
</section>

<section className="mb-10 flex justify-center">
<div className="max-w-4xl">
<div className="w-full max-w-4xl">
<ShareForm />
</div>
</section>
Expand All @@ -51,48 +52,6 @@ export function HomePage() {
<Backlog />
</div>
</section>
</PageContainer>
);
}

// About
function About() {
const array = new Array(6).fill(0);

return (
<div className="space-y-16">
<div className="space-y-6">
<p
className="text-center text-3xl font-medium sm:text-4xl"
style={{
lineHeight: "110%",
}}
>
This project is for anyone curious about the different paths people
take in their careers. It demystifies job titles, shares daily
routines, highlights and aspirations in a{" "}
<span className="text-gradient bg-[length:200%]">
simple Q&A format.
</span>
</p>
</div>

{/* Icons */}
<div className="space-y-6">
<div className="flex flex-wrap justify-center gap-3">
{array.map((_, index) => (
<div className={cn(index > 3 && "hidden sm:block")} key={index}>
<IconTile />
</div>
))}
</div>

<div className="flex justify-center">
<p className="text-gradient w-fit text-center font-medium leading-tight">
More awesome people are coming!
</p>
</div>
</div>
</div>
</PageLayout>
);
}
19 changes: 0 additions & 19 deletions src/components/layouts/PageContainer.tsx

This file was deleted.

21 changes: 21 additions & 0 deletions src/components/layouts/PageLayout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { ReactNode } from "react";

import { cn } from "~/utils/handlers";

interface PageLayoutProps {
children: ReactNode;
className?: string;
}

export function PageLayout({ children, className = "" }: PageLayoutProps) {
return (
<div
className={cn(
"relative mx-auto max-w-7xl px-2 pb-16 pt-10 sm:px-4",
className,
)}
>
{children}
</div>
);
}
8 changes: 3 additions & 5 deletions src/components/layouts/QAPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Loader } from "../Loader";
import { ShareForm } from "../ShareForm";
import { SidePeoplePanel } from "../SidePeoplePanel";
import { PersonPreview } from "../PersonPreview";
import { PageContainer } from "./PageContainer";
import { PageLayout } from "./PageLayout";
import { Content } from "../Content";

import { useAnswers, usePerson } from "~/hooks";
Expand All @@ -17,16 +17,14 @@ export function QAPage({ slug }: QAPageProps) {
const { data: answers, isLoading: isAnswersLoading } = useAnswers(slug);
const { data: person, isLoading: isPersonLoading } = usePerson(slug);

console.log(answers);

const isLoading = isAnswersLoading && isPersonLoading;

if (isLoading) {
return <Loader />;
}

return (
<PageContainer className="min-h-screen max-w-full gap-10 pb-16 pt-4 sm:pt-8 lg:grid lg:grid-cols-[auto_80px]">
<PageLayout className="min-h-screen max-w-full gap-10 pb-16 pt-4 sm:pt-8 lg:grid lg:grid-cols-[auto_80px]">
{answers && person && (
<>
<div className="space-y-16">
Expand Down Expand Up @@ -65,6 +63,6 @@ export function QAPage({ slug }: QAPageProps) {
</aside>
</>
)}
</PageContainer>
</PageLayout>
);
}
60 changes: 30 additions & 30 deletions src/components/ui/Button.tsx
Original file line number Diff line number Diff line change
@@ -1,41 +1,41 @@
import { ReactNode } from "react";
import { forwardRef, ReactNode } from "react";

import { cn } from "~/utils/handlers";

interface ButtonProps {
type?: "button" | "submit" | "reset";
children: string | ReactNode;
onClick?: () => void;
disabled?: boolean;
className?: string;
isAnimated?: boolean;
}

const noop = (): void => {
return;
};
export const Button = forwardRef<HTMLButtonElement, ButtonProps>(
(
{
children,
disabled = false,
isAnimated = false,
className = "",
...props
},
ref,
) => {
return (
<button
className={cn(
"group/button relative z-10 flex h-14 w-full items-center justify-center rounded-full bg-white text-lg font-bold",
isAnimated && "animate-anime bg-gradient-base bg-[length:600%]",
disabled && "opacity-50",
className,
)}
disabled={disabled}
ref={ref}
{...props}
>
{children}
</button>
);
},
);

export function Button({
children,
onClick = noop,
type = "button",
disabled = false,
className = "",
isAnimated = false,
}: ButtonProps) {
return (
<button
className={cn(
"group/button relative z-10 flex h-14 w-full items-center justify-center rounded-full bg-white text-lg font-bold",
isAnimated && "animate-anime bg-gradient-base bg-[length:600%]",
disabled && "opacity-50",
className,
)}
onClick={onClick}
type={type}
disabled={disabled}
>
{children}
</button>
);
}
Button.displayName = "Button";

0 comments on commit 7438513

Please sign in to comment.