home.tsx 8.0 KB

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