feat(frontend): implement SectionAnchorTabs for improved navigation

- Replaced the existing navigation in PromptEditor and PanelAnchorNavigation with the new SectionAnchorTabs component for better code reuse and consistency.
- The SectionAnchorTabs component provides a shared interface for section navigation with equal-width columns and an active state indicator.
This commit is contained in:
Eric Wang
2026-08-05 10:00:16 +08:00
parent 6863567fa9
commit aa72c522c2
3 changed files with 100 additions and 56 deletions
@@ -3,6 +3,8 @@
import type { ReactNode } from "react";
import { useEffect, useRef, useState } from "react";
import { SectionAnchorTabs } from "@/components/editor/section-anchor-tabs";
export type PanelAnchorSection = {
id: string;
label: string;
@@ -128,33 +130,13 @@ export function PanelAnchorNavigation({
return (
<div className="flex min-h-0 flex-1 flex-col bg-canvas-soft">
{sections.length > 1 && (
<nav
aria-label={ariaLabel}
className="shrink-0 overflow-x-auto overscroll-none border-b border-hairline bg-card px-4"
>
<div className="flex min-w-max">
{sections.map((section) => {
const active = resolvedActiveSection === section.id;
return (
<button
key={section.id}
type="button"
aria-current={active ? "location" : undefined}
onClick={() => scrollToSection(section.id)}
className={[
"-mb-px min-w-24 whitespace-nowrap border-b-2 px-3 py-2.5 text-center text-xs transition-colors",
active
? "border-primary text-foreground"
: "border-transparent text-muted-foreground hover:bg-surface-strong/50 hover:text-foreground",
].join(" ")}
>
{section.label}
</button>
);
})}
</div>
</nav>
<SectionAnchorTabs
ariaLabel={ariaLabel}
sections={sections}
activeSectionId={resolvedActiveSection}
onSelect={scrollToSection}
className="bg-card px-4"
/>
)}
<div