2026-05-07 12:46:31 +03:00
|
|
|
import Link from 'next/link';
|
2026-04-24 08:38:00 +03:00
|
|
|
import type { ReactNode } from 'react';
|
2026-05-12 16:10:50 +03:00
|
|
|
import { ViewTransitionWrapper } from '$shared/ui';
|
2026-04-19 08:27:08 +03:00
|
|
|
|
2026-07-14 17:05:31 +03:00
|
|
|
interface SectionPanelProps {
|
2026-04-19 08:27:08 +03:00
|
|
|
/**
|
|
|
|
|
* Display number prefix (e.g. "01")
|
|
|
|
|
*/
|
2026-04-24 08:38:00 +03:00
|
|
|
number: string;
|
2026-04-19 08:27:08 +03:00
|
|
|
/**
|
|
|
|
|
* Section title
|
|
|
|
|
*/
|
2026-04-24 08:38:00 +03:00
|
|
|
title: string;
|
2026-04-19 08:27:08 +03:00
|
|
|
/**
|
|
|
|
|
* HTML id for anchor navigation
|
|
|
|
|
*/
|
2026-04-24 08:38:00 +03:00
|
|
|
id: string;
|
2026-04-19 08:27:08 +03:00
|
|
|
/**
|
|
|
|
|
* Whether this section is expanded
|
|
|
|
|
*/
|
2026-04-24 08:38:00 +03:00
|
|
|
isActive: boolean;
|
2026-04-19 08:27:08 +03:00
|
|
|
/**
|
2026-05-07 12:46:31 +03:00
|
|
|
* Navigation URL for the collapsed heading link
|
2026-04-19 08:27:08 +03:00
|
|
|
*/
|
2026-05-07 12:46:31 +03:00
|
|
|
href: string;
|
2026-04-19 08:27:08 +03:00
|
|
|
/**
|
|
|
|
|
* Section content, shown when active
|
|
|
|
|
*/
|
2026-04-24 08:38:00 +03:00
|
|
|
children: ReactNode;
|
2026-04-19 08:27:08 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2026-05-07 12:46:31 +03:00
|
|
|
* Accordion-style section that collapses to a navigation link when inactive.
|
2026-04-19 08:27:08 +03:00
|
|
|
*/
|
2026-07-14 17:05:31 +03:00
|
|
|
export function SectionPanel({ number, title, id, isActive, href, children }: SectionPanelProps) {
|
2026-05-18 12:39:07 +03:00
|
|
|
const heading = `${number}. ${title}`;
|
|
|
|
|
|
2026-04-19 08:27:08 +03:00
|
|
|
return (
|
|
|
|
|
<section id={id} className="scroll-mt-8">
|
|
|
|
|
{isActive ? (
|
2026-07-14 16:59:48 +03:00
|
|
|
<div className="mb-section-gap">
|
2026-05-22 14:07:26 +03:00
|
|
|
<ViewTransitionWrapper name="section-title">
|
2026-07-14 16:59:48 +03:00
|
|
|
<div className="mb-section-gap">
|
|
|
|
|
<h1 className="font-heading font-black text-xl sm:text-section-title leading-[1.2] mb-0 py-0.5">
|
|
|
|
|
{heading}
|
|
|
|
|
</h1>
|
2026-05-12 16:10:50 +03:00
|
|
|
</div>
|
2026-05-13 09:39:08 +03:00
|
|
|
</ViewTransitionWrapper>
|
|
|
|
|
<ViewTransitionWrapper name="section-body">
|
2026-05-22 14:07:26 +03:00
|
|
|
<div>{children}</div>
|
2026-05-13 09:39:08 +03:00
|
|
|
</ViewTransitionWrapper>
|
|
|
|
|
</div>
|
2026-04-19 08:27:08 +03:00
|
|
|
) : (
|
2026-05-18 12:39:07 +03:00
|
|
|
<Link
|
|
|
|
|
href={href}
|
|
|
|
|
aria-label={heading}
|
2026-07-14 16:59:48 +03:00
|
|
|
className="block w-full text-left text-xl sm:text-nav-title py-0.5 group border-b-0 hover:border-b-0"
|
2026-05-18 12:39:07 +03:00
|
|
|
>
|
2026-07-14 16:59:48 +03:00
|
|
|
<span className="block font-heading font-wonk font-black opacity-30 group-hover:opacity-60 transition-opacity duration-200">
|
2026-05-18 12:39:07 +03:00
|
|
|
{heading}
|
|
|
|
|
</span>
|
2026-05-07 12:46:31 +03:00
|
|
|
</Link>
|
2026-04-19 08:27:08 +03:00
|
|
|
)}
|
|
|
|
|
</section>
|
2026-04-24 08:38:00 +03:00
|
|
|
);
|
2026-04-19 08:27:08 +03:00
|
|
|
}
|