33import { getMdxHeadings } from "@/_design-system/mdx-components/get-mdx-headings"
44import { type ReactNode , useRef , useLayoutEffect , useState } from "react"
55import ArrowDown from "@/app/conf/_design-system/pixelarticons/arrow-down.svg?svgr"
6+ import BestPracticesIcon from "./decorations/best-practices.svg?svgr"
7+ import FrontendIcon from "./decorations/frontend.svg?svgr"
8+ import GeneralIcon from "./decorations/general.svg?svgr"
9+ import GettingStartedIcon from "./decorations/getting-started.svg?svgr"
10+ import SpecificationIcon from "./decorations/specification.svg?svgr"
611
712function slugify ( text : string ) : string {
813 return String ( text )
@@ -13,24 +18,42 @@ function slugify(text: string): string {
1318
1419const mdxHeadings = getMdxHeadings ( )
1520
21+ const iconMap : Record < string , typeof GettingStartedIcon > = {
22+ "getting-started" : GettingStartedIcon ,
23+ "best-practices" : BestPracticesIcon ,
24+ frontend : FrontendIcon ,
25+ general : GeneralIcon ,
26+ specification : SpecificationIcon ,
27+ }
28+
1629function FaqH1 ( { id, children } : { id ?: string ; children ?: ReactNode } ) {
1730 const slug = id ?? slugify ( String ( children ) )
31+ const Icon = iconMap [ slug ] ?? GeneralIcon
32+
1833 return (
19- < mdxHeadings . h2
20- id = { slug }
21- size = "h1"
22- className = "mb-4 mt-8 scroll-mt-24 text-neu-900 first:mt-0"
34+ < div
35+ data-heading
36+ className = "mb-4 mt-8 flex items-center border border-neu-400 first:mt-0 dark:border-neu-100"
2337 >
24- { children }
25- </ mdxHeadings . h2 >
38+ < div className = "flex size-[90px] shrink-0 items-center justify-center border-r border-inherit bg-neu-100 p-4 dark:bg-neu-50/50" >
39+ < Icon className = "size-full text-neu-800" />
40+ </ div >
41+ < mdxHeadings . h2
42+ id = { slug }
43+ size = "h1"
44+ className = "!mt-0 flex-1 px-4 text-neu-900"
45+ >
46+ { children }
47+ </ mdxHeadings . h2 >
48+ </ div >
2649 )
2750}
2851
2952function FaqH2 ( { id, children } : { id ?: string ; children ?: ReactNode } ) {
3053 const slug = id ?? slugify ( String ( children ) )
3154 return (
32- < details className = "group mt-4 border border-neu-400 bg-neu-0 *:px-3 dark:border-neu-200 lg:mt-6 [&:first-of-type]:border-t [&>:last-child]:mb-3 [&>p:first-of-type]:!mt-3" >
33- < summary className = "gql-focus-visible flex cursor-pointer list-none items-center justify-between gap-4 p-3 group-open:border-b group-hover:bg-neu-100 [&::-webkit-details-marker]:hidden" >
55+ < details className = "group mt-4 border border-neu-400 bg-neu-0 *:px-3 dark:border-neu-100 lg:mt-6 [&:first-of-type]:border-t [&>:last-child]:mb-3 [&>p:first-of-type]:!mt-3" >
56+ < summary className = "gql-focus-visible flex cursor-pointer list-none items-center justify-between gap-4 p-3 hover:bg-neu-100 group-open:border-b group-open:border-neu-400 dark: hover:bg-neu-50/50 dark:group-open:border -neu-100 [&::-webkit-details-marker]:hidden" >
3457 < h3 id = { slug } className = "typography-body-lg text-neu-900" >
3558 { children }
3659 </ h3 >
@@ -56,7 +79,11 @@ export function FaqAggregator({ children }: { children: ReactNode }) {
5679 while ( sibling ) {
5780 const next = sibling . nextSibling
5881 if ( sibling instanceof Element ) {
59- if ( sibling . tagName === "DETAILS" || sibling . tagName === "H2" ) break
82+ if (
83+ sibling . tagName === "DETAILS" ||
84+ ( sibling as HTMLElement ) . dataset ?. heading
85+ )
86+ break
6087 answerContent . push ( sibling )
6188 } else if (
6289 sibling . nodeType === Node . TEXT_NODE &&
0 commit comments