Side nav entries take their section's color; the circle stays on the "On this page" heading
Hovered and lit entries use their section's accent (as heading text), the editors' nav keeping the link teal. The circle's leftward shift stops at the heading's center, so short titles no longer pull it off the heading. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
37c555a7b8
commit
7f45006253
2 changed files with 29 additions and 9 deletions
|
|
@ -18,10 +18,14 @@
|
|||
|
||||
import { useEffect, useState } from "react";
|
||||
import { scrollBehavior } from "../../lib/motion.ts";
|
||||
import { accentText } from "../../lib/color.ts";
|
||||
|
||||
export type EditorSection = {
|
||||
id: string;
|
||||
label: string;
|
||||
/** The public pages' section color: its entry takes it when hovered
|
||||
or lit. Without one (the editors), the link teal. */
|
||||
accent?: string;
|
||||
count?: number;
|
||||
hasError?: boolean;
|
||||
};
|
||||
|
|
@ -91,7 +95,7 @@ export function SectionNav({ sections, wrap = false }: { sections: EditorSection
|
|||
|
||||
return (
|
||||
<nav aria-label="Sections" className="hidden max-h-[calc(100vh-8rem)] overflow-y-auto lg:block">
|
||||
<p className="mb-2 px-3 text-xs font-semibold uppercase tracking-wider text-muted/70">
|
||||
<p data-nav-heading className="mb-2 w-fit px-3 text-xs font-semibold uppercase tracking-wider text-muted/70">
|
||||
On this page
|
||||
</p>
|
||||
<ul className="space-y-0.5 border-l border-brand/15">
|
||||
|
|
@ -103,10 +107,15 @@ export function SectionNav({ sections, wrap = false }: { sections: EditorSection
|
|||
type="button"
|
||||
onClick={() => jump(section.id)}
|
||||
aria-current={lit ? "location" : undefined}
|
||||
style={section.accent ? ({ "--nav-accent": accentText(section.accent) } as React.CSSProperties) : undefined}
|
||||
className={`-ml-px flex w-full items-center gap-1.5 border-l-2 px-3 py-1.5 text-left text-sm transition-colors ${
|
||||
lit
|
||||
? "border-brand font-semibold text-link"
|
||||
: "border-transparent text-muted hover:border-brand/40 hover:text-link"
|
||||
section.accent
|
||||
? lit
|
||||
? "border-[var(--nav-accent)] font-semibold text-[var(--nav-accent)]"
|
||||
: "border-transparent text-muted hover:border-[var(--nav-accent)]/40 hover:text-[var(--nav-accent)]"
|
||||
: lit
|
||||
? "border-brand font-semibold text-link"
|
||||
: "border-transparent text-muted hover:border-brand/40 hover:text-link"
|
||||
}`}
|
||||
>
|
||||
<Label section={section} wrap={wrap} />
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue