-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
styles: page transtion when clicking on project
- Loading branch information
Showing
5 changed files
with
114 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,66 +1,105 @@ | ||
"use client"; | ||
import React from "react"; | ||
import React, { useState } from "react"; | ||
import { projects } from "./projects"; | ||
import Link from "next/link"; | ||
import { serifText } from "@/assets/fonts"; | ||
import Image from "next/image"; | ||
import useEmblaCarousel from "embla-carousel-react"; | ||
import { useRouter } from "next/navigation"; | ||
import Portal from "../Portal/Portal"; | ||
import { motion } from "framer-motion"; | ||
|
||
interface Props { | ||
excludeProjects?: string[]; | ||
} | ||
|
||
export default function ProjectsSelect({ excludeProjects }: Props) { | ||
const [emblaRef] = useEmblaCarousel(); | ||
const router = useRouter(); | ||
|
||
const [openProject, setOpenProject] = useState< | ||
(typeof projects)[number] | null | ||
>(null); | ||
|
||
const options = projects.filter( | ||
(project) => !excludeProjects?.includes(project.slug) | ||
); | ||
|
||
const onSelectProject = (idx: number) => { | ||
const project = options[idx]; | ||
|
||
if (project.externalLink) { | ||
window.open(project.externalLink, "_blank"); | ||
return; | ||
} | ||
|
||
setOpenProject(project); | ||
router.prefetch(`/project/${project.slug}`); | ||
setTimeout(() => { | ||
router.push(`/project/${project.slug}`); | ||
}, 400); | ||
}; | ||
return ( | ||
<div className="" ref={emblaRef}> | ||
<ul className="flex gap-24"> | ||
{options.map((option, idx) => ( | ||
<li key={idx} className="shrink-0 grow-0 basis-[min(80%,600px)]"> | ||
<Link | ||
href={option.externalLink ?? `/project/${option.slug}`} | ||
{...(option.externalLink && { | ||
target: "_blank", | ||
rel: "noopener noreferrer", | ||
})} | ||
className={`p-24 flex flex-col uppercase border border-gray-900 max-w-[600px] h-full`} | ||
style={{ | ||
...(option.backgroundColor && { | ||
backgroundColor: option.backgroundColor, | ||
}), | ||
}} | ||
<> | ||
<div className="" ref={emblaRef}> | ||
<ul className="flex gap-24"> | ||
{options.map((option, idx) => ( | ||
<motion.li | ||
initial={false} | ||
layout | ||
layoutId={`project-${option.slug}`} | ||
key={idx} | ||
className="shrink-0 grow-0 basis-[min(80%,600px)]" | ||
> | ||
<div className="flex flex-wrap justify-between gap-x-36 gap-y-16 font-medium"> | ||
<div> | ||
<p className="md:text-body1">{option.tagline} </p> | ||
<p className={`${serifText.className} text-body5`}> | ||
{option.title} | ||
</p> | ||
</div> | ||
<div> | ||
{option.tags.map((tag) => ( | ||
<p key={tag} className="whitespace-nowrap"> | ||
/ {tag} | ||
<button | ||
className={`p-24 w-full flex flex-col items-stretch uppercase border-2 max-w-[600px] h-full text-left`} | ||
style={{ | ||
...(option.backgroundColor && { | ||
backgroundColor: option.backgroundColor, | ||
}), | ||
borderColor: option.frameColor, | ||
}} | ||
onClick={() => onSelectProject(idx)} | ||
> | ||
<div className="flex flex-wrap md:flex-nowrap justify-between gap-x-36 gap-y-16 font-medium"> | ||
<div> | ||
<p className="md:text-body1">{option.tagline} </p> | ||
<p className={`${serifText.className} text-body5`}> | ||
{option.title} | ||
</p> | ||
))} | ||
</div> | ||
<div> | ||
{option.tags.map((tag) => ( | ||
<p key={tag} className="whitespace-nowrap"> | ||
/ {tag} | ||
</p> | ||
))} | ||
</div> | ||
</div> | ||
<div className="mt-auto mx-auto"> | ||
<Image | ||
src={option.image} | ||
alt="" | ||
className="max-w-[450px] w-full my-42 shadow-2xl" | ||
/> | ||
</div> | ||
</div> | ||
<div className="mt-auto"> | ||
<Image | ||
src={option.image} | ||
alt="" | ||
className="max-w-[450px] w-full mx-auto my-42 shadow-2xl" | ||
/> | ||
</div> | ||
</Link> | ||
</li> | ||
))} | ||
</ul> | ||
</div> | ||
</button> | ||
</motion.li> | ||
))} | ||
</ul> | ||
</div> | ||
<Portal id="frame-overlay"> | ||
{openProject && ( | ||
<motion.div | ||
className="fixed inset-0 border-[10px] z-50" | ||
layoutId={`project-${openProject.slug}`} | ||
layout | ||
style={{ | ||
backgroundColor: openProject.backgroundColor, | ||
borderColor: openProject.frameColor, | ||
}} | ||
></motion.div> | ||
)} | ||
</Portal> | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import React from "react"; | ||
|
||
interface Props { | ||
children: React.ReactNode; | ||
} | ||
|
||
export default function FadeIn({ children }: Props) { | ||
return <div className="fade-in">{children}</div>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters