Task 4: Add PatientBanner component with full/condensed modes
- Create useScrollCondensation hook with IntersectionObserver - PatientBanner with 80px full mode and 48px condensed mode - Smooth height transition (200ms) on scroll past 100px - Status dot (green) and badge for 'Open to opportunities' - Action buttons: Download CV, Email, LinkedIn - NHS blue outlined buttons with hover fill effect - Proper GPhC number formatting with tooltip - Sticky positioning for persistent visibility
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
import { useState, useEffect, useRef } from 'react'
|
||||
|
||||
interface UseScrollCondensationOptions {
|
||||
threshold?: number
|
||||
}
|
||||
|
||||
export function useScrollCondensation(options: UseScrollCondensationOptions = {}) {
|
||||
const { threshold = 100 } = options
|
||||
const [isCondensed, setIsCondensed] = useState(false)
|
||||
const sentinelRef = useRef<HTMLDivElement>(null)
|
||||
|
||||
useEffect(() => {
|
||||
const sentinel = sentinelRef.current
|
||||
if (!sentinel) return
|
||||
|
||||
const observer = new IntersectionObserver(
|
||||
(entries) => {
|
||||
const [entry] = entries
|
||||
setIsCondensed(!entry.isIntersecting)
|
||||
},
|
||||
{
|
||||
rootMargin: `-${threshold}px 0px 0px 0px`,
|
||||
threshold: 0,
|
||||
}
|
||||
)
|
||||
|
||||
observer.observe(sentinel)
|
||||
|
||||
return () => {
|
||||
observer.disconnect()
|
||||
}
|
||||
}, [threshold])
|
||||
|
||||
return { isCondensed, sentinelRef }
|
||||
}
|
||||
Reference in New Issue
Block a user