home.tsx 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  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, hailing from UCLA and Purdue. Currently, I’m
  105. building a cool marketing product. My world revolves around web
  106. development. And yes, I have an adorable dog named Bert!
  107. </p>
  108. <DockDemo resumeUrl={resumeUrl} />
  109. </div>
  110. <div
  111. key="themeSwitch"
  112. className={cn(
  113. "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]",
  114. selectedCard[tabSelected]["themeSwitch"]
  115. ? "opacity-100"
  116. : "opacity-50"
  117. )}
  118. >
  119. <ThemeSwitch />
  120. </div>
  121. <div
  122. key="cardStack"
  123. className={cn(
  124. "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]",
  125. selectedCard[tabSelected]["cardStack"]
  126. ? "opacity-100"
  127. : "opacity-50"
  128. )}
  129. >
  130. <CardStack photos={photos} />
  131. </div>
  132. <div
  133. key="animatedEmoji"
  134. className={cn(
  135. "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]",
  136. selectedCard[tabSelected]["animatedEmoji"]
  137. ? "opacity-100"
  138. : "opacity-50"
  139. )}
  140. >
  141. <AnimatedEmoji />
  142. </div>
  143. <div
  144. key="mapComponent"
  145. className={cn(
  146. "bg-white dark:bg-darkBg cursor-grab active:cursor-grabbing rounded-[2rem] flex justify-center items-center z-[1]",
  147. selectedCard[tabSelected]["mapComponent"]
  148. ? "opacity-100"
  149. : "opacity-50"
  150. )}
  151. >
  152. <MapComponent />
  153. </div>
  154. <div
  155. key="iconCloud"
  156. className={cn(
  157. "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]",
  158. selectedCard[tabSelected]["iconCloud"]
  159. ? "opacity-100"
  160. : "opacity-50"
  161. )}
  162. >
  163. <IconCloud iconSlugs={icons} />
  164. </div>
  165. <div
  166. key="webAgent"
  167. className={cn(
  168. "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]",
  169. selectedCard[tabSelected]["webAgent"] ? "opacity-100" : "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;