Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 7 additions & 31 deletions apps/sim/app/(landing)/components/collaboration/collaboration.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use client'

import { useCallback, useEffect, useRef, useState } from 'react'
import { useCallback, useId, useRef, useState } from 'react'
import dynamic from 'next/dynamic'
import Image from 'next/image'
import Link from 'next/link'
Expand Down Expand Up @@ -171,8 +171,8 @@ function YouCursor({ x, y, visible }: YouCursorProps) {
* Collaboration section — team workflows and real-time collaboration.
*
* SEO:
* - `<section id="collaboration" aria-labelledby="collaboration-heading">`.
* - `<h2 id="collaboration-heading">` for the section title.
* - `<section id="collaboration">` is the stable anchor for in-page navigation.
* - The section title `<h2>` is linked via `aria-labelledby` using a `useId()`-generated id.
* - Product visuals use `<figure>` with `<figcaption>` and descriptive `alt` text.
*
* GEO:
Expand All @@ -181,41 +181,17 @@ function YouCursor({ x, y, visible }: YouCursorProps) {
* - Reference "Sim" by name per capability ("Sim's real-time collaboration").
*/

const CURSOR_LERP_FACTOR = 0.3

export default function Collaboration() {
const headingId = useId()
const [cursorPos, setCursorPos] = useState({ x: 0, y: 0 })
const [isHovering, setIsHovering] = useState(false)
const sectionRef = useRef<HTMLElement>(null)
const targetPos = useRef({ x: 0, y: 0 })
const animationRef = useRef<number>(0)

useEffect(() => {
const animate = () => {
setCursorPos((prev) => ({
x: prev.x + (targetPos.current.x - prev.x) * CURSOR_LERP_FACTOR,
y: prev.y + (targetPos.current.y - prev.y) * CURSOR_LERP_FACTOR,
}))
animationRef.current = requestAnimationFrame(animate)
}

if (isHovering) {
animationRef.current = requestAnimationFrame(animate)
}

return () => {
if (animationRef.current) {
cancelAnimationFrame(animationRef.current)
}
}
}, [isHovering])

const handleMouseMove = useCallback((e: React.MouseEvent) => {
targetPos.current = { x: e.clientX, y: e.clientY }
setCursorPos({ x: e.clientX, y: e.clientY })
}, [])

const handleMouseEnter = useCallback((e: React.MouseEvent) => {
targetPos.current = { x: e.clientX, y: e.clientY }
setCursorPos({ x: e.clientX, y: e.clientY })
setIsHovering(true)
}, [])
Expand All @@ -228,7 +204,7 @@ export default function Collaboration() {
<section
ref={sectionRef}
id='collaboration'
aria-labelledby='collaboration-heading'
aria-labelledby={headingId}
className='bg-[var(--landing-bg)]'
style={{ cursor: isHovering ? 'none' : 'auto' }}
onMouseMove={handleMouseMove}
Expand Down Expand Up @@ -258,7 +234,7 @@ export default function Collaboration() {
</Badge>

<h2
id='collaboration-heading'
id={headingId}
className='text-balance font-[430] font-season text-[32px] text-white leading-[100%] tracking-[-0.02em] sm:text-[36px] md:text-[40px]'
>
Realtime
Expand Down
Loading