home.tsx 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. "use client";
  2. import { Tab, Tabs } from "@heroui/react";
  3. import { Responsive } from "react-grid-layout";
  4. import { useEffect, useState } from "react";
  5. import { useRouter } from "next/navigation";
  6. import Paper from "./paper";
  7. import { AnimationSwitch } from "./animation-swith";
  8. import MiniPic from "./mini-pic";
  9. import { cn } from "@/lib/utils";
  10. import AvatarTransition from "@/components/avatar";
  11. import { DockDemo } from "@/components/dock-demo";
  12. import { ThemeSwitch } from "@/components/theme-switch";
  13. import CardStack from "@/components/card-stack";
  14. import AnimatedEmoji from "@/components/animated-emoji";
  15. import IconCloud from "@/components/icon-cloud";
  16. import MapComponent from "@/components/map";
  17. import WebAgent from "@/components/webagent";
  18. import Chatbot from "@/components/chatbot";
  19. import { MiniModel } from "@/components/mini";
  20. import Actions from "@/components/actions";
  21. import { layouts, selectedCard } from "@/config/layout";
  22. import { icons } from "@/config/icons";
  23. import useWindowWidth from "@/hooks/useWindowWidth";
  24. interface HomeProps {
  25. photos: string[];
  26. avatarUrl: string;
  27. dogUrl: string;
  28. actionImageUrl: string;
  29. resumeUrl: string;
  30. webagentUrl: string;
  31. chatbotUrl: string;
  32. paperUrl: string;
  33. }
  34. const Home = ({
  35. photos,
  36. avatarUrl,
  37. dogUrl,
  38. actionImageUrl,
  39. resumeUrl,
  40. webagentUrl,
  41. chatbotUrl,
  42. paperUrl,
  43. }: HomeProps) => {
  44. const { width } = useWindowWidth();
  45. const [tabSelected, setTabSelected] = useState("all");
  46. const [animated, setAnimated] = useState(false);
  47. const router = useRouter();
  48. useEffect(() => {
  49. router.prefetch("/blog");
  50. }, [router]);
  51. if (!width) {
  52. return null;
  53. }
  54. return (
  55. <div className="flex justify-center flex-col items-center">
  56. <Tabs
  57. aria-label="Tabs"
  58. className="mb-2 md:mb-6 rounded-full"
  59. classNames={{
  60. cursor: "shadow-none",
  61. tabList:
  62. "bg-[#ece7e7] dark:bg-darkBg border-2 border-transparent dark:border-knight rounded-full",
  63. }}
  64. radius={"full"}
  65. onSelectionChange={(selected) => {
  66. if (selected === "blog") {
  67. router.push("/blog");
  68. return;
  69. }
  70. setTabSelected(selected as string);
  71. }}
  72. >
  73. <Tab key="all" title="All" />
  74. <Tab key="about" title="About" />
  75. <Tab key="projects" title="Projects" />
  76. <Tab key="blog" title="Blog" />
  77. </Tabs>
  78. <Responsive
  79. breakpoints={{ lg: 1200, md: 996, sm: 768, xs: 480, xxs: 0 }}
  80. className="layout w-full h-full"
  81. cols={{ lg: 4, md: 4, sm: 2, xs: 2, xxs: 2 }}
  82. layouts={layouts[tabSelected]}
  83. margin={[15, 15]}
  84. width={width}
  85. >
  86. <div
  87. key="avatar"
  88. className={cn(
  89. "bg-white dark:bg-darkBg border-2 border-transparent dark:border-knight cursor-grab active:cursor-grabbing rounded-[2rem] flex flex-col justify-between p-5 overflow-hidden z-[1]",
  90. selectedCard[tabSelected]["avatar"] ? "opacity-100" : "opacity-50",
  91. )}
  92. >
  93. <AvatarTransition avatarUrl={avatarUrl} dogUrl={dogUrl} />
  94. <p className="text-sm md:text-medium">
  95. Hey! I’m <span className="font-oleo text-2xl"> Eric</span>, a
  96. software engineer, hailing from UCLA and Purdue. Currently, I’m
  97. building a cool marketing AI agent. My world revolves around web
  98. development, deep learning, and data science. And yes, I have an
  99. adorable dog named Bert!
  100. </p>
  101. <DockDemo resumeUrl={resumeUrl} />
  102. </div>
  103. <div
  104. key="themeSwitch"
  105. className={cn(
  106. "bg-white dark:bg-darkBg border-2 border-transparent dark:border-knight cursor-grab active:cursor-grabbing rounded-[2rem] flex justify-center items-center z-[1]",
  107. selectedCard[tabSelected]["themeSwitch"]
  108. ? "opacity-100"
  109. : "opacity-50",
  110. )}
  111. >
  112. <ThemeSwitch />
  113. </div>
  114. <div
  115. key="cardStack"
  116. className={cn(
  117. "bg-white dark:bg-darkBg border-2 border-transparent dark:border-knight cursor-grab active:cursor-grabbing rounded-[2rem] flex justify-center items-center z-[2]",
  118. selectedCard[tabSelected]["cardStack"]
  119. ? "opacity-100"
  120. : "opacity-50",
  121. )}
  122. >
  123. <CardStack photos={photos} />
  124. </div>
  125. <div
  126. key="animatedEmoji"
  127. className={cn(
  128. "bg-white dark:bg-darkBg border-2 border-transparent dark:border-knight cursor-grab active:cursor-grabbing rounded-[2rem] flex justify-center items-center z-[1]",
  129. selectedCard[tabSelected]["animatedEmoji"]
  130. ? "opacity-100"
  131. : "opacity-50",
  132. )}
  133. >
  134. <AnimatedEmoji />
  135. </div>
  136. <div
  137. key="mapComponent"
  138. className={cn(
  139. "bg-white dark:bg-darkBg cursor-grab active:cursor-grabbing rounded-[2rem] flex justify-center items-center z-[1]",
  140. selectedCard[tabSelected]["mapComponent"]
  141. ? "opacity-100"
  142. : "opacity-50",
  143. )}
  144. >
  145. <MapComponent />
  146. </div>
  147. <div
  148. key="iconCloud"
  149. className={cn(
  150. "bg-white dark:bg-darkBg border-2 border-transparent dark:border-knight cursor-grab active:cursor-grabbing rounded-[2rem] flex justify-center items-center relative overflow-hidden p-10 md:p-8 z-[1]",
  151. selectedCard[tabSelected]["iconCloud"]
  152. ? "opacity-100"
  153. : "opacity-50",
  154. )}
  155. >
  156. <IconCloud iconSlugs={icons} />
  157. </div>
  158. <div
  159. key="webAgent"
  160. className={cn(
  161. "bg-white dark:bg-darkBg dark:border-2 dark:border-knight cursor-grab active:cursor-grabbing rounded-[2rem] flex justify-center items-center overflow-hidden z-[1]",
  162. selectedCard[tabSelected]["webAgent"]
  163. ? "opacity-100"
  164. : "opacity-50",
  165. )}
  166. >
  167. <WebAgent webAgentUrl={webagentUrl} />
  168. </div>
  169. <div
  170. key="chatBot"
  171. className={cn(
  172. "bg-white dark:bg-darkBg dark:border-2 dark:border-knight cursor-grab active:cursor-grabbing rounded-[2rem] flex justify-center items-center overflow-hidden z-[1]",
  173. selectedCard[tabSelected]["chatBot"] ? "opacity-100" : "opacity-50",
  174. )}
  175. >
  176. <Chatbot chatbotUrl={chatbotUrl} />
  177. </div>
  178. <div
  179. key="miniModel"
  180. className={cn(
  181. "bg-white dark:bg-darkBg border-2 border-transparent dark:border-knight cursor-grab active:cursor-grabbing rounded-[2rem] flex justify-center items-center z-[1] overflow-hidden",
  182. selectedCard[tabSelected]["miniModel"]
  183. ? "opacity-100"
  184. : "opacity-50",
  185. )}
  186. >
  187. {animated ? <MiniModel /> : <MiniPic />}
  188. <AnimationSwitch
  189. animated={animated}
  190. className="absolute top-4 right-4 z-50"
  191. setAnimated={setAnimated}
  192. />
  193. </div>
  194. <div
  195. key="actions"
  196. className={cn(
  197. "bg-white dark:bg-darkBg dark:border-2 dark:border-knight cursor-grab active:cursor-grabbing rounded-[2rem] flex justify-center items-center overflow-hidden z-[1]",
  198. selectedCard[tabSelected]["actions"] ? "opacity-100" : "opacity-50",
  199. )}
  200. >
  201. <Actions photoUrl={actionImageUrl} />
  202. </div>
  203. <div
  204. key="paper"
  205. className={cn(
  206. "bg-white dark:bg-darkBg dark:border-2 dark:border-knight cursor-grab active:cursor-grabbing rounded-[2rem] flex justify-center items-center z-[1] overflow-hidden",
  207. selectedCard[tabSelected]["paper"] ? "opacity-100" : "opacity-50",
  208. )}
  209. >
  210. <Paper paperUrl={paperUrl} />
  211. </div>
  212. </Responsive>
  213. </div>
  214. );
  215. };
  216. export default Home;