Skip to content

Commit 34a97fa

Browse files
committed
Add icons
1 parent e937a8c commit 34a97fa

File tree

5 files changed

+46
-11
lines changed

5 files changed

+46
-11
lines changed

src/components/faq-aggregator/index.tsx

Lines changed: 36 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
import { getMdxHeadings } from "@/_design-system/mdx-components/get-mdx-headings"
44
import { type ReactNode, useRef, useLayoutEffect, useState } from "react"
55
import 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

712
function slugify(text: string): string {
813
return String(text)
@@ -13,24 +18,42 @@ function slugify(text: string): string {
1318

1419
const 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+
1629
function 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

2952
function 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 &&

src/components/table-of-contents.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ export function TableOfContents({
8686
}[depth],
8787
"block",
8888
activeAnchor[id]?.isActive
89-
? "text-pri-base contrast-more:!text-pri-base"
89+
? "text-pri-base contrast-more:!text-pri-base dark:text-pri-light"
9090
: "",
9191
)}
9292
>

src/nextra-theme-docs.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1585,7 +1585,7 @@ pre
15851585
}
15861586
:target > .subheading-anchor:is(html[class~="dark"] *):after {
15871587
--tw-text-opacity: 1;
1588-
color: rgb(115 115 115 / var(--tw-text-opacity, 1));
1588+
color: rgb(110 117 87 / var(--tw-text-opacity, 1));
15891589
}
15901590
.subheading-anchor:after {
15911591
--tw-content: "#";

src/pages/faq/index.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
---
2+
title: FAQ
3+
---
4+
15
import { FaqAggregator, faqMdxComponents } from "@/components/faq-aggregator"
26

37
import GettingStarted from "./getting-started.mdx"

src/pages/learn/index.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
---
2+
title: Learn
3+
---
4+
15
import { Button } from '@/app/conf/_design-system/button';
26

37
import { NavbarFixed } from '../../components/navbar/navbar-fixed'

0 commit comments

Comments
 (0)