SectionHeading gets the new sectionHeading text style: uppercase, the shared caps letter-spacing, 26px on phones and 30px from md. The text in the DOM does not change, so accessible names stay as they are. The plain sectionTitle style stays for the headings that do not use SectionHeading. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
57 lines
1.7 KiB
TypeScript
57 lines
1.7 KiB
TypeScript
import type { ReactNode } from 'react';
|
|
import { Box, Heading, Text } from '@chakra-ui/react';
|
|
import Eyebrow from '@/components/Eyebrow/Eyebrow';
|
|
|
|
type SectionHeadingProps = {
|
|
// Referenced by the section's aria-labelledby
|
|
id: string;
|
|
title: string;
|
|
eyebrow?: string;
|
|
// Text, or e.g. a link as in the Instagram section
|
|
lead?: ReactNode;
|
|
align?: 'center' | 'start';
|
|
// compact: little space below, for a heading above running text
|
|
spacing?: 'default' | 'compact';
|
|
// Lets code move focus to the heading (no visible ring, theme rule)
|
|
focusable?: boolean;
|
|
};
|
|
|
|
// Heading block of a section (design .section__head): optional small label,
|
|
// the h2 in letter-spaced capitals (the case is only CSS, the text stays as
|
|
// given) and an optional intro sentence.
|
|
export default function SectionHeading({
|
|
id,
|
|
title,
|
|
eyebrow,
|
|
lead,
|
|
align = 'center',
|
|
spacing = 'default',
|
|
focusable = false,
|
|
}: SectionHeadingProps) {
|
|
const centered = align === 'center';
|
|
|
|
return (
|
|
<Box
|
|
maxW="620px"
|
|
mx={centered ? 'auto' : undefined}
|
|
mb={spacing === 'compact' ? 6 : 'sectionHeadGap'}
|
|
textAlign={centered ? 'center' : 'start'}
|
|
>
|
|
{eyebrow && <Eyebrow>{eyebrow}</Eyebrow>}
|
|
<Heading
|
|
as="h2"
|
|
id={id}
|
|
textStyle="sectionHeading"
|
|
tabIndex={focusable ? -1 : undefined}
|
|
>
|
|
{title}
|
|
</Heading>
|
|
{lead && (
|
|
<Text textStyle="lead" color="ink.soft" mt={2}>
|
|
{lead}
|
|
</Text>
|
|
)}
|
|
</Box>
|
|
);
|
|
}
|