Skip to content

Commit

Permalink
Merge pull request #7 from Hkaar/animations
Browse files Browse the repository at this point in the history
Redesigned components
  • Loading branch information
Hkaar authored Oct 23, 2024
2 parents 76ef92a + d69b9c4 commit 76c6ba2
Show file tree
Hide file tree
Showing 17 changed files with 214 additions and 126 deletions.
17 changes: 6 additions & 11 deletions __tests__/page.test.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
import { assert, expect, test } from "vitest";
import { render, screen } from "@testing-library/react";
import { Suspense } from "react";
import Home from "../app/(main)/page";
import { assert, test } from "vitest";

// RESERVED!! STILL FINDING A WAY TO FIX RSC NOT RENDERING
// RESERVED FOR THE FUTURE WHEN ASYNC COMPONENTS WORK IN TESTS
// test("Page", async () => {
// render(
// <Suspense>
// <Home />
// </Suspense>,
// );

// await screen.findByRole("heading", {level: 3, name: "About myself"});
// render(await (async () => await Home())());
// expect(screen.getByRole("heading", { level: 3, name: "About myself" }))
// .toBeDefined();
// });

test('temp', () => { assert(5 == 5) })
test('temp', () => { assert( 5 === 5) })
2 changes: 1 addition & 1 deletion app/(main)/blog/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export default async function BlogPage(props: BlogPageProps) {
</div>

<div className="flex justify-center">
<Pagination href="/blog" query currentId={searchParams.page ? Number(searchParams.page) : 0} maxId={10} />
<Pagination href="/blog" query currentId={searchParams.page ? Number(searchParams.page) : 1} maxId={10} />
</div>
</div>
</div>
Expand Down
6 changes: 5 additions & 1 deletion app/(main)/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ import EducationSection from "@/components/EducationSection";
import ExperienceSection from "@/components/ExperienceSection";
import Hero from "@/components/Hero";
import ProjectSection from "@/components/ProjectSection";
import BlogSectionSkeleton from "@/components/Skeletons/CardSectionSkeleton";
import SkillContainer from "@/components/SkillContainer";
import SlideLeft from "@/components/Transitions/SlideLeft";
import SlideUp from "@/components/Transitions/SlideUp";
import client from "@/lib/client";
import { Suspense } from "react";

export default async function HomePage() {
const skills = await client.fetch(`*[_type == "skill"] | order(name asc) {
Expand Down Expand Up @@ -92,7 +94,9 @@ export default async function HomePage() {
</SectionContent>

<div className="grid place-items-center">
<BlogSection />
<Suspense fallback={<BlogSectionSkeleton />}>
<BlogSection />
</Suspense>
</div>
</ContentSection>

Expand Down
13 changes: 12 additions & 1 deletion app/(main)/projects/page.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
import Button from "@/components/Button";
import ProjectCard from "@/components/Card/ProjectCard";
import InputField from "@/components/InputField";
import Pagination from "@/components/Pagination";
import { Suspense } from "react";

export default function ProjectPage() {
interface ProjectPageProps {
searchParams: Promise<{page: number}>
}

export default async function ProjectPage(props: ProjectPageProps) {
const searchParams = await props.searchParams;

return (
<div className="min-h-screen flex">
<div className="container flex-1 flex flex-col gap-12 py-12">
Expand Down Expand Up @@ -114,6 +121,10 @@ export default function ProjectPage() {
</ProjectCard>
</Suspense>
</div>

<div className="flex justify-center w-full">
<Pagination currentId={searchParams.page ? Number(searchParams.page) : 1} query href="/projects" maxId={10} />
</div>
</div>
</div>
);
Expand Down
39 changes: 24 additions & 15 deletions components/ContactSection/ContactSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import ContactForm from "../ContactForm";
import ContactCard from "../Card/ContactCard";
import SlideRight from "../Transitions/SlideRight";
import SlideLeft from "../Transitions/SlideLeft";
import SlideUp from "../Transitions/SlideUp";

export default function ContactSection() {
return (
Expand All @@ -18,24 +19,32 @@ export default function ContactSection() {
</SectionContent>

<div className="grid grid-cols-1 md:grid-cols-2 gap-3">
<ContactCard
title="Email"
icon="material-symbols-light:mail-outline"
>
[email protected]
</ContactCard>
<SlideUp>
<ContactCard
title="Email"
icon="material-symbols-light:mail-outline"
>
[email protected]
</ContactCard>
</SlideUp>

<ContactCard title="Phone number" icon="mdi-light:phone">
+62 81237102017
</ContactCard>
<SlideUp delay={1.4}>
<ContactCard title="Phone number" icon="mdi-light:phone">
+62 81237102017
</ContactCard>
</SlideUp>

<ContactCard title="Twitter / X" icon="logos:x">
@Hkaar5
</ContactCard>
<SlideUp delay={1.6}>
<ContactCard title="Twitter / X" icon="logos:x">
@Hkaar5
</ContactCard>
</SlideUp>

<ContactCard title="Github" icon="devicon:github">
Hkaar
</ContactCard>
<SlideUp delay={1.8}>
<ContactCard title="Github" icon="devicon:github">
Hkaar
</ContactCard>
</SlideUp>
</div>
</div>
</SlideRight>
Expand Down
2 changes: 1 addition & 1 deletion components/ContentSection/ContentSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default function ContentSection(
{ centered, ...props }: ContentSectionProps,
) {
return (
<section id={props.id} className={twMerge("py-12", props.className)}>
<section id={props.id} className={twMerge("py-8 md:py-12", props.className)}>
{centered
? (
<div className="container flex items-center flex-col gap-12">
Expand Down
63 changes: 37 additions & 26 deletions components/EducationSection/EducationSection.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import { Icon } from "@iconify/react";
import Timeline from "../Timeline";
import TimePoint from "../Timeline/TimePoint";
import SlideUp from "../Transitions/SlideUp";

export default function EducationSection(
{ ...props }: React.HTMLAttributes<HTMLElement>,
) {
return (
<div
className={`${props.className} shadow-md flex flex-col gap-6 lg:gap-0 lg:flex-row items-center w-full border rounded-md border-gray-200 dark:border-gray-800`}
className={`${props.className} shadow-md flex flex-col gap-6 lg:gap-0 lg:flex-row items-center w-full border rounded-md border-gray-200 dark:border-gray-800 h-full`}
>
<div className="flex flex-col gap-3 flex-1 border-r border-gray-200 dark:border-gray-800 w-full lg:w-fit">
<div className="flex flex-col gap-3 flex-1 border-r border-gray-200 dark:border-gray-800 w-full lg:w-fit h-full">
<div className="flex items-center gap-2 px-4 py-3 border-b border-gray-200 dark:border-gray-800 bg-secondary dark:bg-secondary-dark rounded-t-md lg:rounded-tr-none lg:rounded-tl-md text-base-light dark:text-base-dark">
<Icon
icon="material-symbols-light:school-outline"
Expand All @@ -25,24 +26,32 @@ export default function EducationSection(

<div className="px-8 py-3 flex justify-center flex-1 items-center">
<Timeline>
<TimePoint
title="SMK TI Bali Global Badung"
icon="material-symbols-light:school-outline"
date="2022 - Present"
desc="Software Engineering"
/>
<TimePoint
title="SMPN 5 Denpasar"
icon="material-symbols-light:school-outline"
date="2019 - 2022"
desc="General"
/>
<TimePoint
title="SDN 8 Padang Sambian"
icon="material-symbols-light:school-outline"
date="2013 - 2019"
desc="General"
/>
<SlideUp>
<TimePoint
title="SMK TI Bali Global Badung"
icon="material-symbols-light:school-outline"
date="2022 - Present"
desc="Software Engineering"
/>
</SlideUp>

<SlideUp>
<TimePoint
title="SMPN 5 Denpasar"
icon="material-symbols-light:school-outline"
date="2019 - 2022"
desc="General"
/>
</SlideUp>

<SlideUp>
<TimePoint
title="SDN 8 Padang Sambian"
icon="material-symbols-light:school-outline"
date="2013 - 2019"
desc="General"
/>
</SlideUp>
</Timeline>
</div>
</div>
Expand All @@ -63,12 +72,14 @@ export default function EducationSection(

<div className="px-8 py-3 flex justify-center items-center flex-1">
<Timeline>
<TimePoint
title="Axioo Class Program"
icon="mdi:certificate-outline"
date="February 2023"
desc="Robot making & design"
/>
<SlideUp>
<TimePoint
title="Axioo Class Program"
icon="mdi:certificate-outline"
date="February 2023"
desc="Robot making & design"
/>
</SlideUp>
</Timeline>
</div>
</div>
Expand Down
8 changes: 4 additions & 4 deletions components/Header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ export default function Header() {
<Link href="/" className="flex lg:items-center justify-center lg:justify-start gap-2">
<Icon
icon="material-symbols-light:code-blocks"
fontSize={42}
fontSize={36}
fontWeight={300}
>
</Icon>

<h5 className="font-semibold text-2xl">
<h5 className="font-semibold text-2xl d-flex items-center">
Shava Jaya
</h5>
</Link>
Expand All @@ -63,10 +63,10 @@ export default function Header() {
onClick={handleCollapse}
/>
</div>

<div
id="navMenu"
className={`flex lg:items-center flex-col lg:flex-row gap-3 w-full lg:w-fit ${
className={`flex lg:items-center flex-col lg:flex-row gap-3 w-full lg:w-fit transition-all ease-linear duration-200 ${
isCollapsed ? "block" : "hidden lg:flex"
}`}
>
Expand Down
75 changes: 40 additions & 35 deletions components/Pagination/Pagination.tsx
Original file line number Diff line number Diff line change
@@ -1,72 +1,77 @@
import { twMerge } from "tailwind-merge";
import LinkButton from "../LinkButton";
import { randomUUID } from "crypto";

interface PaginationProps extends React.HTMLAttributes<HTMLElement> {
currentId: number;
href: string;
maxId: number;
query?: boolean
query?: boolean;
}

const generateIds = (id: number, amount: number, maxId: number) => {
const generateIds = (currentId: number, maxId: number) => {
const results: Array<number> = [];
const totalDisplayed = 3;

Array(amount).keys().forEach(i => {
if ((id + i) < maxId) {
results.push(id + i);
} else {
results.push(id - i)
}
});
let start = Math.max(1, currentId - Math.floor(totalDisplayed / 2));
const end = Math.min(maxId, start + totalDisplayed);

if (end === maxId) {
start = Math.max(1, maxId - totalDisplayed);
}

for (let i = start; i < end; i++) {
results.push(i);
}

return results;
};

export default function Pagination(
{ currentId, maxId, href, query, ...props }: PaginationProps,
) {
const idList = generateIds(currentId, 5, maxId).toSorted((a, b) => a - b);
const idList = generateIds(currentId, maxId+1);

return (
<div className={twMerge("flex items-center gap-2 w-fit", props.className)}>
{currentId > 0
? (
<LinkButton
{currentId > 0 && (
<LinkButton
className="px-3 py-2"
href={`${href}${query ? '?page=' : '/'}${currentId - 1}`}
icon="mdi-light:arrow-left"
>
href={`${href}${query ? "?page=" : "/"}${currentId - 1}`}
icon="mdi-light:arrow-left"
>
<span className="hidden lg:block">
Previous
</LinkButton>
)
: null}
</span>
</LinkButton>
)}

{idList.map((id) => (
<LinkButton
className="px-3 py-2"
key={`paginator-${randomUUID()}`}
href={`${href}${query ? '?page=' : '/'}${id}`}
type="tertiary"
key={`paginator-${id}`} // Use id as key
href={`${href}${query ? "?page=" : "/"}${id}`}
type={id === currentId ? "primary" : "tertiary"} // Highlight current page
>
<span className="px-1">
<span
className={twMerge("px-1", id === currentId ? "bg-opacity-50" : "")}
>
{id}
</span>
</LinkButton>
))}

{currentId < maxId
? (
<LinkButton
className="px-4 py-2"
href={`${href}${query ? '?page=' : '/'}${currentId + 1}`}
icon="mdi-light:arrow-right"
rightIcon
>
{currentId <= maxId - 1 && (
<LinkButton
className="px-4 py-2"
href={`${href}${query ? "?page=" : "/"}${currentId + 1}`}
icon="mdi-light:arrow-right"
rightIcon
>
<span className="hidden lg:block">
Next
</LinkButton>
)
: null}
</span>
</LinkButton>
)}
</div>
);
}
Loading

0 comments on commit 76c6ba2

Please sign in to comment.