home.tsx 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. "use client";
  2. import { Tab, Tabs } from "@nextui-org/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. motionProps={{
  65. initial: { scale: 0.8 },
  66. animate: { scale: 1 },
  67. exit: { scale: 0.8 },
  68. transition: { type: "spring", stiffness: 300, damping: 15 },
  69. }}
  70. radius={"full"}
  71. onSelectionChange={(selected) => {
  72. if (selected === "blog") {
  73. router.push("/blog");
  74. return;
  75. }
  76. setTabSelected(selected as string);
  77. }}
  78. >
  79. <Tab key="all" title="All" />
  80. <Tab key="about" title="About" />
  81. <Tab key="projects" title="Projects" />
  82. <Tab key="blog" title="Blog" />
  83. </Tabs>
  84. <Responsive
  85. breakpoints={{ lg: 1200, md: 996, sm: 768, xs: 480, xxs: 0 }}
  86. className="layout w-full h-full"
  87. cols={{ lg: 4, md: 4, sm: 2, xs: 2, xxs: 2 }}
  88. isDraggable={width > 480}
  89. isResizable={false}
  90. layouts={layouts[tabSelected]}
  91. margin={[15, 15]}
  92. width={width}
  93. >
  94. <div
  95. key="avatar"
  96. className={cn(
  97. "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]",
  98. selectedCard[tabSelected]["avatar"] ? "opacity-100" : "opacity-50"
  99. )}
  100. >
  101. <AvatarTransition avatarUrl={avatarUrl} dogUrl={dogUrl} />
  102. <p className="text-sm md:text-medium">
  103. Hey! I’m <span className="font-oleo text-2xl"> Eric</span>, a
  104. software engineer with a knack for AI, hailing from UCLA and Purdue.
  105. Currently, I’m building a cool marketing AI agent. My world revolves
  106. around web development, deep learning, and data science. And yes, I
  107. have an adorable dog named Bert!
  108. </p>
  109. <DockDemo resumeUrl={resumeUrl} />
  110. </div>
  111. <div
  112. key="themeSwitch"
  113. className={cn(
  114. "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]",
  115. selectedCard[tabSelected]["themeSwitch"]
  116. ? "opacity-100"
  117. : "opacity-50"
  118. )}
  119. >
  120. <ThemeSwitch />
  121. </div>
  122. <div
  123. key="cardStack"
  124. className={cn(
  125. "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]",
  126. selectedCard[tabSelected]["cardStack"]
  127. ? "opacity-100"
  128. : "opacity-50"
  129. )}
  130. >
  131. <CardStack photos={photos} />
  132. </div>
  133. <div
  134. key="animatedEmoji"
  135. className={cn(
  136. "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]",
  137. selectedCard[tabSelected]["animatedEmoji"]
  138. ? "opacity-100"
  139. : "opacity-50"
  140. )}
  141. >
  142. <AnimatedEmoji />
  143. </div>
  144. <div
  145. key="mapComponent"
  146. className={cn(
  147. "bg-white dark:bg-darkBg cursor-grab active:cursor-grabbing rounded-[2rem] flex justify-center items-center z-[1]",
  148. selectedCard[tabSelected]["mapComponent"]
  149. ? "opacity-100"
  150. : "opacity-50"
  151. )}
  152. >
  153. <MapComponent />
  154. </div>
  155. <div
  156. key="iconCloud"
  157. className={cn(
  158. "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]",
  159. selectedCard[tabSelected]["iconCloud"]
  160. ? "opacity-100"
  161. : "opacity-50"
  162. )}
  163. >
  164. <IconCloud iconSlugs={icons} />
  165. </div>
  166. <div
  167. key="webAgent"
  168. className={cn(
  169. "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]",
  170. selectedCard[tabSelected]["webAgent"] ? "opacity-100" : "opacity-50"
  171. )}
  172. >
  173. <WebAgent webAgentUrl={webagentUrl} />
  174. </div>
  175. <div
  176. key="chatBot"
  177. className={cn(
  178. "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]",
  179. selectedCard[tabSelected]["chatBot"] ? "opacity-100" : "opacity-50"
  180. )}
  181. >
  182. <Chatbot chatbotUrl={chatbotUrl} />
  183. </div>
  184. <div
  185. key="miniModel"
  186. className={cn(
  187. "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",
  188. selectedCard[tabSelected]["miniModel"]
  189. ? "opacity-100"
  190. : "opacity-50"
  191. )}
  192. >
  193. {animated ? <MiniModel /> : <MiniPic />}
  194. <AnimationSwitch
  195. animated={animated}
  196. className="absolute top-4 right-4 z-50"
  197. setAnimated={setAnimated}
  198. />
  199. </div>
  200. <div
  201. key="actions"
  202. className={cn(
  203. "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]",
  204. selectedCard[tabSelected]["actions"] ? "opacity-100" : "opacity-50"
  205. )}
  206. >
  207. <Actions photoUrl={actionImageUrl} />
  208. </div>
  209. <div
  210. key="paper"
  211. className={cn(
  212. "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",
  213. selectedCard[tabSelected]["paper"] ? "opacity-100" : "opacity-50"
  214. )}
  215. >
  216. <Paper paperUrl={paperUrl} />
  217. </div>
  218. </Responsive>
  219. </div>
  220. );
  221. };
  222. export default Home;