feat: 본문을 읽는 동안에도 조사 안의 위치가 보인다
레일에는 「이 글에서」만 있었다. 이 글 안의 위치는 알아도 이 조사 안의 위치는 알 수 없었고, 제목 아래의 맥락 덩어리는 화면을 몇 번 넘기면 사라진다. 레일 아래 칸에 프로젝트·주제·종류를 짧게 붙여 따라오게 한다. 관계 목록은 두지 않는다 — 제목 아래에 이미 있고, 같은 목록이 한 화면에 두 번 있으면 목록이 아니라 소음이다. 레일이 둘을 담게 되었으므로 이름도 갈랐다. 「이 글에서」와 「맥락」은 서로 다른 질문에 답한다. 작성자가 확대를 끈 도식도 좁은 화면에서는 확대할 수 있게 했다. 390px 화면에서 폭 1,200px 짜리 도식은 3분의 1 로 눌려 덩어리만 보이고 글자는 읽히지 않는다 — 설명하는 일을 하지 못한다. 기준은 치수다: 본문 폭(720px)보다 넓은 그림은 어디선가 반드시 줄어든다. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015c8cBFUaVr7KLVUx6ujz7D
This commit is contained in:
co-authored by
Claude Opus 5
parent
d3bf3925cf
commit
db4450fe00
@@ -1,4 +1,4 @@
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
import { useEffect, useRef, useState, type ReactNode } from "react";
|
||||
|
||||
type HeadingItem = {
|
||||
id: string;
|
||||
@@ -8,9 +8,14 @@ type HeadingItem = {
|
||||
type DocumentTocProps = {
|
||||
headings: ReadonlyArray<HeadingItem>;
|
||||
variant: "desktop" | "mobile";
|
||||
/**
|
||||
* 데스크톱 레일의 아래 칸. 「이 글에서」와 「맥락」은 서로 다른 질문에 답한다 — 앞은 이 글의
|
||||
* 어디인지, 뒤는 이 조사의 어디인지다. 한 레일에 두되 마디를 갈라 둔다.
|
||||
*/
|
||||
context?: ReactNode;
|
||||
};
|
||||
|
||||
export function DocumentToc({ headings, variant }: DocumentTocProps) {
|
||||
export function DocumentToc({ headings, variant, context }: DocumentTocProps) {
|
||||
const [currentId, setCurrentId] = useState(headings[0]?.id ?? "");
|
||||
const empty = headings.length === 0;
|
||||
const detailsRef = useRef<HTMLDetailsElement>(null);
|
||||
@@ -56,7 +61,7 @@ export function DocumentToc({ headings, variant }: DocumentTocProps) {
|
||||
제목이 없는 문서에는 목차를 그리지 않는다. 예전에는 이 컴포넌트가 픽스처 문서 하나에서만
|
||||
쓰여 빈 경우를 만날 일이 없었지만, 이제 모든 Case 가 지나므로 빈 레일이 남을 수 있다.
|
||||
*/
|
||||
if (empty) return null;
|
||||
if (empty && !(variant === "desktop" && context)) return null;
|
||||
|
||||
if (variant === "mobile") {
|
||||
const current =
|
||||
@@ -86,20 +91,27 @@ export function DocumentToc({ headings, variant }: DocumentTocProps) {
|
||||
}
|
||||
|
||||
return (
|
||||
<aside className="document-toc" aria-label="문서 목차">
|
||||
<p>이 글에서</p>
|
||||
<nav>
|
||||
{headings.map((heading) => (
|
||||
<a
|
||||
href={`#${heading.id}`}
|
||||
key={heading.id}
|
||||
aria-current={heading.id === currentId ? "location" : undefined}
|
||||
onClick={() => select(heading.id)}
|
||||
>
|
||||
{heading.label}
|
||||
</a>
|
||||
))}
|
||||
</nav>
|
||||
/*
|
||||
레일은 이제 둘을 담는다 — 이 글의 어디인지(「이 글에서」)와 이 조사의 어디인지(「맥락」).
|
||||
서로 다른 질문에 답하므로 이름도 따로 준다. 레일 전체의 이름은 그 둘을 아우른다.
|
||||
*/
|
||||
<aside className="document-toc" aria-label="문서 안내">
|
||||
{empty ? null : (
|
||||
<nav aria-label="이 글에서">
|
||||
<p>이 글에서</p>
|
||||
{headings.map((heading) => (
|
||||
<a
|
||||
href={`#${heading.id}`}
|
||||
key={heading.id}
|
||||
aria-current={heading.id === currentId ? "location" : undefined}
|
||||
onClick={() => select(heading.id)}
|
||||
>
|
||||
{heading.label}
|
||||
</a>
|
||||
))}
|
||||
</nav>
|
||||
)}
|
||||
{context}
|
||||
</aside>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -40,7 +40,16 @@ export function PublicEvidenceFigure({
|
||||
? ({ width: asset.width, height: asset.height, loading: "lazy" } as const)
|
||||
: ({ loading: "eager" } as const);
|
||||
|
||||
if (!zoom) {
|
||||
/*
|
||||
작성자가 확대를 끄더라도, 좁은 화면에서 줄여 그릴 그림은 확대할 수 있어야 한다.
|
||||
|
||||
390px 화면에서 폭 1,200px 짜리 도식은 3분의 1 크기로 눌린다. 그 상태의 도식은 덩어리만
|
||||
보이고 글자는 읽히지 않아 설명하는 일을 하지 못한다 — 실제로 공개 화면의 도식들이 그랬다.
|
||||
기준은 치수다: 본문 폭(약 720px)보다 넓은 그림은 어디선가 반드시 줄어든다.
|
||||
*/
|
||||
const zoomable = zoom || asset.width > 720;
|
||||
|
||||
if (!zoomable) {
|
||||
return (
|
||||
<figure className="evidence-figure">
|
||||
<img src={asset.src} alt={alt} {...sizing} />
|
||||
|
||||
@@ -10,6 +10,7 @@ import type {
|
||||
import { CaseBodyRenderer } from "./case-body-renderer.tsx";
|
||||
import { ContextNavigator } from "./context-navigator.tsx";
|
||||
import { DocumentToc } from "./document-toc.tsx";
|
||||
import { RailContext } from "./rail-context.tsx";
|
||||
import {
|
||||
PublicDocumentRelations,
|
||||
type PublicRelation,
|
||||
@@ -241,7 +242,11 @@ function CaseDocument({
|
||||
/>
|
||||
<PublicDocumentRelations relations={publicRelations(model.relations)} />
|
||||
</article>
|
||||
<DocumentToc headings={headings} variant="desktop" />
|
||||
<DocumentToc
|
||||
headings={headings}
|
||||
variant="desktop"
|
||||
context={<RailContext model={model} />}
|
||||
/>
|
||||
</div>
|
||||
</Root>
|
||||
);
|
||||
@@ -318,7 +323,11 @@ function ConceptDocument({
|
||||
/>
|
||||
<PublicDocumentRelations relations={publicRelations(model.relations)} />
|
||||
</article>
|
||||
<DocumentToc headings={headings} variant="desktop" />
|
||||
<DocumentToc
|
||||
headings={headings}
|
||||
variant="desktop"
|
||||
context={<RailContext model={model} />}
|
||||
/>
|
||||
</div>
|
||||
</Root>
|
||||
);
|
||||
@@ -407,7 +416,11 @@ function SetupDocument({
|
||||
/>
|
||||
<PublicDocumentRelations relations={publicRelations(model.relations)} />
|
||||
</article>
|
||||
<DocumentToc headings={headings} variant="desktop" />
|
||||
<DocumentToc
|
||||
headings={headings}
|
||||
variant="desktop"
|
||||
context={<RailContext model={model} />}
|
||||
/>
|
||||
</div>
|
||||
</Root>
|
||||
);
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
import { Link } from "react-router-dom";
|
||||
|
||||
import type { components } from "../../../contracts/studio/generated.ts";
|
||||
import { DOCUMENT_KIND_LABELS } from "../document-kind-labels.ts";
|
||||
|
||||
type PublicRenderModelBase = components["schemas"]["PublicRenderModelBase"];
|
||||
|
||||
/**
|
||||
* 레일에 붙어 따라오는 「지금 어디인가」.
|
||||
*
|
||||
* <p>제목 아래의 맥락 덩어리는 한 번 읽고 지나간다. 본문이 길면 화면을 몇 번 넘긴 뒤에는 이
|
||||
* 기록이 어느 프로젝트의 어느 주제였는지가 화면에서 사라진다 — 레일에는 「이 글에서」만 남아
|
||||
* 이 글 안의 위치는 알아도 조사 안의 위치는 알 수 없었다.
|
||||
*
|
||||
* <p>그래서 레일의 아래 칸에 프로젝트·주제·종류만 짧게 붙여 둔다. 관계 목록은 여기 두지 않는다 —
|
||||
* 그것은 제목 아래에 이미 있고, 같은 목록이 한 화면에 두 번 있으면 목록이 아니라 소음이다.
|
||||
*/
|
||||
export function RailContext({ model }: { model: PublicRenderModelBase }) {
|
||||
const topic = model.topic.label ? model.topic : null;
|
||||
if (!model.project && !topic) return null;
|
||||
|
||||
return (
|
||||
<nav className="rail-context" aria-label="지금 위치">
|
||||
<p>맥락</p>
|
||||
{model.project ? (
|
||||
<span>
|
||||
{model.project.publicPath ? (
|
||||
<Link to={model.project.publicPath}>{model.project.label}</Link>
|
||||
) : (
|
||||
model.project.label
|
||||
)}
|
||||
</span>
|
||||
) : null}
|
||||
{topic ? (
|
||||
<span>
|
||||
{topic.publicPath ? <Link to={topic.publicPath}>{topic.label}</Link> : topic.label}
|
||||
</span>
|
||||
) : null}
|
||||
<span className="rail-context-kind">{DOCUMENT_KIND_LABELS[model.kind]}</span>
|
||||
</nav>
|
||||
);
|
||||
}
|
||||
@@ -3823,3 +3823,40 @@ textarea.studio-control { min-height: 118px; resize: vertical; line-height: 1.65
|
||||
content: "— ";
|
||||
color: var(--line-strong);
|
||||
}
|
||||
|
||||
/* 레일의 아래 칸 — 본문을 읽는 동안에도 조사 안의 위치가 보인다 */
|
||||
|
||||
.rail-context {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 5px;
|
||||
margin-top: 26px;
|
||||
padding-top: 18px;
|
||||
border-top: 1px solid var(--line);
|
||||
}
|
||||
|
||||
.rail-context > p {
|
||||
margin: 0 0 6px;
|
||||
color: var(--faint);
|
||||
font-size: 12px;
|
||||
font-weight: 650;
|
||||
letter-spacing: 0.06em;
|
||||
}
|
||||
|
||||
.rail-context > span {
|
||||
color: var(--ink-soft);
|
||||
font-size: 12.5px;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.rail-context a {
|
||||
color: var(--ink-soft);
|
||||
}
|
||||
|
||||
.rail-context a:hover {
|
||||
color: var(--signal);
|
||||
}
|
||||
|
||||
.rail-context-kind {
|
||||
color: var(--faint) !important;
|
||||
}
|
||||
|
||||
@@ -273,7 +273,9 @@ describe("TechLog canonical Public documents", () => {
|
||||
"href",
|
||||
"#observed-values",
|
||||
);
|
||||
// 좁은 화면의 목차 하나. 넓은 화면의 레일은 「이 글에서」와 「맥락」으로 나뉜다.
|
||||
expect(screen.getAllByRole("navigation", { name: "문서 목차" })).toHaveLength(1);
|
||||
expect(screen.getByRole("navigation", { name: "이 글에서" })).toBeInTheDocument();
|
||||
expect(container.querySelectorAll('[aria-label="코드 복사"]')).toHaveLength(3);
|
||||
|
||||
const image = screen.getByRole("img", {
|
||||
|
||||
@@ -380,9 +380,15 @@ describe("shared Public record renderer", () => {
|
||||
expect(screen.getByText("실험 조건 · 검증 환경과 데이터")).toBeVisible();
|
||||
expect(screen.getByText("수정 중인 데이터셋")).toBeInTheDocument();
|
||||
expect(screen.getByText(/게시 2026\.08\.14 · 마지막 검증 2030\.01\.02/)).toBeInTheDocument();
|
||||
/*
|
||||
좁은 화면의 목차 하나. 넓은 화면의 레일은 「이 글에서」와 「맥락」 둘을 담는 별도 이름을
|
||||
쓴다 — 이 글의 어디인지와 이 조사의 어디인지는 서로 다른 질문이다.
|
||||
*/
|
||||
expect(screen.getAllByRole("navigation", { name: "문서 목차" })).toHaveLength(
|
||||
1,
|
||||
);
|
||||
expect(screen.getByRole("navigation", { name: "이 글에서" })).toBeInTheDocument();
|
||||
expect(screen.getByRole("navigation", { name: "지금 위치" })).toBeInTheDocument();
|
||||
expect(screen.getByText("목차 · 강조 강함 코드")).toBeVisible();
|
||||
expect(screen.getByRole("link", { name: "강조 강함 코드 바로가기" })).toBeVisible();
|
||||
/*
|
||||
@@ -432,8 +438,9 @@ describe("shared Public record renderer", () => {
|
||||
"문제문제결론결론",
|
||||
);
|
||||
expect(screen.getByText("일반 본문")).toBeVisible();
|
||||
// 제목이 없는 본문에는 목차를 그리지 않는다 — 빈 레일만 남는다.
|
||||
expect(screen.queryByLabelText("문서 목차")).toBeNull();
|
||||
// 제목이 없는 본문에는 목차를 그리지 않는다. 맥락은 그대로 남는다.
|
||||
expect(screen.queryByRole("navigation", { name: "문서 목차" })).toBeNull();
|
||||
expect(screen.queryByRole("navigation", { name: "이 글에서" })).toBeNull();
|
||||
});
|
||||
|
||||
it("renders supplied Reference and Question preview fields and empty copy", () => {
|
||||
@@ -651,7 +658,7 @@ describe("shared renderer interactions", () => {
|
||||
variant="desktop"
|
||||
/>,
|
||||
);
|
||||
expect(screen.getByRole("complementary", { name: "문서 목차" })).toHaveTextContent(
|
||||
expect(screen.getByRole("complementary", { name: "문서 안내" })).toHaveTextContent(
|
||||
"이 글에서첫째둘째",
|
||||
);
|
||||
expect(screen.getByRole("link", { name: "첫째" })).toHaveAttribute(
|
||||
|
||||
Reference in New Issue
Block a user