import { useEffect, useRef } from 'react'
import Link from 'next/link'
import { useInView } from 'framer-motion'
import { useSectionStore } from '@/components/SectionProvider'
import { Tag } from '@/components/Tag'
import { remToPx } from '@/lib/remToPx'
function AnchorIcon(props) {
return (
)
}
function Eyebrow({ tag, label }) {
if (!tag && !label) {
return null
}
return (
{tag && {tag}}
{tag && label && (
)}
{label && (
{label}
)}
)
}
function Anchor({ id, inView, children }) {
return (
{inView && (
)}
{children}
)
}
export function Heading({
level = 2,
children,
id,
tag,
label,
anchor = true,
...props
}) {
let Component = `h${level}`
let ref = useRef()
// let registerHeading = useSectionStore((s) => s.registerHeading)
let inView = useInView(ref, {
margin: `${remToPx(-3.5)}px 0px 0px 0px`,
amount: 'all',
})
// useEffect(() => {
// if (level === 2) {
// registerHeading({ id, ref, offsetRem: tag || label ? 8 : 6 })
// }
// })
return (
<>
{anchor ? (
{children}
) : (
children
)}
>
)
}