f94714bbdf
Imports the public marketing site previously living in ../oh-my-opencode-web. Independent of the npm plugin: own package.json, bun.lock, tsconfig.json. Not included in the published package — root files: array still only ships dist/, bin/, postinstall.mjs. Stack: - Next.js 15.5 App Router + RSC, deployed to Cloudflare Workers via @opennextjs/cloudflare (build target .open-next/worker.js). - Tailwind v4 + shadcn/ui primitives. - next-intl with 4 locales (en/ja/ko/zh) under app/[locale]/. - Playwright e2e tests under web/e2e/. - Custom domains ohmyopenagent.com (primary) and ohmyopencode.org (legacy alias) declared in web/wrangler.toml. Source files were re-formatted via `bun run format` to bring them in line with the existing .prettierrc (singleQuote: false). Functional code unchanged.
53 lines
1.2 KiB
TypeScript
53 lines
1.2 KiB
TypeScript
"use client"
|
|
|
|
import { useRef, useEffect, useState } from "react"
|
|
|
|
interface TerminalTypewriterProps {
|
|
text: string
|
|
}
|
|
|
|
export function TerminalTypewriter({ text }: TerminalTypewriterProps) {
|
|
const ref = useRef<HTMLSpanElement>(null)
|
|
const [isInView, setIsInView] = useState(false)
|
|
const [displayed, setDisplayed] = useState("")
|
|
|
|
useEffect(() => {
|
|
const element = ref.current
|
|
if (!element || isInView) return
|
|
|
|
const observer = new IntersectionObserver(
|
|
([entry]) => {
|
|
if (!entry?.isIntersecting) return
|
|
setIsInView(true)
|
|
observer.disconnect()
|
|
},
|
|
{ threshold: 0.1 },
|
|
)
|
|
|
|
observer.observe(element)
|
|
|
|
return () => observer.disconnect()
|
|
}, [isInView])
|
|
|
|
useEffect(() => {
|
|
if (!isInView) return
|
|
let i = 0
|
|
const interval = setInterval(() => {
|
|
if (i <= text.length) {
|
|
setDisplayed(text.slice(0, i))
|
|
i++
|
|
} else {
|
|
clearInterval(interval)
|
|
}
|
|
}, 40)
|
|
return () => clearInterval(interval)
|
|
}, [isInView, text])
|
|
|
|
return (
|
|
<span ref={ref} className="text-zinc-300">
|
|
{displayed}
|
|
{displayed.length < text.length && <span className="animate-pulse">_</span>}
|
|
</span>
|
|
)
|
|
}
|