home.tsx 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  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. dragConfig={{ cancel: ".no-drag" }}
  83. layouts={layouts[tabSelected]}
  84. margin={[15, 15]}
  85. width={width}
  86. >
  87. <div
  88. key="avatar"
  89. className={cn(
  90. "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]",
  91. selectedCard[tabSelected]["avatar"] ? "opacity-100" : "opacity-50",
  92. )}
  93. >
  94. <AvatarTransition avatarUrl={avatarUrl} dogUrl={dogUrl} />
  95. <p className="text-sm md:text-medium">
  96. Hey! I’m <span className="font-oleo text-2xl"> Eric</span>, a
  97. software engineer, hailing from UCLA and Purdue. Currently, I’m
  98. building a cool marketing AI agent. My world revolves around web
  99. development, deep learning, and data science. And yes, I have an
  100. adorable dog named Bert!
  101. </p>
  102. <DockDemo resumeUrl={resumeUrl} />
  103. </div>
  104. <div
  105. key="themeSwitch"
  106. className={cn(
  107. "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]",
  108. selectedCard[tabSelected]["themeSwitch"]
  109. ? "opacity-100"
  110. : "opacity-50",
  111. )}
  112. >
  113. <ThemeSwitch />
  114. </div>
  115. <div
  116. key="cardStack"
  117. className={cn(
  118. "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]",
  119. selectedCard[tabSelected]["cardStack"]
  120. ? "opacity-100"
  121. : "opacity-50",
  122. )}
  123. >
  124. <CardStack photos={photos} />
  125. </div>
  126. <div
  127. key="animatedEmoji"
  128. className={cn(
  129. "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]",
  130. selectedCard[tabSelected]["animatedEmoji"]
  131. ? "opacity-100"
  132. : "opacity-50",
  133. )}
  134. >
  135. <AnimatedEmoji />
  136. </div>
  137. <div
  138. key="mapComponent"
  139. className={cn(
  140. "bg-white dark:bg-darkBg cursor-grab active:cursor-grabbing rounded-[2rem] flex justify-center items-center z-[1]",
  141. selectedCard[tabSelected]["mapComponent"]
  142. ? "opacity-100"
  143. : "opacity-50",
  144. )}
  145. >
  146. <MapComponent />
  147. </div>
  148. <div
  149. key="iconCloud"
  150. className={cn(
  151. "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]",
  152. selectedCard[tabSelected]["iconCloud"]
  153. ? "opacity-100"
  154. : "opacity-50",
  155. )}
  156. >
  157. <IconCloud iconSlugs={icons} />
  158. </div>
  159. <div
  160. key="webAgent"
  161. className={cn(
  162. "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]",
  163. selectedCard[tabSelected]["webAgent"]
  164. ? "opacity-100"
  165. : "opacity-50",
  166. )}
  167. >
  168. <WebAgent webAgentUrl={webagentUrl} />
  169. </div>
  170. <div
  171. key="chatBot"
  172. className={cn(
  173. "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]",
  174. selectedCard[tabSelected]["chatBot"] ? "opacity-100" : "opacity-50",
  175. )}
  176. >
  177. <Chatbot chatbotUrl={chatbotUrl} />
  178. </div>
  179. <div
  180. key="miniModel"
  181. className={cn(
  182. "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",
  183. selectedCard[tabSelected]["miniModel"]
  184. ? "opacity-100"
  185. : "opacity-50",
  186. )}
  187. >
  188. {animated ? <MiniModel /> : <MiniPic />}
  189. <AnimationSwitch
  190. animated={animated}
  191. className="absolute top-4 right-4 z-50"
  192. setAnimated={setAnimated}
  193. />
  194. </div>
  195. <div
  196. key="actions"
  197. className={cn(
  198. "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]",
  199. selectedCard[tabSelected]["actions"] ? "opacity-100" : "opacity-50",
  200. )}
  201. >
  202. <Actions photoUrl={actionImageUrl} />
  203. </div>
  204. <div
  205. key="paper"
  206. className={cn(
  207. "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",
  208. selectedCard[tabSelected]["paper"] ? "opacity-100" : "opacity-50",
  209. )}
  210. >
  211. <Paper paperUrl={paperUrl} />
  212. </div>
  213. </Responsive>
  214. </div>
  215. );
  216. };
  217. export default Home;