From 992ff40fb67d26897b48ea3cfe27b0ba4097b9dc Mon Sep 17 00:00:00 2001 From: nomi-nonsz Date: Tue, 2 Sep 2025 08:01:53 +0700 Subject: [PATCH] Another window? --- src/app/globals.css | 12 +++++++ src/app/page.tsx | 3 +- src/components/client-windows.tsx | 47 +++++++++++++++++++++++---- src/components/home-text.mdx | 34 +------------------- src/components/windows.tsx | 53 +++++++++++++++++++++++++++++++ tailwind.config.ts | 7 +++- 6 files changed, 115 insertions(+), 41 deletions(-) diff --git a/src/app/globals.css b/src/app/globals.css index 1477ae1..12f9857 100644 --- a/src/app/globals.css +++ b/src/app/globals.css @@ -30,6 +30,18 @@ } } +@keyframes window-popdown { + 0% { + transform: scale(1, 1); + } + 60% { + transform: scale(1, 0.03); + } + 100% { + transform: scale(0, 0.03); + } +} + h2 { @apply text-2xl font-bold } diff --git a/src/app/page.tsx b/src/app/page.tsx index d5870bc..25677d1 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -4,13 +4,14 @@ import { Sosmed } from "@/components/sosmed"; import HomeText from "@/components/home-text.mdx" import Link from "next/link"; -import { FakeWindow } from "@/components/windows"; +import { FakeWindow, HomeWindows } from "@/components/windows"; import Taskbar from "@/components/taskbar"; export default function Home() { return (<>
+

Nonszy Workspace diff --git a/src/components/client-windows.tsx b/src/components/client-windows.tsx index 822fb2b..377f99b 100644 --- a/src/components/client-windows.tsx +++ b/src/components/client-windows.tsx @@ -2,18 +2,27 @@ import { Icon } from "@iconify/react"; import clsx from "clsx"; -import { useState, useRef } from "react"; +import { useState, useRef, useEffect } from "react"; export const FakeRelativeWindow = ({ - windowText, className, draggable, children + windowText, + className, + draggable, + withAnim, + children }: { windowText: string, className?: string, - draggable?: boolean + draggable?: boolean, + withAnim?: boolean, children: React.ReactNode }) => { const [isMinimized, setMinimize] = useState(false); const [offset, setOffset] = useState({ x: 0, y: 0 }); + const [animation, setAnimation] = useState({ + window: "animate-window-popup", + content: "animate-[fade-in-half_1s]" + }); const popupRef = useRef(null); const pos = useRef({ dragging: false, @@ -23,9 +32,34 @@ export const FakeRelativeWindow = ({ y: 0 }); + useEffect(() => { + if (!withAnim) return; + const node = popupRef.current; + if (!node) return; + const observer = new window.IntersectionObserver( + ([entry]) => { + if (entry.isIntersecting) { + setAnimation({ + window: "animate-window-popup", + content: "animate-[fade-in-half_1s]" + }); + } else { + setAnimation({ + window: "scale-x-0 scale-y-[0.03] animate-window-popdown", + content: "animate-[fade-out-half_1s]" + }); + } + }, + { threshold: 0.5 } + ); + observer.observe(node); + return () => observer.disconnect(); + }, []); + const toggleMinimize = () => setMinimize(!isMinimized); const onMouseDown = (e: React.MouseEvent) => { + if (!draggable) return; if (popupRef.current) { pos.current.dragging = true; pos.current.mouseX = e.clientX; @@ -57,8 +91,8 @@ export const FakeRelativeWindow = ({ }; return ( -
-
+ +) + +export const HomeWindows = () => ( +
+ + + Nola + + + + + Bounce Coral + + + + Coral 1 + + + Coral Cupcake + +
) \ No newline at end of file diff --git a/tailwind.config.ts b/tailwind.config.ts index 8fdcebd..7fce617 100644 --- a/tailwind.config.ts +++ b/tailwind.config.ts @@ -24,12 +24,17 @@ const config: Config = { }, animation: { "silly-bouncing": 'silly-bounce 0.8s infinite', - 'window-popup': 'window-popup 1s' + 'window-popup': 'window-popup 1s', + 'window-popdown': 'window-popdown 1s' }, keyframes: { "fade-in-half": { '0%, 50%': { opacity: "0" }, '100%': { opacity: '1' }, + }, + "fade-out-half": { + '0%, 50%': { opacity: "1" }, + '100%': { opacity: '0' }, } } },