'use client';
import ChevronRightIcon from '@react-spectrum/s2/icons/ChevronRight';
import {getTextWidth} from './textWidth';
import {iconStyle, style} from '@react-spectrum/s2/style' with {type: 'macro'};
import {Link} from '@react-spectrum/s2';
import LinkIcon from '@react-spectrum/s2/icons/Link';
import type {Page} from '@parcel/rsc';
import React, {HTMLAttributes, ReactNode} from 'react';
import {TitleLink} from './Link';
import {useFocusRing} from '@react-aria/focus';
import {useHover} from '@react-aria/interactions';
function childrenToString(children: ReactNode) {
if (typeof children === 'string') {
return children;
}
if (Array.isArray(children)) {
return children.reduce((p, c) => p + childrenToString(c), '');
}
return '';
}
function anchorId(children: ReactNode) {
return childrenToString(children)
.replace(/\s/g, '-')
.replace(/[^a-zA-Z0-9-_]/g, '')
.toLowerCase();
}
function AnchorLink({anchorId, isHovered, level, headingText}) {
let {isFocusVisible, focusProps} = useFocusRing({within: true});
const href = `#${anchorId}`;
return (
);
}
const h1 = style({
font: 'heading-3xl',
// This variable is used to calculate the line height.
// Normally it is set by the fontSize, but the custom clamp prevents this.
'--fs': {
type: 'opacity',
value: {
default: 'pow(1.125, 10)', // heading-2xl
isLongForm: 'pow(1.125, 8)' // heading-xl
}
},
fontSize: {
default: {
// On mobile, adjust heading to fit in the viewport, and clamp between a min and max font size.
default: `clamp(${35 / 16}rem, (100vw - 32px) / var(--width-per-em), ${55 / 16}rem)`,
isLongForm: `clamp(${35 / 16}rem, (100vw - 32px) / var(--width-per-em), ${44 / 16}rem)`
},
lg: {
default: 'heading-3xl',
isLongForm: 'heading-2xl'
}
},
textWrap: 'balance',
marginY: 0,
width: 'full',
maxWidth: '--text-width',
marginX: 'auto'
});
export function H1({children, isLongForm, ...props}) {
return (
{children}
);
}
export function H2({children, ...props}) {
let {hoverProps, isHovered} = useHover({});
let id = anchorId(children);
return (
{children}
);
}
export function H3({children, ...props}) {
let {hoverProps, isHovered} = useHover({});
let id = anchorId(children);
return (
{children}
);
}
export function H4({children, ...props}) {
let {hoverProps, isHovered} = useHover({});
let id = anchorId(children);
return (