mirror of
https://github.com/dong-nz/cv.git
synced 2026-11-23 00:20:40 +07:00
feat(edit): inline editing controls on every record surface (spec-v4-inline-editing §5 steps 1-7)
- EditableText: wrapper zone + pencil trigger (E6), inline validation errors, provenance tooltip + copy-chip (E7) - TagListEditor: per-chip edit/delete/move + ghost add over all six tag arrays, tagline emphasis toggle - RecordControls + AddGhost on About, AboutPage, Expertise, Experience, ExperiencePage, Projects, ProjectsListPage, ProjectDetailPage (incl. sections), PhilosophyPage; RecordSettings popover (featured, section list with type picker, variant, location, logo) - id-slug rename on committed record titles (E3); per-field conflict UI in EditBar; chrome CSS in App.css; labels in both ui.json - JsonPanel kept until the inline surface is verified in a real browser (spec progress row 8); acceptance §6 partial — build, validate:content, lint, smoke-draft pass 2026-10-23
This commit is contained in:
1 parent
753b28a4e3
commit
0a72cd9b58
22 files changed
+1740
-205
No files matched your search
@@ -112,5 +112,7 @@ Page manifests (`spec-v4-data-organization.md` §5) are **read-only in the app**
|
|||||||
| # | Task | Status |
|
| # | Task | Status |
|
||||||
|---|---|---|
|
|---|---|---|
|
||||||
| 0 | Design agreed (E1–E7) | ✅ Done 2026-10-23 |
|
| 0 | Design agreed (E1–E7) | ✅ Done 2026-10-23 |
|
||||||
| 1–9 | Implementation §5 | ⬜ TODO |
|
| 1–7 | Implementation §5 | ✅ Done 2026-10-23 — EditableText zone/pencil/provenance, TagListEditor over all tag arrays, tagline emphasis, `RecordControls` + `AddGhost` on every record surface (About, AboutPage, Expertise, Experience, ExperiencePage, Projects, ProjectsListPage, ProjectDetailPage incl. sections, PhilosophyPage), `RecordSettings` (featured, section list + type picker, variant, location, logo), id-slug rename on title commit, per-field conflict UI in EditBar; chrome CSS in `App.css`, labels in both `ui.json` |
|
||||||
| — | Acceptance §6 | ⬜ TODO |
|
| 8 | Remove `JsonPanel` + panel labels | ⬜ TODO — kept until the inline surface is verified in a real browser |
|
||||||
|
| 9 | Docs superseded notes | ⬜ TODO |
|
||||||
|
| — | Acceptance §6 | 🟡 Partial — `pnpm build`, `pnpm validate:content`, `pnpm lint` (no new warnings), `pnpm tsx scripts/smoke-draft.ts` pass 2026-10-23; browser verification of the edit surfaces pending (user verifies in a real browser) |
|
||||||
+253
@@ -2428,6 +2428,259 @@
|
|||||||
background: var(--accent-tint);
|
background: var(--accent-tint);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Field and record chrome (spec-v4-inline-editing E2/E4/E5): the controls are
|
||||||
|
edit-mode-only islands inside the site's own elements — one bordered icon
|
||||||
|
language (44px targets stay on the bar, 24px here), hover/focus in the
|
||||||
|
accent, delete in the error colour. */
|
||||||
|
.edit-field-controls {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 4px;
|
||||||
|
margin-left: 8px;
|
||||||
|
vertical-align: middle;
|
||||||
|
}
|
||||||
|
|
||||||
|
.edit-pencil,
|
||||||
|
.edit-item-control,
|
||||||
|
.edit-record-btn {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
padding: 3px;
|
||||||
|
border: 1px solid var(--border);
|
||||||
|
border-radius: 4px;
|
||||||
|
background: var(--bg-surface);
|
||||||
|
color: var(--text-muted);
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.edit-pencil:hover,
|
||||||
|
.edit-item-control:hover,
|
||||||
|
.edit-record-btn:hover:not(:disabled) {
|
||||||
|
color: var(--accent);
|
||||||
|
border-color: var(--accent);
|
||||||
|
}
|
||||||
|
|
||||||
|
.edit-pencil:focus-visible,
|
||||||
|
.edit-item-control:focus-visible,
|
||||||
|
.edit-record-btn:focus-visible {
|
||||||
|
outline: 2px solid var(--accent);
|
||||||
|
outline-offset: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.edit-item-control:disabled,
|
||||||
|
.edit-record-btn:disabled {
|
||||||
|
opacity: 0.35;
|
||||||
|
cursor: default;
|
||||||
|
}
|
||||||
|
|
||||||
|
.edit-item-remove:hover,
|
||||||
|
.edit-record-btn.edit-record-remove:hover {
|
||||||
|
color: var(--error);
|
||||||
|
border-color: var(--error);
|
||||||
|
}
|
||||||
|
|
||||||
|
.edit-provenance {
|
||||||
|
max-width: 220px;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
|
font-size: 12px;
|
||||||
|
color: var(--text-muted);
|
||||||
|
border: 1px dashed var(--border);
|
||||||
|
border-radius: 4px;
|
||||||
|
background: none;
|
||||||
|
padding: 2px 6px;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.edit-provenance:hover {
|
||||||
|
color: var(--accent);
|
||||||
|
border-color: var(--accent);
|
||||||
|
}
|
||||||
|
|
||||||
|
.edit-field-error {
|
||||||
|
display: block;
|
||||||
|
font-size: 12px;
|
||||||
|
color: var(--error);
|
||||||
|
margin-top: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.edit-add-inline,
|
||||||
|
.edit-add-ghost {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 5px;
|
||||||
|
border: 1px dashed var(--border-strong);
|
||||||
|
border-radius: 6px;
|
||||||
|
background: transparent;
|
||||||
|
color: var(--text-muted);
|
||||||
|
padding: 6px 10px;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.edit-add-inline:hover,
|
||||||
|
.edit-add-ghost:hover {
|
||||||
|
color: var(--accent);
|
||||||
|
border-color: var(--accent);
|
||||||
|
border-style: solid;
|
||||||
|
}
|
||||||
|
|
||||||
|
.edit-add-ghost-card {
|
||||||
|
justify-content: center;
|
||||||
|
width: 100%;
|
||||||
|
min-height: 160px;
|
||||||
|
border-radius: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* A record whose box hosts the controls (cards, timeline entries, sections)
|
||||||
|
and a grid card whose body is a link (wrapped in a shell) both float the
|
||||||
|
controls at the top-right corner of the record. Elsewhere — the project
|
||||||
|
detail header — they stay in flow. */
|
||||||
|
.edit-record-host,
|
||||||
|
.edit-record-shell {
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
.edit-record-controls {
|
||||||
|
display: inline-flex;
|
||||||
|
gap: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.edit-record-host > .edit-record-controls,
|
||||||
|
.edit-record-shell > .edit-record-controls {
|
||||||
|
position: absolute;
|
||||||
|
top: 8px;
|
||||||
|
right: 8px;
|
||||||
|
z-index: 30;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Record settings dialog (E2): the structure fields of one record —
|
||||||
|
featured, section list, timeline variant, logo. */
|
||||||
|
.record-settings {
|
||||||
|
position: fixed;
|
||||||
|
top: 80px;
|
||||||
|
left: 50%;
|
||||||
|
transform: translateX(-50%);
|
||||||
|
z-index: 960;
|
||||||
|
width: min(560px, calc(100vw - 32px));
|
||||||
|
max-height: min(70vh, 640px);
|
||||||
|
overflow-y: auto;
|
||||||
|
background: var(--bg-elevated);
|
||||||
|
border: 1px solid var(--border-strong);
|
||||||
|
border-radius: 10px;
|
||||||
|
padding: 14px 16px;
|
||||||
|
box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
|
||||||
|
}
|
||||||
|
|
||||||
|
.record-settings-header {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
margin-bottom: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.record-settings-title {
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
.record-settings-close {
|
||||||
|
border: 1px solid var(--border);
|
||||||
|
border-radius: 4px;
|
||||||
|
background: none;
|
||||||
|
color: var(--text-muted);
|
||||||
|
font-size: 16px;
|
||||||
|
line-height: 1;
|
||||||
|
padding: 2px 8px;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.record-settings-close:hover {
|
||||||
|
color: var(--error);
|
||||||
|
border-color: var(--error);
|
||||||
|
}
|
||||||
|
|
||||||
|
.record-settings-group-title {
|
||||||
|
font-size: 12px;
|
||||||
|
text-transform: uppercase;
|
||||||
|
letter-spacing: 0.08em;
|
||||||
|
color: var(--text-muted);
|
||||||
|
margin: 12px 0 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.record-settings-field {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
margin: 8px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.record-settings-field input {
|
||||||
|
background: var(--bg-surface);
|
||||||
|
color: inherit;
|
||||||
|
border: 1px solid var(--border);
|
||||||
|
border-radius: 4px;
|
||||||
|
padding: 4px 8px;
|
||||||
|
min-width: 220px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.record-settings-list {
|
||||||
|
list-style: none;
|
||||||
|
display: grid;
|
||||||
|
gap: 6px;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.record-settings-row {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
border: 1px solid var(--border);
|
||||||
|
border-radius: 6px;
|
||||||
|
padding: 6px 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.record-settings-row select {
|
||||||
|
background: var(--bg-surface);
|
||||||
|
color: inherit;
|
||||||
|
border: 1px solid var(--border);
|
||||||
|
border-radius: 4px;
|
||||||
|
padding: 3px 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.record-settings-id {
|
||||||
|
font-size: 12px;
|
||||||
|
color: var(--text-muted);
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
|
max-width: 220px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Field-by-field conflict view (E8). */
|
||||||
|
.edit-bar-conflict-fields {
|
||||||
|
list-style: none;
|
||||||
|
margin: 8px 0 0;
|
||||||
|
padding: 0;
|
||||||
|
display: grid;
|
||||||
|
gap: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.edit-bar-conflict-fields li {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.edit-bar-conflict-side {
|
||||||
|
font-size: 12px;
|
||||||
|
text-transform: uppercase;
|
||||||
|
letter-spacing: 0.06em;
|
||||||
|
color: var(--text-muted);
|
||||||
|
}
|
||||||
|
|
||||||
@media (max-width: 768px) {
|
@media (max-width: 768px) {
|
||||||
.json-panel {
|
.json-panel {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
|||||||
@@ -1,13 +1,15 @@
|
|||||||
// EditBar (spec-v4 §5.5): the fixed status bar of edit mode. It lists every
|
// EditBar (spec-v4 §5.5, spec-v4-inline-editing E8): the fixed status bar of
|
||||||
// changed path grouped by document with before → after and a per-path revert,
|
// edit mode. It lists every changed path grouped by document with before →
|
||||||
// reports save progress (written / conflict / failed), partial-save resume,
|
// after and a per-path revert, reports save progress (written / conflict /
|
||||||
// conflict resolution (rebase / take-theirs / hand-merge), validation issues,
|
// failed), partial-save resume, validation issues, and guards Exit with a
|
||||||
// and guards Exit with a confirm when changes are unsaved.
|
// confirm when changes are unsaved. Conflicts are resolved field by field:
|
||||||
|
// keep mine / keep theirs per clashing path, with rebase and take-theirs as
|
||||||
|
// the whole-document operations.
|
||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import { useI18n } from '@/i18n/provider';
|
import { useI18n } from '@/i18n/provider';
|
||||||
import { DRAFT_DOCS } from '@/i18n/draft';
|
import { DRAFT_DOCS } from '@/i18n/draft';
|
||||||
import { DEFAULT_BRANCH } from '@/i18n/edit-mode';
|
import { DEFAULT_BRANCH } from '@/i18n/edit-mode';
|
||||||
import type { DocSaveResult, DraftDocId } from '@/i18n/draft';
|
import type { ConflictField, DocSaveResult, DraftDocId } from '@/i18n/draft';
|
||||||
import type { ContentIssue } from '@/i18n/validate';
|
import type { ContentIssue } from '@/i18n/validate';
|
||||||
|
|
||||||
type ChangedDoc = { id: DraftDocId; paths: { path: string; before: unknown; after: unknown }[] };
|
type ChangedDoc = { id: DraftDocId; paths: { path: string; before: unknown; after: unknown }[] };
|
||||||
@@ -24,12 +26,12 @@ type EditBarProps = {
|
|||||||
unionNote: 'ok' | 'failed' | null;
|
unionNote: 'ok' | 'failed' | null;
|
||||||
draftRestored: boolean;
|
draftRestored: boolean;
|
||||||
branch: string;
|
branch: string;
|
||||||
onOpenPanel: () => void;
|
getConflictFields: (id: DraftDocId) => ConflictField[];
|
||||||
onSave: () => void;
|
onSave: () => void;
|
||||||
onExit: () => void;
|
onExit: () => void;
|
||||||
onRebase: (id: DraftDocId) => void;
|
onRebase: (id: DraftDocId) => void;
|
||||||
onTakeTheirs: (id: DraftDocId) => void;
|
onTakeTheirs: (id: DraftDocId) => void;
|
||||||
onHandMerge: (id: DraftDocId) => void;
|
onResolveField: (id: DraftDocId, path: string, side: 'mine' | 'theirs') => void;
|
||||||
onDiscardDoc: (id: DraftDocId) => void;
|
onDiscardDoc: (id: DraftDocId) => void;
|
||||||
onRevertPath: (path: string) => void;
|
onRevertPath: (path: string) => void;
|
||||||
};
|
};
|
||||||
@@ -38,7 +40,7 @@ function fileOf(id: DraftDocId): string {
|
|||||||
return DRAFT_DOCS.find((d) => d.id === id)!.file;
|
return DRAFT_DOCS.find((d) => d.id === id)!.file;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Diff values are shown truncated; the full value lives in the JSON panel.
|
// Diff values are shown truncated; the full value stays in the document.
|
||||||
function truncate(value: unknown): string {
|
function truncate(value: unknown): string {
|
||||||
const text = typeof value === 'string' ? value : JSON.stringify(value) ?? '';
|
const text = typeof value === 'string' ? value : JSON.stringify(value) ?? '';
|
||||||
return text.length > 80 ? `${text.slice(0, 80)}…` : text;
|
return text.length > 80 ? `${text.slice(0, 80)}…` : text;
|
||||||
@@ -56,18 +58,19 @@ export function EditBar({
|
|||||||
unionNote,
|
unionNote,
|
||||||
draftRestored,
|
draftRestored,
|
||||||
branch,
|
branch,
|
||||||
onOpenPanel,
|
getConflictFields,
|
||||||
onSave,
|
onSave,
|
||||||
onExit,
|
onExit,
|
||||||
onRebase,
|
onRebase,
|
||||||
onTakeTheirs,
|
onTakeTheirs,
|
||||||
onHandMerge,
|
onResolveField,
|
||||||
onDiscardDoc,
|
onDiscardDoc,
|
||||||
onRevertPath,
|
onRevertPath,
|
||||||
}: EditBarProps) {
|
}: EditBarProps) {
|
||||||
const { ui } = useI18n();
|
const { ui } = useI18n();
|
||||||
const s = ui.edit;
|
const s = ui.edit;
|
||||||
const [showDiff, setShowDiff] = useState(false);
|
const [showDiff, setShowDiff] = useState(false);
|
||||||
|
const [openFields, setOpenFields] = useState<Set<DraftDocId>>(new Set());
|
||||||
|
|
||||||
const allWritten =
|
const allWritten =
|
||||||
saveResults.length > 0 && !saveStopped && saveResults.every((r) => r.status === 'written');
|
saveResults.length > 0 && !saveStopped && saveResults.every((r) => r.status === 'written');
|
||||||
@@ -99,9 +102,6 @@ export function EditBar({
|
|||||||
>
|
>
|
||||||
{s.changesTitle}
|
{s.changesTitle}
|
||||||
</button>
|
</button>
|
||||||
<button type="button" className="edit-btn" onClick={onOpenPanel}>
|
|
||||||
{s.openPanel}
|
|
||||||
</button>
|
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
className="edit-btn edit-btn-primary"
|
className="edit-btn edit-btn-primary"
|
||||||
@@ -159,7 +159,7 @@ export function EditBar({
|
|||||||
<div className="edit-bar-conflicts">
|
<div className="edit-bar-conflicts">
|
||||||
<strong>{s.conflicts}</strong>
|
<strong>{s.conflicts}</strong>
|
||||||
{conflicts.map((id) => (
|
{conflicts.map((id) => (
|
||||||
<span key={id} className="edit-bar-conflict">
|
<div key={id} className="edit-bar-conflict">
|
||||||
<code>{fileOf(id)}</code> {s.conflictDetail}{' '}
|
<code>{fileOf(id)}</code> {s.conflictDetail}{' '}
|
||||||
<button type="button" className="edit-btn" onClick={() => onRebase(id)}>
|
<button type="button" className="edit-btn" onClick={() => onRebase(id)}>
|
||||||
{s.rebase}
|
{s.rebase}
|
||||||
@@ -167,10 +167,41 @@ export function EditBar({
|
|||||||
<button type="button" className="edit-btn" onClick={() => onTakeTheirs(id)}>
|
<button type="button" className="edit-btn" onClick={() => onTakeTheirs(id)}>
|
||||||
{s.takeTheirs}
|
{s.takeTheirs}
|
||||||
</button>
|
</button>
|
||||||
<button type="button" className="edit-btn" onClick={() => onHandMerge(id)}>
|
<button
|
||||||
{s.handMerge}
|
type="button"
|
||||||
|
className="edit-btn"
|
||||||
|
aria-expanded={openFields.has(id)}
|
||||||
|
onClick={() =>
|
||||||
|
setOpenFields((prev) => {
|
||||||
|
const next = new Set(prev);
|
||||||
|
if (next.has(id)) next.delete(id);
|
||||||
|
else next.add(id);
|
||||||
|
return next;
|
||||||
|
})
|
||||||
|
}
|
||||||
|
>
|
||||||
|
{s.conflictFields}
|
||||||
</button>
|
</button>
|
||||||
</span>
|
{openFields.has(id) && (
|
||||||
|
<ul className="edit-bar-conflict-fields">
|
||||||
|
{getConflictFields(id).map((f) => (
|
||||||
|
<li key={f.path}>
|
||||||
|
<code className="edit-bar-path">{f.path}</code>
|
||||||
|
<span className="edit-bar-conflict-side">{s.yours}</span>
|
||||||
|
<span className="edit-bar-value">{truncate(f.mine)}</span>
|
||||||
|
<span className="edit-bar-conflict-side">{s.theirs}</span>
|
||||||
|
<span className="edit-bar-value">{truncate(f.theirs)}</span>
|
||||||
|
<button type="button" className="edit-btn" onClick={() => onResolveField(id, f.path, 'mine')}>
|
||||||
|
{s.keepMine}
|
||||||
|
</button>
|
||||||
|
<button type="button" className="edit-btn" onClick={() => onResolveField(id, f.path, 'theirs')}>
|
||||||
|
{s.keepTheirs}
|
||||||
|
</button>
|
||||||
|
</li>
|
||||||
|
))}
|
||||||
|
</ul>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ import {
|
|||||||
fetchTextFile,
|
fetchTextFile,
|
||||||
saveDraft,
|
saveDraft,
|
||||||
saveIdUnions,
|
saveIdUnions,
|
||||||
|
recordForTitlePath,
|
||||||
} from '@/i18n/draft';
|
} from '@/i18n/draft';
|
||||||
import type { DocBase, DocSaveResult, DraftDocId } from '@/i18n/draft';
|
import type { DocBase, DocSaveResult, DraftDocId } from '@/i18n/draft';
|
||||||
import {
|
import {
|
||||||
@@ -35,7 +36,6 @@ import { EditContext } from '@/hooks/useEdit';
|
|||||||
import type { EditApi } from '@/hooks/useEdit';
|
import type { EditApi } from '@/hooks/useEdit';
|
||||||
import type { ContentIssue } from '@/i18n/validate';
|
import type { ContentIssue } from '@/i18n/validate';
|
||||||
import { EditBar } from './EditBar';
|
import { EditBar } from './EditBar';
|
||||||
import { JsonPanel, type PanelTab } from './JsonPanel';
|
|
||||||
|
|
||||||
type Phase = 'authenticating' | 'loading' | 'ready' | 'offline';
|
type Phase = 'authenticating' | 'loading' | 'ready' | 'offline';
|
||||||
|
|
||||||
@@ -61,8 +61,6 @@ export default function EditModeShell({ children }: { children: ReactNode }) {
|
|||||||
const [saving, setSaving] = useState(false);
|
const [saving, setSaving] = useState(false);
|
||||||
const [saveStopped, setSaveStopped] = useState(false);
|
const [saveStopped, setSaveStopped] = useState(false);
|
||||||
const [unionNote, setUnionNote] = useState<'ok' | 'failed' | null>(null);
|
const [unionNote, setUnionNote] = useState<'ok' | 'failed' | null>(null);
|
||||||
const [panelOpen, setPanelOpen] = useState(false);
|
|
||||||
const [panelTab, setPanelTab] = useState<PanelTab>('profile');
|
|
||||||
|
|
||||||
const stripEditQuery = useCallback(() => {
|
const stripEditQuery = useCallback(() => {
|
||||||
const params = new URLSearchParams(location.search);
|
const params = new URLSearchParams(location.search);
|
||||||
@@ -167,15 +165,23 @@ export default function EditModeShell({ children }: { children: ReactNode }) {
|
|||||||
return () => window.removeEventListener('beforeunload', warn);
|
return () => window.removeEventListener('beforeunload', warn);
|
||||||
}, [dirty]);
|
}, [dirty]);
|
||||||
|
|
||||||
|
// The EditApi v2 surface (spec-v4-inline-editing E4): text writes keep the
|
||||||
|
// v1 helpers; everything else — structure fields, tags, records, order,
|
||||||
|
// provenance — goes through the generic draft methods. A committed record
|
||||||
|
// title re-sluges its draft-only id (E3); a saved record's id never moves.
|
||||||
const editApi = useMemo<EditApi | null>(
|
const editApi = useMemo<EditApi | null>(
|
||||||
() =>
|
() =>
|
||||||
store && (phase === 'ready' || phase === 'offline')
|
store && (phase === 'ready' || phase === 'offline')
|
||||||
? {
|
? {
|
||||||
|
textDoc: lang === 'en' ? 'content.en' : 'content.vi',
|
||||||
commit: (path, value) => {
|
commit: (path, value) => {
|
||||||
const rejected = store.setValue(lang, path, value);
|
const rejected = store.setValue(lang, path, value);
|
||||||
setIssues(rejected ?? []);
|
setIssues(rejected ?? []);
|
||||||
if (!rejected) refresh(store);
|
if (rejected) return rejected;
|
||||||
return rejected;
|
const record = recordForTitlePath(path);
|
||||||
|
if (record) store.renameRecord(record.kind, record.ids, value);
|
||||||
|
refresh(store);
|
||||||
|
return null;
|
||||||
},
|
},
|
||||||
revert: (path) => {
|
revert: (path) => {
|
||||||
const rejected = store.revertPath(path);
|
const rejected = store.revertPath(path);
|
||||||
@@ -184,6 +190,59 @@ export default function EditModeShell({ children }: { children: ReactNode }) {
|
|||||||
return rejected;
|
return rejected;
|
||||||
},
|
},
|
||||||
isPathDirty: (path) => store.isPathDirty(path),
|
isPathDirty: (path) => store.isPathDirty(path),
|
||||||
|
describe: (doc, path) => store.describeField(doc, path),
|
||||||
|
apply: (doc, next) => {
|
||||||
|
const rejected = store.apply(doc, next);
|
||||||
|
setIssues(rejected ?? []);
|
||||||
|
if (!rejected) refresh(store);
|
||||||
|
return rejected;
|
||||||
|
},
|
||||||
|
dataOf: (doc) => store.dataOf(doc),
|
||||||
|
setStructured: (doc, path, value) => {
|
||||||
|
const rejected = store.setStructured(doc, path, value);
|
||||||
|
setIssues(rejected ?? []);
|
||||||
|
if (!rejected) refresh(store);
|
||||||
|
return rejected;
|
||||||
|
},
|
||||||
|
deleteStructured: (doc, path) => {
|
||||||
|
const rejected = store.deleteStructured(doc, path);
|
||||||
|
setIssues(rejected ?? []);
|
||||||
|
if (!rejected) refresh(store);
|
||||||
|
return rejected;
|
||||||
|
},
|
||||||
|
isPathDirtyIn: (doc, path) => store.changedPaths(doc).includes(path),
|
||||||
|
moveItem: (doc, path, from, to) => {
|
||||||
|
const rejected = store.moveItem(doc, path, from, to);
|
||||||
|
if (rejected) setIssues(rejected);
|
||||||
|
else refresh(store);
|
||||||
|
return rejected;
|
||||||
|
},
|
||||||
|
addRecord: (kind, options) => {
|
||||||
|
const rejected = store.addRecord(kind, options);
|
||||||
|
setIssues(rejected ?? []);
|
||||||
|
if (!rejected) refresh(store);
|
||||||
|
return rejected;
|
||||||
|
},
|
||||||
|
deleteRecord: (kind, ids) => {
|
||||||
|
const rejected = store.deleteRecord(kind, ids);
|
||||||
|
setIssues(rejected ?? []);
|
||||||
|
if (!rejected) refresh(store);
|
||||||
|
return rejected;
|
||||||
|
},
|
||||||
|
isCreated: (kind, ids) => store.isCreated(kind, ids),
|
||||||
|
renameRecord: (kind, ids, rawId) => {
|
||||||
|
const rejected = store.renameRecord(kind, ids, rawId);
|
||||||
|
if (!rejected) refresh(store);
|
||||||
|
return rejected;
|
||||||
|
},
|
||||||
|
conflictFields: (doc) => store.conflictFields(doc),
|
||||||
|
resolveConflictField: (doc, path, side) => {
|
||||||
|
const rejected = store.resolveConflictField(doc, path, side);
|
||||||
|
setIssues(rejected ?? []);
|
||||||
|
if (!rejected) setConflicts((prev) => prev.filter((x) => x !== doc));
|
||||||
|
refresh(store);
|
||||||
|
return rejected;
|
||||||
|
},
|
||||||
}
|
}
|
||||||
: null,
|
: null,
|
||||||
[store, phase, lang, refresh],
|
[store, phase, lang, refresh],
|
||||||
@@ -252,10 +311,27 @@ export default function EditModeShell({ children }: { children: ReactNode }) {
|
|||||||
[store, refresh],
|
[store, refresh],
|
||||||
);
|
);
|
||||||
|
|
||||||
const openHandMerge = useCallback((id: DraftDocId) => {
|
// One field, one side (E8): refresh that document's base first so the
|
||||||
setPanelTab(id);
|
// branch values shown are current, then keep 'mine' or 'theirs' at that
|
||||||
setPanelOpen(true);
|
// path and retry the rebase. The document leaves the conflict list only
|
||||||
}, []);
|
// when the rebase completes with no remaining clash.
|
||||||
|
const resolveConflictField = useCallback(
|
||||||
|
async (id: DraftDocId, path: string, side: 'mine' | 'theirs') => {
|
||||||
|
if (!store) return;
|
||||||
|
const meta = DRAFT_DOCS.find((d) => d.id === id)!;
|
||||||
|
try {
|
||||||
|
store.resetBase(id, await fetchDoc(meta.file, branch));
|
||||||
|
} catch {
|
||||||
|
// unreachable proxy — the field UI stays, take-theirs still works
|
||||||
|
}
|
||||||
|
const rejected = store.resolveConflictField(id, path, side);
|
||||||
|
setIssues(rejected ?? []);
|
||||||
|
if (!rejected) setConflicts((prev) => prev.filter((x) => x !== id));
|
||||||
|
refresh(store);
|
||||||
|
},
|
||||||
|
[store, refresh, branch],
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
const discardDoc = useCallback(
|
const discardDoc = useCallback(
|
||||||
(id: DraftDocId) => {
|
(id: DraftDocId) => {
|
||||||
@@ -282,9 +358,6 @@ export default function EditModeShell({ children }: { children: ReactNode }) {
|
|||||||
stripEditQuery();
|
stripEditQuery();
|
||||||
}, [stripEditQuery]);
|
}, [stripEditQuery]);
|
||||||
|
|
||||||
const openPanel = useCallback(() => {
|
|
||||||
setPanelOpen(true);
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
// `revision` is the draft's invalidation counter — the store mutates in
|
// `revision` is the draft's invalidation counter — the store mutates in
|
||||||
// place, so it is the only signal that a recomputation is due.
|
// place, so it is the only signal that a recomputation is due.
|
||||||
@@ -311,30 +384,15 @@ export default function EditModeShell({ children }: { children: ReactNode }) {
|
|||||||
unionNote={unionNote}
|
unionNote={unionNote}
|
||||||
draftRestored={draftRestored}
|
draftRestored={draftRestored}
|
||||||
branch={branch}
|
branch={branch}
|
||||||
onOpenPanel={openPanel}
|
getConflictFields={(id) => store.conflictFields(id)}
|
||||||
onSave={() => void runSave()}
|
onSave={() => void runSave()}
|
||||||
onExit={exit}
|
onExit={exit}
|
||||||
onRebase={(id) => void resolveRebase(id)}
|
onRebase={(id) => void resolveRebase(id)}
|
||||||
onTakeTheirs={resolveTakeTheirs}
|
onTakeTheirs={resolveTakeTheirs}
|
||||||
onHandMerge={openHandMerge}
|
onResolveField={(id, path, side) => void resolveConflictField(id, path, side)}
|
||||||
onDiscardDoc={discardDoc}
|
onDiscardDoc={discardDoc}
|
||||||
onRevertPath={revertPath}
|
onRevertPath={revertPath}
|
||||||
/>
|
/>
|
||||||
{panelOpen && (
|
|
||||||
<JsonPanel
|
|
||||||
store={store}
|
|
||||||
tab={panelTab}
|
|
||||||
revision={revision}
|
|
||||||
conflicts={conflicts}
|
|
||||||
onClose={() => setPanelOpen(false)}
|
|
||||||
onTab={setPanelTab}
|
|
||||||
onChanged={() => {
|
|
||||||
setIssues(store.validate());
|
|
||||||
refresh(store);
|
|
||||||
}}
|
|
||||||
onConflictResolved={(id) => setConflicts((prev) => prev.filter((x) => x !== id))}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</EditContext.Provider>
|
</EditContext.Provider>
|
||||||
|
|||||||
@@ -3,9 +3,13 @@ import { motion } from 'motion/react'
|
|||||||
import { InView } from '@/components/ui/InView'
|
import { InView } from '@/components/ui/InView'
|
||||||
import { Tag } from '@/components/ui/Tag'
|
import { Tag } from '@/components/ui/Tag'
|
||||||
import { EditableText } from '@/components/ui/EditableText'
|
import { EditableText } from '@/components/ui/EditableText'
|
||||||
|
import { TagListEditor } from '@/components/ui/TagListEditor'
|
||||||
|
import { RecordControls, AddGhost } from '@/components/ui/RecordControls'
|
||||||
|
import { useEdit } from '@/hooks/useEdit'
|
||||||
import { useI18n } from '@/i18n/provider'
|
import { useI18n } from '@/i18n/provider'
|
||||||
export function About() {
|
export function About() {
|
||||||
const { ui: s, content: c } = useI18n()
|
const { ui: s, content: c } = useI18n()
|
||||||
|
const edit = useEdit()
|
||||||
return (
|
return (
|
||||||
<InView>
|
<InView>
|
||||||
<motion.section
|
<motion.section
|
||||||
@@ -37,7 +41,7 @@ export function About() {
|
|||||||
{c.profile.philosophy.map((point, i) => (
|
{c.profile.philosophy.map((point, i) => (
|
||||||
<motion.div
|
<motion.div
|
||||||
key={point.id}
|
key={point.id}
|
||||||
className="philosophy-card"
|
className={edit ? 'philosophy-card edit-record-host' : 'philosophy-card'}
|
||||||
initial={{ opacity: 0, y: 24 }}
|
initial={{ opacity: 0, y: 24 }}
|
||||||
whileInView={{ opacity: 1, y: 0 }}
|
whileInView={{ opacity: 1, y: 0 }}
|
||||||
viewport={{ once: true, amount: 0.2 }}
|
viewport={{ once: true, amount: 0.2 }}
|
||||||
@@ -45,31 +49,49 @@ export function About() {
|
|||||||
whileHover={{ scale: 1.02, y: -4 }}
|
whileHover={{ scale: 1.02, y: -4 }}
|
||||||
whileTap={{ scale: 0.98 }}
|
whileTap={{ scale: 0.98 }}
|
||||||
>
|
>
|
||||||
|
{edit && (
|
||||||
|
<RecordControls
|
||||||
|
label={point.title}
|
||||||
|
canUp={i > 0}
|
||||||
|
canDown={i < c.profile.philosophy.length - 1}
|
||||||
|
onUp={() => edit.moveItem('profile', 'philosophy', i, i - 1)}
|
||||||
|
onDown={() => edit.moveItem('profile', 'philosophy', i, i + 1)}
|
||||||
|
onDelete={() => edit.deleteRecord('philosophy', { id: point.id })}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
<EditableText as="h3" path={`profile.philosophy.${point.id}.title`} label={s.edit.fields.pointTitle}>
|
<EditableText as="h3" path={`profile.philosophy.${point.id}.title`} label={s.edit.fields.pointTitle}>
|
||||||
{point.title}
|
{point.title}
|
||||||
</EditableText>
|
</EditableText>
|
||||||
<EditableText as="p" path={`profile.philosophy.${point.id}.description`} label={s.edit.fields.pointDescription} multiline>
|
<EditableText as="p" path={`profile.philosophy.${point.id}.description`} label={s.edit.fields.pointDescription} multiline>
|
||||||
{point.description}
|
{point.description}
|
||||||
</EditableText>
|
</EditableText>
|
||||||
<div className="philosophy-keywords">
|
<TagListEditor
|
||||||
{point.keywords.map((kw) => (
|
arrayPath={`profile.philosophy.${point.id}.keywords`}
|
||||||
<Tag key={kw}>{kw}</Tag>
|
items={point.keywords}
|
||||||
))}
|
containerAs="div"
|
||||||
</div>
|
containerClassName="philosophy-keywords"
|
||||||
|
as={Tag}
|
||||||
|
labelPrefix={`${point.title} — ${s.edit.fields.pointKeywords}`}
|
||||||
|
addLabel={s.edit.addKeyword}
|
||||||
|
/>
|
||||||
</motion.div>
|
</motion.div>
|
||||||
))}
|
))}
|
||||||
|
{edit && <AddGhost variant="card" label={s.edit.addPhilosophy} onClick={() => edit.addRecord('philosophy')} />}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<h3 className="subheading">
|
<h3 className="subheading">
|
||||||
{s.about.exploringTitle}
|
{s.about.exploringTitle}
|
||||||
</h3>
|
</h3>
|
||||||
<div className="interests-list">
|
<TagListEditor
|
||||||
{c.profile.currentInterests.map((interest) => (
|
arrayPath="profile.currentInterests"
|
||||||
<Tag key={interest} accent>
|
items={c.profile.currentInterests}
|
||||||
{interest}
|
containerAs="div"
|
||||||
</Tag>
|
containerClassName="interests-list"
|
||||||
))}
|
as={Tag}
|
||||||
</div>
|
accent
|
||||||
|
labelPrefix={s.edit.fields.interests}
|
||||||
|
addLabel={s.edit.addInterest}
|
||||||
|
/>
|
||||||
</motion.section>
|
</motion.section>
|
||||||
</InView>
|
</InView>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -2,10 +2,17 @@ import { SectionHeading } from '@/components/ui/SectionHeading'
|
|||||||
import { motion } from "motion/react"
|
import { motion } from "motion/react"
|
||||||
import { InView } from "@/components/ui/InView"
|
import { InView } from "@/components/ui/InView"
|
||||||
import { EditableText } from '@/components/ui/EditableText'
|
import { EditableText } from '@/components/ui/EditableText'
|
||||||
|
import { TagListEditor } from '@/components/ui/TagListEditor'
|
||||||
|
import { RecordControls, AddGhost } from '@/components/ui/RecordControls'
|
||||||
|
import { RecordSettings, ExperienceSettingsPanel } from '@/components/ui/RecordSettings'
|
||||||
|
import { useEdit } from '@/hooks/useEdit'
|
||||||
import { useI18n } from '@/i18n/provider'
|
import { useI18n } from '@/i18n/provider'
|
||||||
|
import { useState } from 'react'
|
||||||
|
|
||||||
export function Experience() {
|
export function Experience() {
|
||||||
const { ui: s, content: c } = useI18n()
|
const { ui: s, content: c } = useI18n()
|
||||||
|
const edit = useEdit()
|
||||||
|
const [settingsFor, setSettingsFor] = useState<string | null>(null)
|
||||||
return (
|
return (
|
||||||
<InView>
|
<InView>
|
||||||
<motion.section
|
<motion.section
|
||||||
@@ -25,13 +32,30 @@ export function Experience() {
|
|||||||
{c.experiences.map((exp, i) => (
|
{c.experiences.map((exp, i) => (
|
||||||
<motion.div
|
<motion.div
|
||||||
key={exp.id}
|
key={exp.id}
|
||||||
className={exp.variant ? `timeline-entry timeline-entry-${exp.variant}` : 'timeline-entry'}
|
className={[
|
||||||
|
'timeline-entry',
|
||||||
|
exp.variant ? `timeline-entry-${exp.variant}` : '',
|
||||||
|
edit ? 'edit-record-host' : '',
|
||||||
|
]
|
||||||
|
.filter(Boolean)
|
||||||
|
.join(' ')}
|
||||||
initial={{ opacity: 0, y: 24 }}
|
initial={{ opacity: 0, y: 24 }}
|
||||||
whileInView={{ opacity: 1, y: 0 }}
|
whileInView={{ opacity: 1, y: 0 }}
|
||||||
viewport={{ once: true, amount: 0.2 }}
|
viewport={{ once: true, amount: 0.2 }}
|
||||||
transition={{ duration: 0.45, ease: "easeOut", delay: i * 0.08 }}
|
transition={{ duration: 0.45, ease: "easeOut", delay: i * 0.08 }}
|
||||||
>
|
>
|
||||||
<div className="timeline-marker" />
|
<div className="timeline-marker" />
|
||||||
|
{edit && (
|
||||||
|
<RecordControls
|
||||||
|
label={exp.title}
|
||||||
|
canUp={i > 0}
|
||||||
|
canDown={i < c.experiences.length - 1}
|
||||||
|
onUp={() => edit.moveItem('experience', '', i, i - 1)}
|
||||||
|
onDown={() => edit.moveItem('experience', '', i, i + 1)}
|
||||||
|
onDelete={() => edit.deleteRecord('experience', { id: exp.id })}
|
||||||
|
onSettings={() => setSettingsFor(exp.id)}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
<div className="timeline-header">
|
<div className="timeline-header">
|
||||||
<EditableText as="div" className="timeline-title" path={`experience.${exp.id}.title`} label={s.edit.fields.expTitle}>
|
<EditableText as="div" className="timeline-title" path={`experience.${exp.id}.title`} label={s.edit.fields.expTitle}>
|
||||||
{exp.title}
|
{exp.title}
|
||||||
@@ -48,20 +72,18 @@ export function Experience() {
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<ul className="timeline-responsibilities">
|
<TagListEditor
|
||||||
{exp.responsibilities.map((r, ri) => (
|
arrayPath={`experience.${exp.id}.responsibilities`}
|
||||||
<EditableText
|
items={exp.responsibilities}
|
||||||
|
containerAs="ul"
|
||||||
|
containerClassName="timeline-responsibilities"
|
||||||
as="li"
|
as="li"
|
||||||
key={ri}
|
labelPrefix={`${exp.title} — ${s.edit.fields.responsibility}`}
|
||||||
path={`experience.${exp.id}.responsibilities[${ri}]`}
|
addLabel={s.edit.addResponsibility}
|
||||||
label={`${exp.title} — ${s.edit.fields.responsibility} ${ri + 1}`}
|
/>
|
||||||
>
|
|
||||||
{r}
|
|
||||||
</EditableText>
|
|
||||||
))}
|
|
||||||
</ul>
|
|
||||||
</motion.div>
|
</motion.div>
|
||||||
))}
|
))}
|
||||||
|
{edit && <AddGhost label={s.edit.addExperience} onClick={() => edit.addRecord('experience')} />}
|
||||||
<div className="timeline-tldr">
|
<div className="timeline-tldr">
|
||||||
<span className="timeline-tldr-marker" aria-hidden="true" />
|
<span className="timeline-tldr-marker" aria-hidden="true" />
|
||||||
<span className="timeline-tldr-chip">{s.experience.tldr}</span>
|
<span className="timeline-tldr-chip">{s.experience.tldr}</span>
|
||||||
@@ -70,6 +92,14 @@ export function Experience() {
|
|||||||
</EditableText>
|
</EditableText>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{edit && settingsFor && (
|
||||||
|
<RecordSettings title={s.edit.settings} onClose={() => setSettingsFor(null)}>
|
||||||
|
{(() => {
|
||||||
|
const entry = c.experiences.find((e) => e.id === settingsFor)
|
||||||
|
return entry ? <ExperienceSettingsPanel entry={entry} /> : null
|
||||||
|
})()}
|
||||||
|
</RecordSettings>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</motion.section>
|
</motion.section>
|
||||||
</InView>
|
</InView>
|
||||||
|
|||||||
@@ -2,10 +2,14 @@ import { motion } from "motion/react"
|
|||||||
import { SectionHeading } from "@/components/ui/SectionHeading"
|
import { SectionHeading } from "@/components/ui/SectionHeading"
|
||||||
import { InView } from '@/components/ui/InView'
|
import { InView } from '@/components/ui/InView'
|
||||||
import { EditableText } from '@/components/ui/EditableText'
|
import { EditableText } from '@/components/ui/EditableText'
|
||||||
|
import { TagListEditor } from '@/components/ui/TagListEditor'
|
||||||
|
import { RecordControls, AddGhost } from '@/components/ui/RecordControls'
|
||||||
|
import { useEdit } from '@/hooks/useEdit'
|
||||||
import { useI18n } from '@/i18n/provider'
|
import { useI18n } from '@/i18n/provider'
|
||||||
|
|
||||||
export function Expertise() {
|
export function Expertise() {
|
||||||
const { ui: s, content: c } = useI18n()
|
const { ui: s, content: c } = useI18n()
|
||||||
|
const edit = useEdit()
|
||||||
return (
|
return (
|
||||||
<InView>
|
<InView>
|
||||||
<motion.section
|
<motion.section
|
||||||
@@ -24,7 +28,7 @@ export function Expertise() {
|
|||||||
{c.skillGroups.map((group, i) => (
|
{c.skillGroups.map((group, i) => (
|
||||||
<motion.div
|
<motion.div
|
||||||
key={group.id}
|
key={group.id}
|
||||||
className="expertise-card"
|
className={edit ? 'expertise-card edit-record-host' : 'expertise-card'}
|
||||||
initial={{ opacity: 0, y: 24 }}
|
initial={{ opacity: 0, y: 24 }}
|
||||||
whileInView={{ opacity: 1, y: 0 }}
|
whileInView={{ opacity: 1, y: 0 }}
|
||||||
viewport={{ once: true, amount: 0.2 }}
|
viewport={{ once: true, amount: 0.2 }}
|
||||||
@@ -32,18 +36,33 @@ export function Expertise() {
|
|||||||
whileHover={{ scale: 1.02, y: -4 }}
|
whileHover={{ scale: 1.02, y: -4 }}
|
||||||
whileTap={{ scale: 0.98 }}
|
whileTap={{ scale: 0.98 }}
|
||||||
>
|
>
|
||||||
|
{edit && (
|
||||||
|
<RecordControls
|
||||||
|
label={group.title}
|
||||||
|
canUp={i > 0}
|
||||||
|
canDown={i < c.skillGroups.length - 1}
|
||||||
|
onUp={() => edit.moveItem('skills', '', i, i - 1)}
|
||||||
|
onDown={() => edit.moveItem('skills', '', i, i + 1)}
|
||||||
|
onDelete={() => edit.deleteRecord('skill-group', { id: group.id })}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
<EditableText as="h3" path={`skills.${group.id}.title`} label={s.edit.fields.groupTitle}>
|
<EditableText as="h3" path={`skills.${group.id}.title`} label={s.edit.fields.groupTitle}>
|
||||||
{group.title}
|
{group.title}
|
||||||
</EditableText>
|
</EditableText>
|
||||||
<ul className="expertise-skills">
|
<TagListEditor
|
||||||
{group.skills.map((skill) => (
|
doc="skills"
|
||||||
<li key={skill} className="expertise-skill">
|
arrayPath={`[${i}].skills`}
|
||||||
{skill}
|
items={group.skills}
|
||||||
</li>
|
containerAs="ul"
|
||||||
))}
|
containerClassName="expertise-skills"
|
||||||
</ul>
|
as="li"
|
||||||
|
itemClassName="expertise-skill"
|
||||||
|
labelPrefix={`${group.title} — ${s.edit.fields.skill}`}
|
||||||
|
addLabel={s.edit.addSkill}
|
||||||
|
/>
|
||||||
</motion.div>
|
</motion.div>
|
||||||
))}
|
))}
|
||||||
|
{edit && <AddGhost variant="card" label={s.edit.addSkillGroup} onClick={() => edit.addRecord('skill-group')} />}
|
||||||
</div>
|
</div>
|
||||||
</motion.section>
|
</motion.section>
|
||||||
</InView>
|
</InView>
|
||||||
|
|||||||
@@ -9,11 +9,14 @@ import {Typewriter} from '@/components/ui/Typewriter'
|
|||||||
import {HeroParticles} from '@/components/sections/HeroParticles'
|
import {HeroParticles} from '@/components/sections/HeroParticles'
|
||||||
import {EditableText} from '@/components/ui/EditableText'
|
import {EditableText} from '@/components/ui/EditableText'
|
||||||
import {SocialLinks} from "@/components/ui/SocialLinks"
|
import {SocialLinks} from "@/components/ui/SocialLinks"
|
||||||
|
import {useEdit} from '@/hooks/useEdit'
|
||||||
|
import {deletePath, parsePath, setPath} from '@/i18n/draft'
|
||||||
|
import {ChevronDownIcon, ChevronUpIcon, PlusIcon, TrashIcon} from '@/components/ui/icons'
|
||||||
|
|
||||||
export function Hero() {
|
export function Hero() {
|
||||||
const {scrollY} = useScroll()
|
const {scrollY} = useScroll()
|
||||||
const {ui: s, content: c} = useI18n()
|
const {ui: s, content: c} = useI18n()
|
||||||
|
const edit = useEdit()
|
||||||
const y = useTransform(scrollY, [0, 300], [0, -80])
|
const y = useTransform(scrollY, [0, 300], [0, -80])
|
||||||
return (
|
return (
|
||||||
<InView>
|
<InView>
|
||||||
@@ -72,15 +75,72 @@ export function Hero() {
|
|||||||
transition={{duration: 0.45, ease: "easeOut", delay: 0.24}}
|
transition={{duration: 0.45, ease: "easeOut", delay: 0.24}}
|
||||||
>
|
>
|
||||||
{/* Tagline segments (D9): markup is this component's rendering,
|
{/* Tagline segments (D9): markup is this component's rendering,
|
||||||
never content — the emphasis span keeps its classes. */}
|
never content — the emphasis span keeps its classes. In edit
|
||||||
{c.profile.tagline.map((segment, i) => (
|
mode each segment carries emphasis / move / delete controls
|
||||||
segment.emphasis ? (
|
(spec-v4-inline-editing §2.1) and a ghost add follows. */}
|
||||||
|
{c.profile.tagline.map((segment, i) => {
|
||||||
|
const controls = edit ? (
|
||||||
|
<>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className={`edit-item-control edit-emphasis-toggle${segment.emphasis ? ' is-on' : ''}`}
|
||||||
|
aria-pressed={segment.emphasis === true}
|
||||||
|
aria-label={`${s.edit.emphasis} — ${s.edit.fields.tagline} ${i + 1}`}
|
||||||
|
onMouseDown={(event) => event.stopPropagation()}
|
||||||
|
onClick={() => {
|
||||||
|
const segs = parsePath(`profile.tagline[${i}].emphasis`)
|
||||||
|
if (segment.emphasis) {
|
||||||
|
edit.apply(edit.textDoc, deletePath(edit.dataOf(edit.textDoc), segs))
|
||||||
|
} else {
|
||||||
|
edit.apply(edit.textDoc, setPath(edit.dataOf(edit.textDoc), segs, true))
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
B
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className="edit-item-control"
|
||||||
|
aria-label={`${s.edit.moveUp} — ${s.edit.fields.tagline} ${i + 1}`}
|
||||||
|
disabled={i === 0}
|
||||||
|
onMouseDown={(event) => event.stopPropagation()}
|
||||||
|
onClick={() => edit.moveItem(edit.textDoc, 'profile.tagline', i, i - 1)}
|
||||||
|
>
|
||||||
|
<ChevronUpIcon size={12}/>
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className="edit-item-control"
|
||||||
|
aria-label={`${s.edit.moveDown} — ${s.edit.fields.tagline} ${i + 1}`}
|
||||||
|
disabled={i === c.profile.tagline.length - 1}
|
||||||
|
onMouseDown={(event) => event.stopPropagation()}
|
||||||
|
onClick={() => edit.moveItem(edit.textDoc, 'profile.tagline', i, i + 1)}
|
||||||
|
>
|
||||||
|
<ChevronDownIcon size={12}/>
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className="edit-item-control edit-item-remove"
|
||||||
|
aria-label={`${s.edit.remove} — ${s.edit.fields.tagline} ${i + 1}`}
|
||||||
|
onMouseDown={(event) => event.stopPropagation()}
|
||||||
|
onClick={() => {
|
||||||
|
if (window.confirm(s.edit.removeConfirm)) {
|
||||||
|
edit.apply(edit.textDoc, deletePath(edit.dataOf(edit.textDoc), parsePath(`profile.tagline[${i}]`)))
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<TrashIcon size={12}/>
|
||||||
|
</button>
|
||||||
|
</>
|
||||||
|
) : undefined
|
||||||
|
return segment.emphasis ? (
|
||||||
<EditableText
|
<EditableText
|
||||||
as="span"
|
as="span"
|
||||||
key={i}
|
key={i}
|
||||||
className="ok-possible name-highlight"
|
className="ok-possible name-highlight"
|
||||||
path={`profile.tagline[${i}].text`}
|
path={`profile.tagline[${i}].text`}
|
||||||
label={`${s.edit.fields.tagline} ${i + 1}`}
|
label={`${s.edit.fields.tagline} ${i + 1}`}
|
||||||
|
fieldControls={controls}
|
||||||
>
|
>
|
||||||
{segment.text}
|
{segment.text}
|
||||||
</EditableText>
|
</EditableText>
|
||||||
@@ -90,11 +150,22 @@ export function Hero() {
|
|||||||
key={i}
|
key={i}
|
||||||
path={`profile.tagline[${i}].text`}
|
path={`profile.tagline[${i}].text`}
|
||||||
label={`${s.edit.fields.tagline} ${i + 1}`}
|
label={`${s.edit.fields.tagline} ${i + 1}`}
|
||||||
|
fieldControls={controls}
|
||||||
>
|
>
|
||||||
{segment.text}
|
{segment.text}
|
||||||
</EditableText>
|
</EditableText>
|
||||||
)
|
)
|
||||||
))}
|
})}
|
||||||
|
{edit && (
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className="edit-add-inline"
|
||||||
|
onClick={() => edit.apply(edit.textDoc, setPath(edit.dataOf(edit.textDoc), parsePath('profile.tagline'), [...c.profile.tagline, {text: s.edit.newTag}]))}
|
||||||
|
>
|
||||||
|
<PlusIcon size={12}/>
|
||||||
|
{s.edit.addTaglineSegment}
|
||||||
|
</button>
|
||||||
|
)}
|
||||||
</motion.p>
|
</motion.p>
|
||||||
<motion.div
|
<motion.div
|
||||||
className="hero-cta"
|
className="hero-cta"
|
||||||
|
|||||||
@@ -4,12 +4,19 @@ import { motion } from "motion/react"
|
|||||||
import { Badge } from "@/components/ui/Badge"
|
import { Badge } from "@/components/ui/Badge"
|
||||||
import { InView } from "@/components/ui/InView"
|
import { InView } from "@/components/ui/InView"
|
||||||
import { EditableText } from '@/components/ui/EditableText'
|
import { EditableText } from '@/components/ui/EditableText'
|
||||||
|
import { TagListEditor } from '@/components/ui/TagListEditor'
|
||||||
|
import { RecordControls } from '@/components/ui/RecordControls'
|
||||||
|
import { RecordSettings, ProjectSettingsPanel } from '@/components/ui/RecordSettings'
|
||||||
|
import { useEdit } from '@/hooks/useEdit'
|
||||||
import { useI18n } from '@/i18n/provider'
|
import { useI18n } from '@/i18n/provider'
|
||||||
|
import { useState } from 'react'
|
||||||
|
|
||||||
const MotionLink = motion.create(Link)
|
const MotionLink = motion.create(Link)
|
||||||
|
|
||||||
export function Projects() {
|
export function Projects() {
|
||||||
const { ui: s, content: c } = useI18n()
|
const { ui: s, content: c } = useI18n()
|
||||||
|
const edit = useEdit()
|
||||||
|
const [settingsFor, setSettingsFor] = useState<string | null>(null)
|
||||||
const featured = c.projects.filter((p) => p.featured).slice(0, 4)
|
const featured = c.projects.filter((p) => p.featured).slice(0, 4)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -33,7 +40,12 @@ export function Projects() {
|
|||||||
{s.projects.viewAll} →
|
{s.projects.viewAll} →
|
||||||
</Link>
|
</Link>
|
||||||
<div className="projects-grid">
|
<div className="projects-grid">
|
||||||
{featured.map((project, i) => (
|
{featured.map((project, i) => {
|
||||||
|
// Structure paths are relative to the document array, so the
|
||||||
|
// control writes address the record by its real index, not the
|
||||||
|
// featured-subset index it happens to render at.
|
||||||
|
const docIndex = c.projects.findIndex((p) => p.id === project.id)
|
||||||
|
const card = (
|
||||||
<MotionLink
|
<MotionLink
|
||||||
key={project.id}
|
key={project.id}
|
||||||
to={`/projects/${project.id}`}
|
to={`/projects/${project.id}`}
|
||||||
@@ -57,6 +69,19 @@ export function Projects() {
|
|||||||
<EditableText as="p" className="project-card-summary" path={`projects.${project.id}.summary`} label={`${project.title} — ${s.edit.fields.summary}`}>
|
<EditableText as="p" className="project-card-summary" path={`projects.${project.id}.summary`} label={`${project.title} — ${s.edit.fields.summary}`}>
|
||||||
{project.summary}
|
{project.summary}
|
||||||
</EditableText>
|
</EditableText>
|
||||||
|
{edit ? (
|
||||||
|
<TagListEditor
|
||||||
|
doc="projects"
|
||||||
|
arrayPath={`[${docIndex}].technologies`}
|
||||||
|
items={project.technologies}
|
||||||
|
containerAs="div"
|
||||||
|
containerClassName="project-card-techs"
|
||||||
|
as="span"
|
||||||
|
itemClassName="tag"
|
||||||
|
labelPrefix={`${project.title} — ${s.edit.fields.technology}`}
|
||||||
|
addLabel={s.edit.addTechnology}
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
<div className="project-card-techs">
|
<div className="project-card-techs">
|
||||||
{project.technologies.slice(0, 4).map((tech) => (
|
{project.technologies.slice(0, 4).map((tech) => (
|
||||||
<span key={tech} className="tag">
|
<span key={tech} className="tag">
|
||||||
@@ -64,20 +89,47 @@ export function Projects() {
|
|||||||
</span>
|
</span>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
{project.metrics && project.metrics.length > 0 && (
|
)}
|
||||||
<div className="project-card-metrics">
|
{(edit || (project.metrics?.length ?? 0) > 0) && (
|
||||||
{project.metrics.map((m) => (
|
<TagListEditor
|
||||||
<span key={m} className="achievement-metric">
|
arrayPath={`projects.${project.id}.metrics`}
|
||||||
{m}
|
items={project.metrics ?? []}
|
||||||
</span>
|
containerAs="div"
|
||||||
))}
|
containerClassName="project-card-metrics"
|
||||||
</div>
|
as="span"
|
||||||
|
itemClassName="achievement-metric"
|
||||||
|
labelPrefix={`${project.title} — ${s.edit.fields.metric}`}
|
||||||
|
addLabel={s.edit.addMetric}
|
||||||
|
/>
|
||||||
)}
|
)}
|
||||||
<span className="project-card-cta">{s.projects.viewDetails} →</span>
|
<span className="project-card-cta">{s.projects.viewDetails} →</span>
|
||||||
</div>
|
</div>
|
||||||
</MotionLink>
|
</MotionLink>
|
||||||
))}
|
)
|
||||||
|
// A card body is a link; its controls sit beside it, in an
|
||||||
|
// edit-mode shell that keeps the grid layout intact.
|
||||||
|
return edit ? (
|
||||||
|
<div key={project.id} className="edit-record-shell">
|
||||||
|
<RecordControls
|
||||||
|
label={project.title}
|
||||||
|
onDelete={() => edit.deleteRecord('project', { id: project.id })}
|
||||||
|
onSettings={() => setSettingsFor(project.id)}
|
||||||
|
/>
|
||||||
|
{card}
|
||||||
</div>
|
</div>
|
||||||
|
) : (
|
||||||
|
card
|
||||||
|
)
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
{edit && settingsFor && (
|
||||||
|
<RecordSettings title={s.edit.settings} onClose={() => setSettingsFor(null)}>
|
||||||
|
{(() => {
|
||||||
|
const project = c.projects.find((p) => p.id === settingsFor)
|
||||||
|
return project ? <ProjectSettingsPanel project={project} /> : null
|
||||||
|
})()}
|
||||||
|
</RecordSettings>
|
||||||
|
)}
|
||||||
</motion.section>
|
</motion.section>
|
||||||
</InView>
|
</InView>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,30 +1,49 @@
|
|||||||
// EditableText (spec-v4 §5.3): a text node bound to a text-document path.
|
// EditableText (spec-v4 §5.3, spec-v4-inline-editing E6/E7): a text node
|
||||||
// Outside edit mode it renders exactly the element the site renders today —
|
// bound to a document path. Outside edit mode it renders exactly the element
|
||||||
// same tag, same attributes, text as children, zero DOM/CSS/motion difference.
|
// the site renders today — same tag, same attributes, text as children, zero
|
||||||
// In edit mode the same element becomes the inline editor.
|
// DOM/CSS/motion difference. In edit mode the element stays text: editing is
|
||||||
|
// entered through the pencil on its corner, never by clicking the text, so a
|
||||||
|
// reader can still select and copy in edit mode.
|
||||||
//
|
//
|
||||||
// Hard rules implemented here:
|
// Hard rules implemented here:
|
||||||
|
// - the pencil starts editing; the element is contentEditable only while
|
||||||
|
// editing (E6);
|
||||||
|
// - while editing, the element carries a provenance chip — the file and path
|
||||||
|
// the value lives in (E7), clickable to copy; the pencil's title names the
|
||||||
|
// same target for hover;
|
||||||
// - commit on blur only, never per keystroke — Vietnamese IME composition is
|
// - commit on blur only, never per keystroke — Vietnamese IME composition is
|
||||||
// never truncated because no keystroke ever reaches the draft;
|
// never truncated because no keystroke ever reaches the draft;
|
||||||
// - Esc cancels the current edit and restores the last committed value;
|
// - Esc cancels the current edit and restores the last committed value;
|
||||||
// - Enter commits + blurs single-line fields, inserts \n in multi-line ones;
|
// - Enter commits + blurs single-line fields, inserts \n in multi-line ones;
|
||||||
// - paste is sanitized to plain text;
|
// - paste is sanitized to plain text;
|
||||||
// - an empty required value is rejected at commit (validator rule 6) and the
|
// - an empty required value is rejected at commit (validator rule 6), the
|
||||||
// field keeps focus;
|
// reason is shown on the field, and the field keeps focus;
|
||||||
|
// - a structure-document path (doc prop) writes through the same draft store —
|
||||||
|
// text and structure are one editing surface for the user (E1/E4);
|
||||||
// - motion keeps transform ownership: this component edits only the text node
|
// - motion keeps transform ownership: this component edits only the text node
|
||||||
// inside already-animated elements.
|
// inside already-animated elements.
|
||||||
import { useContext, useRef, useState } from 'react';
|
import { useContext, useEffect, useRef, useState } from 'react';
|
||||||
import type { ElementType, ReactNode } from 'react';
|
import type { ElementType, ReactNode } from 'react';
|
||||||
import { EditContext } from '@/hooks/useEdit';
|
import { EditContext } from '@/hooks/useEdit';
|
||||||
|
import type { EditApi } from '@/hooks/useEdit';
|
||||||
|
import { useI18n } from '@/i18n/provider';
|
||||||
|
import { parsePath, setPath } from '@/i18n/draft';
|
||||||
|
import type { DraftDocId } from '@/i18n/draft';
|
||||||
|
import { PencilIcon } from '@/components/ui/icons';
|
||||||
|
|
||||||
type EditableTextProps = {
|
type EditableTextProps = {
|
||||||
// The element this site renders today — tag or motion component.
|
// The element this site renders today — tag or motion component.
|
||||||
as?: ElementType;
|
as?: ElementType;
|
||||||
// Text-document path, e.g. `projects.iot-dws-integration.summary`.
|
// Path inside the target document, e.g. `projects.iot-dws-integration.summary`.
|
||||||
path: string;
|
path: string;
|
||||||
|
// Target document; defaults to the text document of the edited language (E1).
|
||||||
|
doc?: DraftDocId;
|
||||||
// Human-readable field name for the accessibility label (§5.3).
|
// Human-readable field name for the accessibility label (§5.3).
|
||||||
label: string;
|
label: string;
|
||||||
multiline?: boolean;
|
multiline?: boolean;
|
||||||
|
// Extra non-text controls rendered inside the element as chrome islands —
|
||||||
|
// the per-item buttons a tag list attaches (spec-v4-inline-editing E5).
|
||||||
|
fieldControls?: ReactNode;
|
||||||
children: ReactNode;
|
children: ReactNode;
|
||||||
className?: string;
|
className?: string;
|
||||||
[prop: string]: unknown;
|
[prop: string]: unknown;
|
||||||
@@ -33,17 +52,18 @@ type EditableTextProps = {
|
|||||||
export function EditableText({
|
export function EditableText({
|
||||||
as,
|
as,
|
||||||
path,
|
path,
|
||||||
|
doc,
|
||||||
label,
|
label,
|
||||||
multiline = false,
|
multiline = false,
|
||||||
|
fieldControls,
|
||||||
children,
|
children,
|
||||||
className,
|
className,
|
||||||
...rest
|
...rest
|
||||||
}: EditableTextProps) {
|
}: EditableTextProps) {
|
||||||
const edit = useContext(EditContext);
|
const edit = useContext(EditContext);
|
||||||
const ref = useRef<HTMLElement | null>(null);
|
|
||||||
const [invalid, setInvalid] = useState(false);
|
|
||||||
const Comp = (as ?? 'p') as ElementType;
|
const Comp = (as ?? 'p') as ElementType;
|
||||||
|
|
||||||
|
// Without a provider the element is byte-identical to the plain one.
|
||||||
if (!edit) {
|
if (!edit) {
|
||||||
return (
|
return (
|
||||||
<Comp {...rest} className={className}>
|
<Comp {...rest} className={className}>
|
||||||
@@ -52,20 +72,152 @@ export function EditableText({
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const dirty = edit.isPathDirty(path);
|
return (
|
||||||
const cls = [className, 'editable-text', dirty && 'edit-dirty', invalid && 'edit-invalid']
|
<EditableField
|
||||||
|
edit={edit}
|
||||||
|
Comp={Comp}
|
||||||
|
docId={doc ?? edit.textDoc}
|
||||||
|
path={path}
|
||||||
|
label={label}
|
||||||
|
multiline={multiline}
|
||||||
|
fieldControls={fieldControls}
|
||||||
|
className={className}
|
||||||
|
rest={rest}
|
||||||
|
>
|
||||||
|
{children}
|
||||||
|
</EditableField>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// The chrome islands EditableText renders inside the element — excluded from
|
||||||
|
// the value and from a cancel-restore, never from the element's own text.
|
||||||
|
const CHROME_CLASSES = ['edit-pencil', 'edit-provenance', 'edit-field-error', 'edit-field-controls'];
|
||||||
|
const isChrome = (node: Node): boolean =>
|
||||||
|
node.nodeType === Node.ELEMENT_NODE &&
|
||||||
|
CHROME_CLASSES.some((c) => (node as HTMLElement).classList.contains(c));
|
||||||
|
|
||||||
|
// Read only the element's own text: chrome subtrees are rejected, and <br>
|
||||||
|
// plus block boxes become \n the way innerText would (§5.3 — multi-line text
|
||||||
|
// is stored as plain text with newlines, rendering unchanged).
|
||||||
|
function readElementText(el: HTMLElement): string {
|
||||||
|
const walker = document.createTreeWalker(
|
||||||
|
el,
|
||||||
|
NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_TEXT,
|
||||||
|
{
|
||||||
|
acceptNode: (node) => (isChrome(node) ? NodeFilter.FILTER_REJECT : NodeFilter.FILTER_ACCEPT),
|
||||||
|
},
|
||||||
|
);
|
||||||
|
let value = '';
|
||||||
|
for (let node = walker.nextNode(); node; node = walker.nextNode()) {
|
||||||
|
if (node.nodeType === Node.TEXT_NODE) {
|
||||||
|
value += node.textContent ?? '';
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
const tag = (node as HTMLElement).tagName;
|
||||||
|
if (tag === 'BR') {
|
||||||
|
value += '\n';
|
||||||
|
} else if ((tag === 'DIV' || tag === 'P') && value && !value.endsWith('\n')) {
|
||||||
|
value += '\n';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return value.replace(/\n+$/, '');
|
||||||
|
}
|
||||||
|
|
||||||
|
// The editing element — all hooks live here so the provider decision above
|
||||||
|
// stays a plain branch (react/rules-of-hooks).
|
||||||
|
function EditableField({
|
||||||
|
edit,
|
||||||
|
Comp,
|
||||||
|
docId,
|
||||||
|
path,
|
||||||
|
label,
|
||||||
|
multiline,
|
||||||
|
fieldControls,
|
||||||
|
className,
|
||||||
|
rest,
|
||||||
|
children,
|
||||||
|
}: {
|
||||||
|
edit: EditApi;
|
||||||
|
Comp: ElementType;
|
||||||
|
docId: DraftDocId;
|
||||||
|
path: string;
|
||||||
|
label: string;
|
||||||
|
multiline: boolean;
|
||||||
|
fieldControls?: ReactNode;
|
||||||
|
className?: string;
|
||||||
|
rest: Record<string, unknown>;
|
||||||
|
children: ReactNode;
|
||||||
|
}) {
|
||||||
|
const { ui: s } = useI18n();
|
||||||
|
const ref = useRef<HTMLElement | null>(null);
|
||||||
|
const [editing, setEditing] = useState(false);
|
||||||
|
const [error, setError] = useState<string | null>(null);
|
||||||
|
const [copied, setCopied] = useState(false);
|
||||||
|
|
||||||
|
const info = edit.describe(docId, path);
|
||||||
|
const pointer = `${info.doc} → ${info.pointer}`;
|
||||||
|
const dirty = edit.isPathDirtyIn(docId, path);
|
||||||
|
const cls = [className, 'editable-text', dirty && 'edit-dirty', error && 'edit-invalid']
|
||||||
.filter(Boolean)
|
.filter(Boolean)
|
||||||
.join(' ');
|
.join(' ');
|
||||||
|
|
||||||
|
// Entering edit mode: focus the element and put the caret at the end of
|
||||||
|
// its text — the browser clamps the caret out of a chrome island.
|
||||||
|
useEffect(() => {
|
||||||
|
if (!editing) return;
|
||||||
|
const el = ref.current;
|
||||||
|
if (!el) return;
|
||||||
|
el.focus({ preventScroll: true });
|
||||||
|
const range = document.createRange();
|
||||||
|
range.selectNodeContents(el);
|
||||||
|
range.collapse(false);
|
||||||
|
const selection = window.getSelection();
|
||||||
|
selection?.removeAllRanges();
|
||||||
|
selection?.addRange(range);
|
||||||
|
}, [editing]);
|
||||||
|
|
||||||
const commit = () => {
|
const commit = () => {
|
||||||
const el = ref.current;
|
const el = ref.current;
|
||||||
if (!el) return;
|
if (!el) return;
|
||||||
// innerText normalizes <br>/<div> line boxes into \n — multi-line text
|
const value = readElementText(el);
|
||||||
// is stored as plain text with newlines, rendering unchanged (§5.3).
|
if (value.trim() === '') {
|
||||||
const value = (el.innerText ?? '').replace(/\n+$/, '');
|
setError(s.edit.emptyRequired);
|
||||||
const issues = edit.commit(path, value);
|
el.focus(); // empty-required: the field keeps focus
|
||||||
setInvalid(issues !== null);
|
return;
|
||||||
if (issues) el.focus(); // empty-required: the field keeps focus
|
}
|
||||||
|
const issues =
|
||||||
|
docId === edit.textDoc
|
||||||
|
? edit.commit(path, value)
|
||||||
|
: edit.apply(docId, setPath(edit.dataOf(docId), parsePath(path), value));
|
||||||
|
if (issues) {
|
||||||
|
setError(issues[0]?.message ?? 'invalid');
|
||||||
|
el.focus();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
setError(null);
|
||||||
|
setEditing(false);
|
||||||
|
};
|
||||||
|
|
||||||
|
// Esc: drop everything the user typed, keep the chrome, restore the last
|
||||||
|
// committed text. React owns no text-node diff here (the children string is
|
||||||
|
// unchanged), so the restored node survives the next render.
|
||||||
|
const cancel = () => {
|
||||||
|
const el = ref.current;
|
||||||
|
if (el && typeof children === 'string') {
|
||||||
|
for (const node of Array.from(el.childNodes)) {
|
||||||
|
if (!isChrome(node)) el.removeChild(node);
|
||||||
|
}
|
||||||
|
const pencil = el.querySelector('.edit-pencil');
|
||||||
|
el.insertBefore(document.createTextNode(children), pencil ?? null);
|
||||||
|
}
|
||||||
|
setEditing(false);
|
||||||
|
setError(null);
|
||||||
|
};
|
||||||
|
|
||||||
|
const copyPath = () => {
|
||||||
|
void navigator.clipboard.writeText(`${info.repoPath} → ${info.pointer}`);
|
||||||
|
setCopied(true);
|
||||||
|
window.setTimeout(() => setCopied(false), 1500);
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -73,36 +225,78 @@ export function EditableText({
|
|||||||
{...rest}
|
{...rest}
|
||||||
ref={ref}
|
ref={ref}
|
||||||
className={cls}
|
className={cls}
|
||||||
contentEditable
|
contentEditable={editing || undefined}
|
||||||
suppressContentEditableWarning
|
suppressContentEditableWarning
|
||||||
role="textbox"
|
role={editing ? 'textbox' : undefined}
|
||||||
aria-multiline={multiline || undefined}
|
aria-multiline={editing && multiline ? true : undefined}
|
||||||
aria-label={label}
|
aria-label={editing ? label : undefined}
|
||||||
data-edit-path={path}
|
data-edit-path={path}
|
||||||
// Editing text must not follow the card link it sits inside.
|
// Editing text must not follow the card link it sits inside; in idle
|
||||||
|
// edit mode the click is inert, text stays selectable.
|
||||||
onClick={(event: React.MouseEvent) => {
|
onClick={(event: React.MouseEvent) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
}}
|
}}
|
||||||
onBlur={commit}
|
onBlur={editing ? commit : undefined}
|
||||||
onKeyDown={(event: React.KeyboardEvent) => {
|
onKeyDown={
|
||||||
|
editing
|
||||||
|
? (event: React.KeyboardEvent) => {
|
||||||
if (event.key === 'Escape') {
|
if (event.key === 'Escape') {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
const el = ref.current;
|
cancel();
|
||||||
if (el && typeof children === 'string') el.innerText = children;
|
|
||||||
el?.blur(); // blurring commits the restored value — a no-op change
|
|
||||||
setInvalid(false);
|
|
||||||
} else if (event.key === 'Enter' && !multiline) {
|
} else if (event.key === 'Enter' && !multiline) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
ref.current?.blur(); // blur performs the commit (§5.3)
|
ref.current?.blur(); // blur performs the commit (§5.3)
|
||||||
}
|
}
|
||||||
}}
|
}
|
||||||
onPaste={(event: React.ClipboardEvent) => {
|
: undefined
|
||||||
|
}
|
||||||
|
onPaste={
|
||||||
|
editing
|
||||||
|
? (event: React.ClipboardEvent) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
document.execCommand('insertText', false, event.clipboardData.getData('text/plain'));
|
document.execCommand('insertText', false, event.clipboardData.getData('text/plain'));
|
||||||
}}
|
}
|
||||||
|
: undefined
|
||||||
|
}
|
||||||
>
|
>
|
||||||
{children}
|
{children}
|
||||||
|
{fieldControls && (
|
||||||
|
<span className="edit-field-controls" contentEditable={false}>
|
||||||
|
{fieldControls}
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
{/* Editing chrome sits inside the element but outside the editable text
|
||||||
|
(contentEditable={false}), so it never reaches the value. mousedown
|
||||||
|
is prevented to keep the caret out of the chrome. */}
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className="edit-pencil"
|
||||||
|
contentEditable={false}
|
||||||
|
aria-label={`${s.edit.editField} — ${label}`}
|
||||||
|
title={pointer}
|
||||||
|
onMouseDown={(event: React.MouseEvent) => event.preventDefault()}
|
||||||
|
onClick={() => setEditing(true)}
|
||||||
|
>
|
||||||
|
<PencilIcon size={14} />
|
||||||
|
</button>
|
||||||
|
{editing && (
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className="edit-provenance"
|
||||||
|
contentEditable={false}
|
||||||
|
title={s.edit.copyPath}
|
||||||
|
onMouseDown={(event: React.MouseEvent) => event.preventDefault()}
|
||||||
|
onClick={copyPath}
|
||||||
|
>
|
||||||
|
{copied ? s.edit.pathCopied : pointer}
|
||||||
|
</button>
|
||||||
|
)}
|
||||||
|
{error && (
|
||||||
|
<span className="edit-field-error" contentEditable={false}>
|
||||||
|
{error}
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
</Comp>
|
</Comp>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,102 @@
|
|||||||
|
// Record controls (spec-v4-inline-editing E2): the settings / move / delete
|
||||||
|
// cluster of one record, plus the ghost affordance that creates a new one.
|
||||||
|
// Rendered only in edit mode; the caller places them inside the record's own
|
||||||
|
// element, or beside it for cards whose body is a link.
|
||||||
|
import { useI18n } from '@/i18n/provider';
|
||||||
|
import { ChevronDownIcon, ChevronUpIcon, GearIcon, PlusIcon, TrashIcon } from '@/components/ui/icons';
|
||||||
|
|
||||||
|
type RecordControlsProps = {
|
||||||
|
// Human-readable name of the record, carried into every aria-label.
|
||||||
|
label: string;
|
||||||
|
canUp?: boolean;
|
||||||
|
canDown?: boolean;
|
||||||
|
// The move pair renders only when the caller provides it — a filtered
|
||||||
|
// subset view (home featured grid) has no document-order move to offer.
|
||||||
|
onUp?: () => void;
|
||||||
|
onDown?: () => void;
|
||||||
|
onDelete: () => void;
|
||||||
|
onSettings?: () => void;
|
||||||
|
};
|
||||||
|
|
||||||
|
export function RecordControls({
|
||||||
|
label,
|
||||||
|
canUp,
|
||||||
|
canDown,
|
||||||
|
onUp,
|
||||||
|
onDown,
|
||||||
|
onDelete,
|
||||||
|
onSettings,
|
||||||
|
}: RecordControlsProps) {
|
||||||
|
const { ui: s } = useI18n();
|
||||||
|
return (
|
||||||
|
<span className="edit-record-controls">
|
||||||
|
{onSettings && (
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className="edit-record-btn"
|
||||||
|
aria-label={`${s.edit.settings} — ${label}`}
|
||||||
|
onMouseDown={(event) => event.stopPropagation()}
|
||||||
|
onClick={onSettings}
|
||||||
|
>
|
||||||
|
<GearIcon size={14} />
|
||||||
|
</button>
|
||||||
|
)}
|
||||||
|
{onUp && onDown && (
|
||||||
|
<>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className="edit-record-btn"
|
||||||
|
aria-label={`${s.edit.moveUp} — ${label}`}
|
||||||
|
disabled={!canUp}
|
||||||
|
onMouseDown={(event) => event.stopPropagation()}
|
||||||
|
onClick={onUp}
|
||||||
|
>
|
||||||
|
<ChevronUpIcon size={14} />
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className="edit-record-btn"
|
||||||
|
aria-label={`${s.edit.moveDown} — ${label}`}
|
||||||
|
disabled={!canDown}
|
||||||
|
onMouseDown={(event) => event.stopPropagation()}
|
||||||
|
onClick={onDown}
|
||||||
|
>
|
||||||
|
<ChevronDownIcon size={14} />
|
||||||
|
</button>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className="edit-record-btn edit-record-remove"
|
||||||
|
aria-label={`${s.edit.remove} — ${label}`}
|
||||||
|
onMouseDown={(event) => event.stopPropagation()}
|
||||||
|
onClick={() => {
|
||||||
|
if (window.confirm(s.edit.removeConfirm)) onDelete();
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<TrashIcon size={14} />
|
||||||
|
</button>
|
||||||
|
</span>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
type AddGhostProps = {
|
||||||
|
label: string;
|
||||||
|
onClick: () => void;
|
||||||
|
// 'inline' sits at the end of a list; 'card' fills a grid cell like the
|
||||||
|
// cards beside it, so the new record appears as the next one.
|
||||||
|
variant?: 'inline' | 'card';
|
||||||
|
};
|
||||||
|
|
||||||
|
export function AddGhost({ label, onClick, variant = 'inline' }: AddGhostProps) {
|
||||||
|
return (
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className={variant === 'card' ? 'edit-add-ghost edit-add-ghost-card' : 'edit-add-ghost'}
|
||||||
|
onClick={onClick}
|
||||||
|
>
|
||||||
|
<PlusIcon size={16} />
|
||||||
|
<span>{label}</span>
|
||||||
|
</button>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,189 @@
|
|||||||
|
// RecordSettings (spec-v4-inline-editing E2): the structure-settings dialog of
|
||||||
|
// one record. Inline editing covers text and tags; the fields that shape a
|
||||||
|
// record's structure — featured, section list, timeline variant, logo — live
|
||||||
|
// here, in a small form that writes through the same EditApi.
|
||||||
|
import { useEffect, useRef } from 'react';
|
||||||
|
import type { ReactNode } from 'react';
|
||||||
|
import { useEdit } from '@/hooks/useEdit';
|
||||||
|
import { useI18n } from '@/i18n/provider';
|
||||||
|
import { useClickOutside } from '@/hooks/useClickOutside';
|
||||||
|
import type { ProjectStructure, ExperienceStructure } from '@/i18n/dict-types';
|
||||||
|
import { ChevronDownIcon, ChevronUpIcon, PlusIcon, TrashIcon } from '@/components/ui/icons';
|
||||||
|
|
||||||
|
type RecordSettingsProps = {
|
||||||
|
title: string;
|
||||||
|
onClose: () => void;
|
||||||
|
children: ReactNode;
|
||||||
|
};
|
||||||
|
|
||||||
|
export function RecordSettings({ title, onClose, children }: RecordSettingsProps) {
|
||||||
|
const { ui: s } = useI18n();
|
||||||
|
const ref = useRef<HTMLDivElement | null>(null);
|
||||||
|
useClickOutside(ref, onClose);
|
||||||
|
useEffect(() => {
|
||||||
|
const onKey = (event: KeyboardEvent) => {
|
||||||
|
if (event.key === 'Escape') onClose();
|
||||||
|
};
|
||||||
|
document.addEventListener('keydown', onKey);
|
||||||
|
return () => document.removeEventListener('keydown', onKey);
|
||||||
|
}, [onClose]);
|
||||||
|
return (
|
||||||
|
<div className="record-settings" ref={ref} role="dialog" aria-label={title}>
|
||||||
|
<div className="record-settings-header">
|
||||||
|
<span className="record-settings-title">{title}</span>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className="record-settings-close"
|
||||||
|
aria-label={s.edit.closeSettings}
|
||||||
|
onClick={onClose}
|
||||||
|
>
|
||||||
|
×
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div className="record-settings-body">{children}</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// A project's structure: featured visibility and the section list — order,
|
||||||
|
// type, delete, add (spec-v4-inline-editing §2.4).
|
||||||
|
export function ProjectSettingsPanel({ project }: { project: ProjectStructure }) {
|
||||||
|
const edit = useEdit();
|
||||||
|
const { ui: s } = useI18n();
|
||||||
|
if (!edit) return null;
|
||||||
|
const projects = edit.dataOf('projects') as ProjectStructure[];
|
||||||
|
const index = projects.findIndex((p) => p.id === project.id);
|
||||||
|
if (index < 0) return null;
|
||||||
|
const sections = project.sections;
|
||||||
|
const typeLabels = s.edit.sectionTypes;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<label className="record-settings-field">
|
||||||
|
<input
|
||||||
|
type="checkbox"
|
||||||
|
checked={project.featured === true}
|
||||||
|
onChange={(event) => edit.setStructured('projects', `[${index}].featured`, event.target.checked)}
|
||||||
|
/>
|
||||||
|
{s.edit.featured}
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<div className="record-settings-group-title">{s.edit.sections}</div>
|
||||||
|
<ul className="record-settings-list">
|
||||||
|
{sections.map((section, i) => (
|
||||||
|
<li key={section.id} className="record-settings-row">
|
||||||
|
<code className="record-settings-id">{section.id}</code>
|
||||||
|
<select
|
||||||
|
aria-label={`${s.edit.sectionType} — ${section.id}`}
|
||||||
|
value={section.type}
|
||||||
|
onChange={(event) =>
|
||||||
|
edit.setStructured('projects', `[${index}].sections[${i}].type`, event.target.value)
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<option value="text">{typeLabels.text}</option>
|
||||||
|
<option value="diagram">{typeLabels.diagram}</option>
|
||||||
|
<option value="metrics">{typeLabels.metrics}</option>
|
||||||
|
<option value="code">{typeLabels.code}</option>
|
||||||
|
</select>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className="edit-record-btn"
|
||||||
|
aria-label={`${s.edit.moveUp} — ${section.id}`}
|
||||||
|
disabled={i === 0}
|
||||||
|
onClick={() => edit.moveItem('projects', `[${index}].sections`, i, i - 1)}
|
||||||
|
>
|
||||||
|
<ChevronUpIcon size={14} />
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className="edit-record-btn"
|
||||||
|
aria-label={`${s.edit.moveDown} — ${section.id}`}
|
||||||
|
disabled={i === sections.length - 1}
|
||||||
|
onClick={() => edit.moveItem('projects', `[${index}].sections`, i, i + 1)}
|
||||||
|
>
|
||||||
|
<ChevronDownIcon size={14} />
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className="edit-record-btn edit-record-remove"
|
||||||
|
aria-label={`${s.edit.remove} — ${section.id}`}
|
||||||
|
onClick={() => {
|
||||||
|
if (window.confirm(s.edit.removeConfirm)) {
|
||||||
|
edit.deleteRecord('section', { id: section.id, projectId: project.id });
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<TrashIcon size={14} />
|
||||||
|
</button>
|
||||||
|
</li>
|
||||||
|
))}
|
||||||
|
</ul>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className="edit-add-inline"
|
||||||
|
onClick={() => edit.addRecord('section', { projectId: project.id })}
|
||||||
|
>
|
||||||
|
<PlusIcon size={12} />
|
||||||
|
{s.edit.addSection}
|
||||||
|
</button>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// A timeline entry's decoration and metadata: the current/gap variant marker,
|
||||||
|
// location, logo path — all structure fields of the experience document.
|
||||||
|
export function ExperienceSettingsPanel({ entry }: { entry: ExperienceStructure }) {
|
||||||
|
const edit = useEdit();
|
||||||
|
const { ui: s } = useI18n();
|
||||||
|
if (!edit) return null;
|
||||||
|
const experiences = edit.dataOf('experience') as ExperienceStructure[];
|
||||||
|
const index = experiences.findIndex((e) => e.id === entry.id);
|
||||||
|
if (index < 0) return null;
|
||||||
|
|
||||||
|
const writeOrDrop = (field: string, value: string) => {
|
||||||
|
const trimmed = value.trim();
|
||||||
|
if (trimmed === '') {
|
||||||
|
edit.deleteStructured('experience', `[${index}].${field}`);
|
||||||
|
} else {
|
||||||
|
edit.setStructured('experience', `[${index}].${field}`, trimmed);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<label className="record-settings-field">
|
||||||
|
<span>{s.edit.variant}</span>
|
||||||
|
<select
|
||||||
|
value={entry.variant ?? ''}
|
||||||
|
onChange={(event) => {
|
||||||
|
const next = event.target.value;
|
||||||
|
if (next === '') edit.deleteStructured('experience', `[${index}].variant`);
|
||||||
|
else edit.setStructured('experience', `[${index}].variant`, next);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<option value="">{s.edit.variantNone}</option>
|
||||||
|
<option value="current">{s.edit.variantCurrent}</option>
|
||||||
|
<option value="gap">{s.edit.variantGap}</option>
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
|
<label className="record-settings-field">
|
||||||
|
<span>{s.edit.fields.location}</span>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
defaultValue={entry.location ?? ''}
|
||||||
|
key={`location-${entry.location ?? ''}-${entry.variant ?? ''}`}
|
||||||
|
onBlur={(event) => writeOrDrop('location', event.target.value)}
|
||||||
|
/>
|
||||||
|
</label>
|
||||||
|
<label className="record-settings-field">
|
||||||
|
<span>{s.edit.fields.logo}</span>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
defaultValue={entry.logo ?? ''}
|
||||||
|
key={`logo-${entry.logo ?? ''}-${entry.variant ?? ''}`}
|
||||||
|
onBlur={(event) => writeOrDrop('logo', event.target.value)}
|
||||||
|
/>
|
||||||
|
</label>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,132 @@
|
|||||||
|
// TagListEditor (spec-v4-inline-editing E5): an array field rendered with the
|
||||||
|
// site's own container and tag elements. Outside edit mode the markup is
|
||||||
|
// exactly what the section renders today — same container, same tag elements,
|
||||||
|
// zero chrome. In edit mode every item carries move/delete controls inside its
|
||||||
|
// own element (EditableText fieldControls islands) and a ghost add button
|
||||||
|
// follows the list. Text arrays (interests, keywords, metrics, tagline tags)
|
||||||
|
// and structure arrays (technologies, skills) are the same component — one
|
||||||
|
// editing surface (E1).
|
||||||
|
import type { ElementType } from 'react';
|
||||||
|
import { useEdit } from '@/hooks/useEdit';
|
||||||
|
import { useI18n } from '@/i18n/provider';
|
||||||
|
import { EditableText } from '@/components/ui/EditableText';
|
||||||
|
import { parsePath, setPath } from '@/i18n/draft';
|
||||||
|
import type { DraftDocId } from '@/i18n/draft';
|
||||||
|
import { ChevronDownIcon, ChevronUpIcon, PlusIcon, TrashIcon } from '@/components/ui/icons';
|
||||||
|
|
||||||
|
type TagListEditorProps = {
|
||||||
|
// Structure document to edit; defaults to the text document of the edited
|
||||||
|
// language (E1) — text arrays need no explicit doc.
|
||||||
|
doc?: DraftDocId;
|
||||||
|
// Array path inside that document: `profile.currentInterests` for a text
|
||||||
|
// document, `[2].technologies` for a structure document.
|
||||||
|
arrayPath: string;
|
||||||
|
items: string[];
|
||||||
|
// The container and item elements the site renders today.
|
||||||
|
containerAs: ElementType;
|
||||||
|
containerClassName: string;
|
||||||
|
as: ElementType;
|
||||||
|
itemClassName?: string;
|
||||||
|
// Tag's accent variant, passed through when the site's tag component takes it.
|
||||||
|
accent?: boolean;
|
||||||
|
// Human-readable names for the accessibility labels and the add button.
|
||||||
|
labelPrefix: string;
|
||||||
|
addLabel: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export function TagListEditor({
|
||||||
|
doc,
|
||||||
|
arrayPath,
|
||||||
|
items,
|
||||||
|
containerAs,
|
||||||
|
containerClassName,
|
||||||
|
as,
|
||||||
|
itemClassName,
|
||||||
|
accent,
|
||||||
|
labelPrefix,
|
||||||
|
addLabel,
|
||||||
|
}: TagListEditorProps) {
|
||||||
|
const edit = useEdit();
|
||||||
|
const { ui: s } = useI18n();
|
||||||
|
const Container = containerAs;
|
||||||
|
const Comp = as;
|
||||||
|
|
||||||
|
if (!edit) {
|
||||||
|
return (
|
||||||
|
<Container className={containerClassName}>
|
||||||
|
{items.map((item, i) => (
|
||||||
|
<Comp key={i} {...(accent ? { accent: true } : {})} className={itemClassName}>
|
||||||
|
{item}
|
||||||
|
</Comp>
|
||||||
|
))}
|
||||||
|
</Container>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
const docId = doc ?? edit.textDoc;
|
||||||
|
|
||||||
|
const write = (next: string[]) =>
|
||||||
|
edit.apply(docId, setPath(edit.dataOf(docId), parsePath(arrayPath), next));
|
||||||
|
|
||||||
|
const controls = (i: number) => (
|
||||||
|
<>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className="edit-item-control"
|
||||||
|
aria-label={`${s.edit.moveUp} — ${labelPrefix} ${i + 1}`}
|
||||||
|
disabled={i === 0}
|
||||||
|
onMouseDown={(event) => event.stopPropagation()}
|
||||||
|
onClick={() => edit.moveItem(docId, arrayPath, i, i - 1)}
|
||||||
|
>
|
||||||
|
<ChevronUpIcon size={12} />
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className="edit-item-control"
|
||||||
|
aria-label={`${s.edit.moveDown} — ${labelPrefix} ${i + 1}`}
|
||||||
|
disabled={i === items.length - 1}
|
||||||
|
onMouseDown={(event) => event.stopPropagation()}
|
||||||
|
onClick={() => edit.moveItem(docId, arrayPath, i, i + 1)}
|
||||||
|
>
|
||||||
|
<ChevronDownIcon size={12} />
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className="edit-item-control edit-item-remove"
|
||||||
|
aria-label={`${s.edit.remove} — ${labelPrefix} ${i + 1}`}
|
||||||
|
onMouseDown={(event) => event.stopPropagation()}
|
||||||
|
onClick={() => {
|
||||||
|
if (window.confirm(s.edit.removeConfirm)) write(items.filter((_, j) => j !== i));
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<TrashIcon size={12} />
|
||||||
|
</button>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Container className={containerClassName}>
|
||||||
|
{items.map((item, i) => (
|
||||||
|
<EditableText
|
||||||
|
key={i}
|
||||||
|
as={Comp}
|
||||||
|
doc={docId}
|
||||||
|
path={`${arrayPath}[${i}]`}
|
||||||
|
label={`${labelPrefix} ${i + 1}`}
|
||||||
|
className={itemClassName}
|
||||||
|
{...(accent ? { accent: true } : {})}
|
||||||
|
fieldControls={controls(i)}
|
||||||
|
>
|
||||||
|
{item}
|
||||||
|
</EditableText>
|
||||||
|
))}
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className="edit-add-inline"
|
||||||
|
onClick={() => write([...items, s.edit.newTag])}
|
||||||
|
>
|
||||||
|
<PlusIcon size={12} />
|
||||||
|
{addLabel}
|
||||||
|
</button>
|
||||||
|
</Container>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -84,3 +84,58 @@ export function MoonIcon({ size = 20 }: IconProps) {
|
|||||||
</svg>
|
</svg>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Edit-mode chrome glyphs (spec-v4-inline-editing §3): one stroke language as
|
||||||
|
// the bar icons. The pencil opens an inline editor, the gear opens a record's
|
||||||
|
// structure settings, the arrows move array items, the trash removes a record.
|
||||||
|
export function PencilIcon({ size = 16 }: IconProps) {
|
||||||
|
return (
|
||||||
|
<svg viewBox="0 0 24 24" width={size} height={size} aria-hidden="true" {...strokeProps}>
|
||||||
|
<path d="M12 20h9" />
|
||||||
|
<path d="M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4Z" />
|
||||||
|
</svg>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export function PlusIcon({ size = 16 }: IconProps) {
|
||||||
|
return (
|
||||||
|
<svg viewBox="0 0 24 24" width={size} height={size} aria-hidden="true" {...strokeProps}>
|
||||||
|
<path d="M12 5v14M5 12h14" />
|
||||||
|
</svg>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export function TrashIcon({ size = 16 }: IconProps) {
|
||||||
|
return (
|
||||||
|
<svg viewBox="0 0 24 24" width={size} height={size} aria-hidden="true" {...strokeProps}>
|
||||||
|
<path d="M3 6h18" />
|
||||||
|
<path d="M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2" />
|
||||||
|
<path d="M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6" />
|
||||||
|
</svg>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export function ChevronUpIcon({ size = 16 }: IconProps) {
|
||||||
|
return (
|
||||||
|
<svg viewBox="0 0 24 24" width={size} height={size} aria-hidden="true" {...strokeProps}>
|
||||||
|
<path d="m18 15-6-6-6 6" />
|
||||||
|
</svg>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export function ChevronDownIcon({ size = 16 }: IconProps) {
|
||||||
|
return (
|
||||||
|
<svg viewBox="0 0 24 24" width={size} height={size} aria-hidden="true" {...strokeProps}>
|
||||||
|
<path d="m6 9 6 6 6-6" />
|
||||||
|
</svg>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export function GearIcon({ size = 16 }: IconProps) {
|
||||||
|
return (
|
||||||
|
<svg viewBox="0 0 24 24" width={size} height={size} aria-hidden="true" {...strokeProps}>
|
||||||
|
<circle cx="12" cy="12" r="3.5" />
|
||||||
|
<path d="M12 2v3M12 19v3M2 12h3M19 12h3M4.9 4.9l2.1 2.1M17 17l2.1 2.1M19.1 4.9 17 7M7 17l-2.1 2.1" />
|
||||||
|
</svg>
|
||||||
|
)
|
||||||
|
}
|
||||||
+43
-7
@@ -1,17 +1,53 @@
|
|||||||
// The edit-mode context (spec-v4 §5.3): the API EditModeShell hands to
|
// The edit-mode context (spec-v4 §5.3, spec-v4-inline-editing E4): the API
|
||||||
// EditableText consumers. Lives on its own so component files stay pure
|
// EditModeShell hands to every editing consumer. Lives on its own so
|
||||||
// components (react/only-export-components).
|
// component files stay pure components (react/only-export-components).
|
||||||
import { createContext } from 'react';
|
import { createContext, useContext } from 'react';
|
||||||
import type { ContentIssue } from '@/i18n/validate';
|
import type { ContentIssue } from '@/i18n/validate';
|
||||||
|
import type {
|
||||||
|
ConflictField,
|
||||||
|
DraftDocId,
|
||||||
|
FieldInfo,
|
||||||
|
RecordIds,
|
||||||
|
RecordKind,
|
||||||
|
} from '@/i18n/draft';
|
||||||
|
|
||||||
// commit/revert return the validator issues when the candidate draft is
|
// commit/apply/revert return the validator issues when the candidate draft is
|
||||||
// invalid (the edit was NOT applied), or null when it was accepted.
|
// invalid (the change was NOT applied), or null when it was accepted.
|
||||||
export type EditApi = {
|
export type EditApi = {
|
||||||
|
// The text document of the language being edited — the default `doc` for
|
||||||
|
// every text path (E1).
|
||||||
|
textDoc: DraftDocId;
|
||||||
|
// Text-document helpers, unchanged from v1 (paths relative to textDoc).
|
||||||
commit: (path: string, value: string) => ContentIssue[] | null;
|
commit: (path: string, value: string) => ContentIssue[] | null;
|
||||||
revert: (path: string) => ContentIssue[] | null;
|
revert: (path: string) => ContentIssue[] | null;
|
||||||
isPathDirty: (path: string) => boolean;
|
isPathDirty: (path: string) => boolean;
|
||||||
|
// Generic draft surface (E4): read one document, propose the next version,
|
||||||
|
// ask where a field lives.
|
||||||
|
describe: (doc: DraftDocId, path: string) => FieldInfo;
|
||||||
|
apply: (doc: DraftDocId, next: unknown) => ContentIssue[] | null;
|
||||||
|
dataOf: (doc: DraftDocId) => unknown;
|
||||||
|
// Structure fields (E4): set or delete one value at a concrete path.
|
||||||
|
setStructured: (doc: DraftDocId, path: string, value: unknown) => ContentIssue[] | null;
|
||||||
|
deleteStructured: (doc: DraftDocId, path: string) => ContentIssue[] | null;
|
||||||
|
isPathDirtyIn: (doc: DraftDocId, path: string) => boolean;
|
||||||
|
// One primitive for every order question (E5): record order (document root
|
||||||
|
// array) and tag order (array field) are the same move.
|
||||||
|
moveItem: (doc: DraftDocId, path: string, from: number, to: number) => ContentIssue[] | null;
|
||||||
|
// Records (E2/E3): structure record + text entries move as one action.
|
||||||
|
addRecord: (kind: RecordKind, options?: { projectId?: string }) => ContentIssue[] | null;
|
||||||
|
deleteRecord: (kind: RecordKind, ids: RecordIds) => ContentIssue[] | null;
|
||||||
|
// A draft-only record's id follows its title; a saved record's id is fixed.
|
||||||
|
isCreated: (kind: RecordKind, ids: RecordIds) => boolean;
|
||||||
|
renameRecord: (kind: RecordKind, ids: RecordIds, rawId: string) => ContentIssue[] | null;
|
||||||
|
// Conflicts, field by field (E8).
|
||||||
|
conflictFields: (doc: DraftDocId) => ConflictField[];
|
||||||
|
resolveConflictField: (doc: DraftDocId, path: string, side: 'mine' | 'theirs') => ContentIssue[] | null;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Without a provider (every visitor request, every page outside edit mode)
|
// Without a provider (every visitor request, every page outside edit mode)
|
||||||
// the context is null and EditableText is transparent.
|
// the context is null and every editing affordance is absent.
|
||||||
export const EditContext = createContext<EditApi | null>(null);
|
export const EditContext = createContext<EditApi | null>(null);
|
||||||
|
|
||||||
|
export function useEdit(): EditApi | null {
|
||||||
|
return useContext(EditContext);
|
||||||
|
}
|
||||||
@@ -114,6 +114,50 @@
|
|||||||
"QR_ALT": "QR code"
|
"QR_ALT": "QR code"
|
||||||
},
|
},
|
||||||
"edit": {
|
"edit": {
|
||||||
|
"editField": "Edit this field",
|
||||||
|
"copyPath": "Copy JSON path",
|
||||||
|
"pathCopied": "Copied",
|
||||||
|
"emptyRequired": "Required fields cannot be empty",
|
||||||
|
"settings": "Record settings",
|
||||||
|
"closeSettings": "Close settings",
|
||||||
|
"moveUp": "Move up",
|
||||||
|
"moveDown": "Move down",
|
||||||
|
"remove": "Remove",
|
||||||
|
"removeConfirm": "Remove this item?",
|
||||||
|
"newTag": "new",
|
||||||
|
"emphasis": "Emphasis",
|
||||||
|
"featured": "Featured on the home page",
|
||||||
|
"sections": "Sections",
|
||||||
|
"sectionType": "Section type",
|
||||||
|
"sectionTypes": {
|
||||||
|
"text": "prose",
|
||||||
|
"diagram": "diagram",
|
||||||
|
"metrics": "metrics",
|
||||||
|
"code": "code"
|
||||||
|
},
|
||||||
|
"conflictFields": "Show conflicting fields",
|
||||||
|
"yours": "mine:",
|
||||||
|
"theirs": "theirs:",
|
||||||
|
"keepMine": "Keep mine",
|
||||||
|
"keepTheirs": "Keep theirs",
|
||||||
|
"variant": "Timeline variant",
|
||||||
|
"variantNone": "normal",
|
||||||
|
"variantCurrent": "current role",
|
||||||
|
"variantGap": "career break",
|
||||||
|
"addTaglineSegment": "Add tagline segment",
|
||||||
|
"addKeyword": "Add keyword",
|
||||||
|
"addInterest": "Add interest",
|
||||||
|
"addSkill": "Add skill",
|
||||||
|
"addTechnology": "Add technology",
|
||||||
|
"addMetric": "Add metric",
|
||||||
|
"addResponsibility": "Add responsibility",
|
||||||
|
"addQuoteDetail": "Add quote paragraph",
|
||||||
|
"addQuote": "Add quote",
|
||||||
|
"addProject": "Add project",
|
||||||
|
"addSection": "Add section",
|
||||||
|
"addExperience": "Add experience",
|
||||||
|
"addSkillGroup": "Add skill group",
|
||||||
|
"addPhilosophy": "Add philosophy point",
|
||||||
"title": "Edit mode",
|
"title": "Edit mode",
|
||||||
"changes": "Unsaved changes",
|
"changes": "Unsaved changes",
|
||||||
"noChanges": "No unsaved changes",
|
"noChanges": "No unsaved changes",
|
||||||
@@ -178,7 +222,14 @@
|
|||||||
"quoteDetail": "quote paragraph",
|
"quoteDetail": "quote paragraph",
|
||||||
"company": "company",
|
"company": "company",
|
||||||
"duration": "duration",
|
"duration": "duration",
|
||||||
"projectRole": "project role"
|
"projectRole": "project role",
|
||||||
|
"interests": "interest",
|
||||||
|
"skill": "skill",
|
||||||
|
"technology": "technology",
|
||||||
|
"metric": "metric",
|
||||||
|
"pointKeywords": "philosophy keyword",
|
||||||
|
"location": "location",
|
||||||
|
"logo": "logo"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -114,6 +114,50 @@
|
|||||||
"QR_ALT": "mã QR"
|
"QR_ALT": "mã QR"
|
||||||
},
|
},
|
||||||
"edit": {
|
"edit": {
|
||||||
|
"editField": "Sửa trường này",
|
||||||
|
"copyPath": "Copy đường dẫn JSON",
|
||||||
|
"pathCopied": "Đã copy",
|
||||||
|
"emptyRequired": "Trường bắt buộc không được để trống",
|
||||||
|
"settings": "Cài đặt bản ghi",
|
||||||
|
"closeSettings": "Đóng cài đặt",
|
||||||
|
"moveUp": "Chuyển lên",
|
||||||
|
"moveDown": "Chuyển xuống",
|
||||||
|
"remove": "Xóa",
|
||||||
|
"removeConfirm": "Xóa mục này?",
|
||||||
|
"newTag": "mới",
|
||||||
|
"emphasis": "Nhấn mạnh",
|
||||||
|
"featured": "Nổi bật",
|
||||||
|
"sections": "Các mục",
|
||||||
|
"sectionType": "Kiểu mục",
|
||||||
|
"sectionTypes": {
|
||||||
|
"text": "chữ",
|
||||||
|
"diagram": "sơ đồ",
|
||||||
|
"metrics": "chỉ số",
|
||||||
|
"code": "code"
|
||||||
|
},
|
||||||
|
"conflictFields": "Xem các trường xung đột",
|
||||||
|
"yours": "bản của tôi:",
|
||||||
|
"theirs": "bản gốc:",
|
||||||
|
"keepMine": "Giữ bản của tôi",
|
||||||
|
"keepTheirs": "Giữ bản gốc",
|
||||||
|
"variant": "Biến thể timeline",
|
||||||
|
"variantNone": "bình thường",
|
||||||
|
"variantCurrent": "đang làm",
|
||||||
|
"variantGap": "nghỉ giữa hai vai trò",
|
||||||
|
"addTaglineSegment": "Thêm đoạn tagline",
|
||||||
|
"addKeyword": "Thêm từ khóa",
|
||||||
|
"addInterest": "Thêm sở thích",
|
||||||
|
"addSkill": "Thêm kỹ năng",
|
||||||
|
"addTechnology": "Thêm công nghệ",
|
||||||
|
"addMetric": "Thêm chỉ số",
|
||||||
|
"addResponsibility": "Thêm trách nhiệm",
|
||||||
|
"addQuoteDetail": "Thêm đoạn trích dẫn",
|
||||||
|
"addQuote": "Thêm trích dẫn",
|
||||||
|
"addProject": "Thêm dự án",
|
||||||
|
"addSection": "Thêm mục",
|
||||||
|
"addExperience": "Thêm kinh nghiệm",
|
||||||
|
"addSkillGroup": "Thêm nhóm kỹ năng",
|
||||||
|
"addPhilosophy": "Thêm nguyên lý",
|
||||||
"title": "Chế độ sửa",
|
"title": "Chế độ sửa",
|
||||||
"changes": "Thay đổi chưa lưu",
|
"changes": "Thay đổi chưa lưu",
|
||||||
"noChanges": "Không có thay đổi chưa lưu",
|
"noChanges": "Không có thay đổi chưa lưu",
|
||||||
@@ -178,7 +222,14 @@
|
|||||||
"quoteDetail": "đoạn trích dẫn",
|
"quoteDetail": "đoạn trích dẫn",
|
||||||
"company": "công ty",
|
"company": "công ty",
|
||||||
"duration": "thời gian công tác",
|
"duration": "thời gian công tác",
|
||||||
"projectRole": "vai trò dự án"
|
"projectRole": "vai trò dự án",
|
||||||
|
"interests": "sở thích",
|
||||||
|
"skill": "kỹ năng",
|
||||||
|
"technology": "công nghệ",
|
||||||
|
"metric": "chỉ số",
|
||||||
|
"pointKeywords": "từ khóa nguyên lý",
|
||||||
|
"location": "địa điểm",
|
||||||
|
"logo": "logo"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+59
-21
@@ -3,10 +3,15 @@ import { SectionHeading } from '@/components/ui/SectionHeading'
|
|||||||
import { Tag } from '@/components/ui/Tag'
|
import { Tag } from '@/components/ui/Tag'
|
||||||
import { InView } from '@/components/ui/InView'
|
import { InView } from '@/components/ui/InView'
|
||||||
import { EditableText } from '@/components/ui/EditableText'
|
import { EditableText } from '@/components/ui/EditableText'
|
||||||
|
import { TagListEditor } from '@/components/ui/TagListEditor'
|
||||||
|
import { RecordControls, AddGhost } from '@/components/ui/RecordControls'
|
||||||
|
import { useEdit } from '@/hooks/useEdit'
|
||||||
import { useI18n } from '@/i18n/provider'
|
import { useI18n } from '@/i18n/provider'
|
||||||
|
|
||||||
export function AboutPage() {
|
export function AboutPage() {
|
||||||
const { ui: s, content: c } = useI18n()
|
const { ui: s, content: c } = useI18n()
|
||||||
|
const edit = useEdit()
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<InView>
|
<InView>
|
||||||
@@ -51,7 +56,7 @@ export function AboutPage() {
|
|||||||
{c.profile.philosophy.map((point, i) => (
|
{c.profile.philosophy.map((point, i) => (
|
||||||
<motion.div
|
<motion.div
|
||||||
key={point.id}
|
key={point.id}
|
||||||
className="philosophy-card"
|
className={edit ? 'philosophy-card edit-record-host' : 'philosophy-card'}
|
||||||
initial={{ opacity: 0, y: 24 }}
|
initial={{ opacity: 0, y: 24 }}
|
||||||
whileInView={{ opacity: 1, y: 0 }}
|
whileInView={{ opacity: 1, y: 0 }}
|
||||||
viewport={{ once: true, amount: 0.2 }}
|
viewport={{ once: true, amount: 0.2 }}
|
||||||
@@ -59,31 +64,49 @@ export function AboutPage() {
|
|||||||
whileHover={{ scale: 1.02, y: -4 }}
|
whileHover={{ scale: 1.02, y: -4 }}
|
||||||
whileTap={{ scale: 0.98 }}
|
whileTap={{ scale: 0.98 }}
|
||||||
>
|
>
|
||||||
|
{edit && (
|
||||||
|
<RecordControls
|
||||||
|
label={point.title}
|
||||||
|
canUp={i > 0}
|
||||||
|
canDown={i < c.profile.philosophy.length - 1}
|
||||||
|
onUp={() => edit.moveItem('profile', 'philosophy', i, i - 1)}
|
||||||
|
onDown={() => edit.moveItem('profile', 'philosophy', i, i + 1)}
|
||||||
|
onDelete={() => edit.deleteRecord('philosophy', { id: point.id })}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
<EditableText as="h3" path={`profile.philosophy.${point.id}.title`} label={s.edit.fields.pointTitle}>
|
<EditableText as="h3" path={`profile.philosophy.${point.id}.title`} label={s.edit.fields.pointTitle}>
|
||||||
{point.title}
|
{point.title}
|
||||||
</EditableText>
|
</EditableText>
|
||||||
<EditableText as="p" path={`profile.philosophy.${point.id}.description`} label={s.edit.fields.pointDescription} multiline>
|
<EditableText as="p" path={`profile.philosophy.${point.id}.description`} label={s.edit.fields.pointDescription} multiline>
|
||||||
{point.description}
|
{point.description}
|
||||||
</EditableText>
|
</EditableText>
|
||||||
<div className="philosophy-keywords">
|
<TagListEditor
|
||||||
{point.keywords.map((kw) => (
|
arrayPath={`profile.philosophy.${point.id}.keywords`}
|
||||||
<Tag key={kw}>{kw}</Tag>
|
items={point.keywords}
|
||||||
))}
|
containerAs="div"
|
||||||
</div>
|
containerClassName="philosophy-keywords"
|
||||||
|
as={Tag}
|
||||||
|
labelPrefix={`${point.title} — ${s.edit.fields.pointKeywords}`}
|
||||||
|
addLabel={s.edit.addKeyword}
|
||||||
|
/>
|
||||||
</motion.div>
|
</motion.div>
|
||||||
))}
|
))}
|
||||||
|
{edit && <AddGhost variant="card" label={s.edit.addPhilosophy} onClick={() => edit.addRecord('philosophy')} />}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<h3 className="subheading">
|
<h3 className="subheading">
|
||||||
{s.about.exploringTitlePage}
|
{s.about.exploringTitlePage}
|
||||||
</h3>
|
</h3>
|
||||||
<div className="interests-list">
|
<TagListEditor
|
||||||
{c.profile.currentInterests.map((interest) => (
|
arrayPath="profile.currentInterests"
|
||||||
<Tag key={interest} accent>
|
items={c.profile.currentInterests}
|
||||||
{interest}
|
containerAs="div"
|
||||||
</Tag>
|
containerClassName="interests-list"
|
||||||
))}
|
as={Tag}
|
||||||
</div>
|
accent
|
||||||
|
labelPrefix={s.edit.fields.interests}
|
||||||
|
addLabel={s.edit.addInterest}
|
||||||
|
/>
|
||||||
</motion.section>
|
</motion.section>
|
||||||
</InView>
|
</InView>
|
||||||
<InView>
|
<InView>
|
||||||
@@ -103,7 +126,7 @@ export function AboutPage() {
|
|||||||
{c.skillGroups.map((group, i) => (
|
{c.skillGroups.map((group, i) => (
|
||||||
<motion.div
|
<motion.div
|
||||||
key={group.id}
|
key={group.id}
|
||||||
className="expertise-card"
|
className={edit ? 'expertise-card edit-record-host' : 'expertise-card'}
|
||||||
initial={{ opacity: 0, y: 24 }}
|
initial={{ opacity: 0, y: 24 }}
|
||||||
whileInView={{ opacity: 1, y: 0 }}
|
whileInView={{ opacity: 1, y: 0 }}
|
||||||
viewport={{ once: true, amount: 0.2 }}
|
viewport={{ once: true, amount: 0.2 }}
|
||||||
@@ -111,18 +134,33 @@ export function AboutPage() {
|
|||||||
whileHover={{ scale: 1.02, y: -4 }}
|
whileHover={{ scale: 1.02, y: -4 }}
|
||||||
whileTap={{ scale: 0.98 }}
|
whileTap={{ scale: 0.98 }}
|
||||||
>
|
>
|
||||||
|
{edit && (
|
||||||
|
<RecordControls
|
||||||
|
label={group.title}
|
||||||
|
canUp={i > 0}
|
||||||
|
canDown={i < c.skillGroups.length - 1}
|
||||||
|
onUp={() => edit.moveItem('skills', '', i, i - 1)}
|
||||||
|
onDown={() => edit.moveItem('skills', '', i, i + 1)}
|
||||||
|
onDelete={() => edit.deleteRecord('skill-group', { id: group.id })}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
<EditableText as="h3" path={`skills.${group.id}.title`} label={s.edit.fields.groupTitle}>
|
<EditableText as="h3" path={`skills.${group.id}.title`} label={s.edit.fields.groupTitle}>
|
||||||
{group.title}
|
{group.title}
|
||||||
</EditableText>
|
</EditableText>
|
||||||
<ul className="expertise-skills">
|
<TagListEditor
|
||||||
{group.skills.map((skill: string) => (
|
doc="skills"
|
||||||
<li key={skill} className="expertise-skill">
|
arrayPath={`[${i}].skills`}
|
||||||
{skill}
|
items={group.skills}
|
||||||
</li>
|
containerAs="ul"
|
||||||
))}
|
containerClassName="expertise-skills"
|
||||||
</ul>
|
as="li"
|
||||||
|
itemClassName="expertise-skill"
|
||||||
|
labelPrefix={`${group.title} — ${s.edit.fields.skill}`}
|
||||||
|
addLabel={s.edit.addSkill}
|
||||||
|
/>
|
||||||
</motion.div>
|
</motion.div>
|
||||||
))}
|
))}
|
||||||
|
{edit && <AddGhost variant="card" label={s.edit.addSkillGroup} onClick={() => edit.addRecord('skill-group')} />}
|
||||||
</div>
|
</div>
|
||||||
</motion.section>
|
</motion.section>
|
||||||
</InView>
|
</InView>
|
||||||
|
|||||||
@@ -2,10 +2,17 @@ import { motion } from 'motion/react'
|
|||||||
import { SectionHeading } from '@/components/ui/SectionHeading'
|
import { SectionHeading } from '@/components/ui/SectionHeading'
|
||||||
import { InView } from '@/components/ui/InView'
|
import { InView } from '@/components/ui/InView'
|
||||||
import { EditableText } from '@/components/ui/EditableText'
|
import { EditableText } from '@/components/ui/EditableText'
|
||||||
|
import { TagListEditor } from '@/components/ui/TagListEditor'
|
||||||
|
import { RecordControls, AddGhost } from '@/components/ui/RecordControls'
|
||||||
|
import { RecordSettings, ExperienceSettingsPanel } from '@/components/ui/RecordSettings'
|
||||||
|
import { useEdit } from '@/hooks/useEdit'
|
||||||
import { useI18n } from '@/i18n/provider'
|
import { useI18n } from '@/i18n/provider'
|
||||||
|
import { useState } from 'react'
|
||||||
|
|
||||||
export function ExperiencePage() {
|
export function ExperiencePage() {
|
||||||
const { ui: s, content: c } = useI18n()
|
const { ui: s, content: c } = useI18n()
|
||||||
|
const edit = useEdit()
|
||||||
|
const [settingsFor, setSettingsFor] = useState<string | null>(null)
|
||||||
return (
|
return (
|
||||||
<InView>
|
<InView>
|
||||||
<motion.section
|
<motion.section
|
||||||
@@ -24,13 +31,30 @@ export function ExperiencePage() {
|
|||||||
{c.experiences.map((exp, i) => (
|
{c.experiences.map((exp, i) => (
|
||||||
<motion.div
|
<motion.div
|
||||||
key={exp.id}
|
key={exp.id}
|
||||||
className={exp.variant ? `timeline-entry timeline-entry-${exp.variant}` : 'timeline-entry'}
|
className={[
|
||||||
|
'timeline-entry',
|
||||||
|
exp.variant ? `timeline-entry-${exp.variant}` : '',
|
||||||
|
edit ? 'edit-record-host' : '',
|
||||||
|
]
|
||||||
|
.filter(Boolean)
|
||||||
|
.join(' ')}
|
||||||
initial={{ opacity: 0, y: 24 }}
|
initial={{ opacity: 0, y: 24 }}
|
||||||
whileInView={{ opacity: 1, y: 0 }}
|
whileInView={{ opacity: 1, y: 0 }}
|
||||||
viewport={{ once: true, amount: 0.2 }}
|
viewport={{ once: true, amount: 0.2 }}
|
||||||
transition={{ duration: 0.45, ease: 'easeOut', delay: i * 0.08 }}
|
transition={{ duration: 0.45, ease: 'easeOut', delay: i * 0.08 }}
|
||||||
>
|
>
|
||||||
<div className="timeline-marker" />
|
<div className="timeline-marker" />
|
||||||
|
{edit && (
|
||||||
|
<RecordControls
|
||||||
|
label={exp.title}
|
||||||
|
canUp={i > 0}
|
||||||
|
canDown={i < c.experiences.length - 1}
|
||||||
|
onUp={() => edit.moveItem('experience', '', i, i - 1)}
|
||||||
|
onDown={() => edit.moveItem('experience', '', i, i + 1)}
|
||||||
|
onDelete={() => edit.deleteRecord('experience', { id: exp.id })}
|
||||||
|
onSettings={() => setSettingsFor(exp.id)}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
<div className="timeline-header">
|
<div className="timeline-header">
|
||||||
<EditableText as="div" className="timeline-title" path={`experience.${exp.id}.title`} label={s.edit.fields.expTitle}>
|
<EditableText as="div" className="timeline-title" path={`experience.${exp.id}.title`} label={s.edit.fields.expTitle}>
|
||||||
{exp.title}
|
{exp.title}
|
||||||
@@ -45,20 +69,18 @@ export function ExperiencePage() {
|
|||||||
{exp.location && <span className="timeline-location">{exp.location}</span>}
|
{exp.location && <span className="timeline-location">{exp.location}</span>}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<ul className="timeline-responsibilities">
|
<TagListEditor
|
||||||
{exp.responsibilities.map((r, ri) => (
|
arrayPath={`experience.${exp.id}.responsibilities`}
|
||||||
<EditableText
|
items={exp.responsibilities}
|
||||||
|
containerAs="ul"
|
||||||
|
containerClassName="timeline-responsibilities"
|
||||||
as="li"
|
as="li"
|
||||||
key={ri}
|
labelPrefix={`${exp.title} — ${s.edit.fields.responsibility}`}
|
||||||
path={`experience.${exp.id}.responsibilities[${ri}]`}
|
addLabel={s.edit.addResponsibility}
|
||||||
label={`${exp.title} — ${s.edit.fields.responsibility} ${ri + 1}`}
|
/>
|
||||||
>
|
|
||||||
{r}
|
|
||||||
</EditableText>
|
|
||||||
))}
|
|
||||||
</ul>
|
|
||||||
</motion.div>
|
</motion.div>
|
||||||
))}
|
))}
|
||||||
|
{edit && <AddGhost label={s.edit.addExperience} onClick={() => edit.addRecord('experience')} />}
|
||||||
<div className="timeline-tldr">
|
<div className="timeline-tldr">
|
||||||
<span className="timeline-tldr-marker" aria-hidden="true" />
|
<span className="timeline-tldr-marker" aria-hidden="true" />
|
||||||
<span className="timeline-tldr-chip">{s.experience.tldr}</span>
|
<span className="timeline-tldr-chip">{s.experience.tldr}</span>
|
||||||
@@ -66,6 +88,14 @@ export function ExperiencePage() {
|
|||||||
{c.profile.tldr}
|
{c.profile.tldr}
|
||||||
</EditableText>
|
</EditableText>
|
||||||
</div>
|
</div>
|
||||||
|
{edit && settingsFor && (
|
||||||
|
<RecordSettings title={s.edit.settings} onClose={() => setSettingsFor(null)}>
|
||||||
|
{(() => {
|
||||||
|
const entry = c.experiences.find((e) => e.id === settingsFor)
|
||||||
|
return entry ? <ExperienceSettingsPanel entry={entry} /> : null
|
||||||
|
})()}
|
||||||
|
</RecordSettings>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</motion.section>
|
</motion.section>
|
||||||
</InView>
|
</InView>
|
||||||
|
|||||||
@@ -2,11 +2,19 @@ import {SectionHeading} from '@/components/ui/SectionHeading'
|
|||||||
import {EditableText} from '@/components/ui/EditableText'
|
import {EditableText} from '@/components/ui/EditableText'
|
||||||
import {motion} from 'motion/react'
|
import {motion} from 'motion/react'
|
||||||
import {InView} from '@/components/ui/InView'
|
import {InView} from '@/components/ui/InView'
|
||||||
|
import { TagListEditor } from '@/components/ui/TagListEditor'
|
||||||
|
import { RecordControls, AddGhost } from '@/components/ui/RecordControls'
|
||||||
|
import { useEdit } from '@/hooks/useEdit'
|
||||||
|
import { useI18n } from '@/i18n/provider'
|
||||||
|
import { setPath, parsePath } from '@/i18n/draft'
|
||||||
|
|
||||||
import {useI18n} from '@/i18n/provider'
|
// philosophyQuotes are text-only records: they live in the language document
|
||||||
|
// being edited, so add and delete go through the plain document primitives.
|
||||||
|
const quotesPath = 'profile.philosophyQuotes'
|
||||||
|
|
||||||
export function PhilosophyPage() {
|
export function PhilosophyPage() {
|
||||||
const {ui: s, content: c} = useI18n()
|
const {ui: s, content: c} = useI18n()
|
||||||
|
const edit = useEdit()
|
||||||
return (
|
return (
|
||||||
<InView>
|
<InView>
|
||||||
<motion.section
|
<motion.section
|
||||||
@@ -25,12 +33,27 @@ export function PhilosophyPage() {
|
|||||||
{c.profile.philosophyQuotes.map((quote, i) => (
|
{c.profile.philosophyQuotes.map((quote, i) => (
|
||||||
<motion.div
|
<motion.div
|
||||||
key={i}
|
key={i}
|
||||||
className="philosophy-quote"
|
className={edit ? 'philosophy-quote edit-record-host' : 'philosophy-quote'}
|
||||||
initial={{opacity: 0, y: 24}}
|
initial={{opacity: 0, y: 24}}
|
||||||
whileInView={{opacity: 1, y: 0}}
|
whileInView={{opacity: 1, y: 0}}
|
||||||
viewport={{once: true, amount: 0.2}}
|
viewport={{once: true, amount: 0.2}}
|
||||||
transition={{duration: 0.45, ease: 'easeOut', delay: i * 0.08}}
|
transition={{duration: 0.45, ease: 'easeOut', delay: i * 0.08}}
|
||||||
>
|
>
|
||||||
|
{edit && (
|
||||||
|
<RecordControls
|
||||||
|
label={quote.title}
|
||||||
|
canUp={i > 0}
|
||||||
|
canDown={i < c.profile.philosophyQuotes.length - 1}
|
||||||
|
onUp={() => edit.moveItem(edit.textDoc, quotesPath, i, i - 1)}
|
||||||
|
onDown={() => edit.moveItem(edit.textDoc, quotesPath, i, i + 1)}
|
||||||
|
onDelete={() => {
|
||||||
|
const doc = edit.dataOf(edit.textDoc) as Record<string, any>
|
||||||
|
const next = setPath(doc, parsePath(quotesPath),
|
||||||
|
(doc.profile.philosophyQuotes as unknown[]).filter((_, j) => j !== i))
|
||||||
|
edit.apply(edit.textDoc, next)
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
<EditableText
|
<EditableText
|
||||||
as="h3"
|
as="h3"
|
||||||
path={`profile.philosophyQuotes[${i}].title`}
|
path={`profile.philosophyQuotes[${i}].title`}
|
||||||
@@ -38,21 +61,28 @@ export function PhilosophyPage() {
|
|||||||
>
|
>
|
||||||
{quote.title}
|
{quote.title}
|
||||||
</EditableText>
|
</EditableText>
|
||||||
<div>
|
<TagListEditor
|
||||||
{quote.details.map((detail, j) => (
|
arrayPath={`profile.philosophyQuotes[${i}].details`}
|
||||||
<EditableText
|
items={quote.details}
|
||||||
|
containerAs="div"
|
||||||
|
containerClassName="philosophy-quote-details"
|
||||||
as="p"
|
as="p"
|
||||||
key={j}
|
labelPrefix={`${quote.title} — ${s.edit.fields.quoteDetail}`}
|
||||||
path={`profile.philosophyQuotes[${i}].details[${j}]`}
|
addLabel={s.edit.addQuoteDetail}
|
||||||
label={`${s.edit.fields.quoteDetail} ${j + 1}`}
|
/>
|
||||||
multiline
|
|
||||||
>
|
|
||||||
{detail}
|
|
||||||
</EditableText>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
</motion.div>
|
</motion.div>
|
||||||
))}
|
))}
|
||||||
|
{edit && (
|
||||||
|
<AddGhost
|
||||||
|
label={s.edit.addQuote}
|
||||||
|
onClick={() => {
|
||||||
|
const doc = edit.dataOf(edit.textDoc) as Record<string, any>
|
||||||
|
const next = setPath(doc, parsePath(quotesPath),
|
||||||
|
[...(doc.profile.philosophyQuotes as unknown[]), { title: 'New quote', details: ['Write the quote here.'] }])
|
||||||
|
edit.apply(edit.textDoc, next)
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</motion.section>
|
</motion.section>
|
||||||
</InView>
|
</InView>
|
||||||
|
|||||||
@@ -5,7 +5,11 @@ import { Tag } from '@/components/ui/Tag'
|
|||||||
import { EditableText } from '@/components/ui/EditableText'
|
import { EditableText } from '@/components/ui/EditableText'
|
||||||
import { InView } from '@/components/ui/InView'
|
import { InView } from '@/components/ui/InView'
|
||||||
import { useI18n } from '@/i18n/provider'
|
import { useI18n } from '@/i18n/provider'
|
||||||
|
import { TagListEditor } from '@/components/ui/TagListEditor'
|
||||||
|
import { RecordControls, AddGhost } from '@/components/ui/RecordControls'
|
||||||
|
import { RecordSettings, ProjectSettingsPanel } from '@/components/ui/RecordSettings'
|
||||||
|
import { useEdit } from '@/hooks/useEdit'
|
||||||
|
import { useState } from 'react'
|
||||||
const sectionVariants = {
|
const sectionVariants = {
|
||||||
hidden: { opacity: 0 },
|
hidden: { opacity: 0 },
|
||||||
visible: { opacity: 1, transition: { duration: 0.5 } },
|
visible: { opacity: 1, transition: { duration: 0.5 } },
|
||||||
@@ -20,8 +24,9 @@ const itemTransition = (delay: number): Transition => ({
|
|||||||
export function ProjectDetailPage() {
|
export function ProjectDetailPage() {
|
||||||
const { id } = useParams<{ id: string }>()
|
const { id } = useParams<{ id: string }>()
|
||||||
const { ui: s, content: c } = useI18n()
|
const { ui: s, content: c } = useI18n()
|
||||||
|
const edit = useEdit()
|
||||||
|
const [settingsOpen, setSettingsOpen] = useState(false)
|
||||||
const project = c.projects.find((p) => p.id === id)
|
const project = c.projects.find((p) => p.id === id)
|
||||||
|
|
||||||
if (!project) {
|
if (!project) {
|
||||||
return (
|
return (
|
||||||
<InView>
|
<InView>
|
||||||
@@ -66,6 +71,13 @@ export function ProjectDetailPage() {
|
|||||||
{project.title}
|
{project.title}
|
||||||
</EditableText>
|
</EditableText>
|
||||||
<Badge variant="outline">{s.projects.categories[project.category]}</Badge>
|
<Badge variant="outline">{s.projects.categories[project.category]}</Badge>
|
||||||
|
{edit && (
|
||||||
|
<RecordControls
|
||||||
|
label={project.title}
|
||||||
|
onDelete={() => edit.deleteRecord('project', { id: project.id })}
|
||||||
|
onSettings={() => setSettingsOpen(true)}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</motion.div>
|
</motion.div>
|
||||||
|
|
||||||
<EditableText
|
<EditableText
|
||||||
@@ -83,7 +95,7 @@ export function ProjectDetailPage() {
|
|||||||
</EditableText>
|
</EditableText>
|
||||||
|
|
||||||
<div className="prose">
|
<div className="prose">
|
||||||
{project.metrics && project.metrics.length > 0 && (
|
{(edit || (project.metrics?.length ?? 0) > 0) && (
|
||||||
<motion.div
|
<motion.div
|
||||||
initial={{ opacity: 0, y: 24 }}
|
initial={{ opacity: 0, y: 24 }}
|
||||||
whileInView={{ opacity: 1, y: 0 }}
|
whileInView={{ opacity: 1, y: 0 }}
|
||||||
@@ -91,13 +103,16 @@ export function ProjectDetailPage() {
|
|||||||
transition={itemTransition(0.16)}
|
transition={itemTransition(0.16)}
|
||||||
>
|
>
|
||||||
<h3>{s.projectDetail.impact}</h3>
|
<h3>{s.projectDetail.impact}</h3>
|
||||||
<div style={{ display: 'flex', gap: '16px', flexWrap: 'wrap' }}>
|
<TagListEditor
|
||||||
{project.metrics.map((m) => (
|
arrayPath={`projects.${project.id}.metrics`}
|
||||||
<span key={m} className="achievement-metric">
|
items={project.metrics ?? []}
|
||||||
{m}
|
containerAs="div"
|
||||||
</span>
|
containerClassName="project-metrics"
|
||||||
))}
|
as="span"
|
||||||
</div>
|
itemClassName="achievement-metric"
|
||||||
|
labelPrefix={`${project.title} — ${s.edit.fields.metric}`}
|
||||||
|
addLabel={s.edit.addMetric}
|
||||||
|
/>
|
||||||
</motion.div>
|
</motion.div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
@@ -120,14 +135,19 @@ export function ProjectDetailPage() {
|
|||||||
transition={itemTransition(0.32)}
|
transition={itemTransition(0.32)}
|
||||||
>
|
>
|
||||||
<h3>{s.projectDetail.technologies}</h3>
|
<h3>{s.projectDetail.technologies}</h3>
|
||||||
<div className="philosophy-keywords">
|
<TagListEditor
|
||||||
{project.technologies.map((tech) => (
|
doc="projects"
|
||||||
<Tag key={tech}>{tech}</Tag>
|
arrayPath={`[${c.projects.findIndex((p) => p.id === project.id)}].technologies`}
|
||||||
))}
|
items={project.technologies}
|
||||||
</div>
|
containerAs="div"
|
||||||
|
containerClassName="philosophy-keywords"
|
||||||
|
as={Tag}
|
||||||
|
labelPrefix={`${project.title} — ${s.edit.fields.technology}`}
|
||||||
|
addLabel={s.edit.addTechnology}
|
||||||
|
/>
|
||||||
</motion.div>
|
</motion.div>
|
||||||
|
|
||||||
{project.sections && project.sections.length > 0 && (
|
{(edit || (project.sections?.length ?? 0) > 0) && (
|
||||||
<div>
|
<div>
|
||||||
<motion.h3
|
<motion.h3
|
||||||
initial={{ opacity: 0, y: 24 }}
|
initial={{ opacity: 0, y: 24 }}
|
||||||
@@ -139,13 +159,23 @@ export function ProjectDetailPage() {
|
|||||||
</motion.h3>
|
</motion.h3>
|
||||||
{project.sections.map((section, idx) => (
|
{project.sections.map((section, idx) => (
|
||||||
<motion.div
|
<motion.div
|
||||||
key={idx}
|
key={section.id}
|
||||||
className="project-section"
|
className={edit ? 'project-section edit-record-host' : 'project-section'}
|
||||||
initial={{ opacity: 0, y: 24 }}
|
initial={{ opacity: 0, y: 24 }}
|
||||||
whileInView={{ opacity: 1, y: 0 }}
|
whileInView={{ opacity: 1, y: 0 }}
|
||||||
viewport={{ once: true, amount: 0.2 }}
|
viewport={{ once: true, amount: 0.2 }}
|
||||||
transition={itemTransition(0.48 + idx * 0.08)}
|
transition={itemTransition(0.48 + idx * 0.08)}
|
||||||
>
|
>
|
||||||
|
{edit && (
|
||||||
|
<RecordControls
|
||||||
|
label={section.title}
|
||||||
|
canUp={idx > 0}
|
||||||
|
canDown={idx < (project.sections?.length ?? 0) - 1}
|
||||||
|
onUp={() => edit.moveItem('projects', `[${c.projects.findIndex((p) => p.id === project.id)}].sections`, idx, idx - 1)}
|
||||||
|
onDown={() => edit.moveItem('projects', `[${c.projects.findIndex((p) => p.id === project.id)}].sections`, idx, idx + 1)}
|
||||||
|
onDelete={() => edit.deleteRecord('section', { id: section.id, projectId: project.id })}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
<EditableText as="h4" path={`projects.${project.id}.sections.${section.id}.title`} label={`${section.title} — ${s.edit.fields.sectionTitle}`}>
|
<EditableText as="h4" path={`projects.${project.id}.sections.${section.id}.title`} label={`${section.title} — ${s.edit.fields.sectionTitle}`}>
|
||||||
{section.title}
|
{section.title}
|
||||||
</EditableText>
|
</EditableText>
|
||||||
@@ -155,9 +185,20 @@ export function ProjectDetailPage() {
|
|||||||
<Tag accent>{section.type}</Tag>
|
<Tag accent>{section.type}</Tag>
|
||||||
</motion.div>
|
</motion.div>
|
||||||
))}
|
))}
|
||||||
|
{edit && (
|
||||||
|
<AddGhost
|
||||||
|
label={s.edit.addSection}
|
||||||
|
onClick={() => edit.addRecord('section', { projectId: project.id })}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
{edit && settingsOpen && (
|
||||||
|
<RecordSettings title={s.edit.settings} onClose={() => setSettingsOpen(false)}>
|
||||||
|
<ProjectSettingsPanel project={project} />
|
||||||
|
</RecordSettings>
|
||||||
|
)}
|
||||||
</motion.section>
|
</motion.section>
|
||||||
</InView>
|
</InView>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -3,7 +3,12 @@ import { Badge } from '@/components/ui/Badge'
|
|||||||
import { motion } from 'motion/react'
|
import { motion } from 'motion/react'
|
||||||
import { InView } from '@/components/ui/InView'
|
import { InView } from '@/components/ui/InView'
|
||||||
import { EditableText } from '@/components/ui/EditableText'
|
import { EditableText } from '@/components/ui/EditableText'
|
||||||
|
import { TagListEditor } from '@/components/ui/TagListEditor'
|
||||||
|
import { RecordControls, AddGhost } from '@/components/ui/RecordControls'
|
||||||
|
import { RecordSettings, ProjectSettingsPanel } from '@/components/ui/RecordSettings'
|
||||||
|
import { useEdit } from '@/hooks/useEdit'
|
||||||
import { useI18n } from '@/i18n/provider'
|
import { useI18n } from '@/i18n/provider'
|
||||||
|
import { useState } from 'react'
|
||||||
|
|
||||||
import { Link } from 'react-router'
|
import { Link } from 'react-router'
|
||||||
|
|
||||||
@@ -12,6 +17,8 @@ const MotionLink = motion.create(Link)
|
|||||||
|
|
||||||
export function ProjectsListPage() {
|
export function ProjectsListPage() {
|
||||||
const { ui: s, content: c } = useI18n()
|
const { ui: s, content: c } = useI18n()
|
||||||
|
const edit = useEdit()
|
||||||
|
const [settingsFor, setSettingsFor] = useState<string | null>(null)
|
||||||
return (
|
return (
|
||||||
<InView>
|
<InView>
|
||||||
<motion.section
|
<motion.section
|
||||||
@@ -27,7 +34,8 @@ export function ProjectsListPage() {
|
|||||||
>
|
>
|
||||||
<SectionHeading title={s.projects.all} tag={s.projects.all} />
|
<SectionHeading title={s.projects.all} tag={s.projects.all} />
|
||||||
<div className="projects-grid">
|
<div className="projects-grid">
|
||||||
{c.projects.map((project, i) => (
|
{c.projects.map((project, i) => {
|
||||||
|
const card = (
|
||||||
<MotionLink
|
<MotionLink
|
||||||
key={project.id}
|
key={project.id}
|
||||||
to={`/projects/${project.id}`}
|
to={`/projects/${project.id}`}
|
||||||
@@ -50,6 +58,19 @@ export function ProjectsListPage() {
|
|||||||
<EditableText as="p" className="project-card-summary" path={`projects.${project.id}.summary`} label={`${project.title} — ${s.edit.fields.summary}`}>
|
<EditableText as="p" className="project-card-summary" path={`projects.${project.id}.summary`} label={`${project.title} — ${s.edit.fields.summary}`}>
|
||||||
{project.summary}
|
{project.summary}
|
||||||
</EditableText>
|
</EditableText>
|
||||||
|
{edit ? (
|
||||||
|
<TagListEditor
|
||||||
|
doc="projects"
|
||||||
|
arrayPath={`[${i}].technologies`}
|
||||||
|
items={project.technologies}
|
||||||
|
containerAs="div"
|
||||||
|
containerClassName="project-card-techs"
|
||||||
|
as="span"
|
||||||
|
itemClassName="tag"
|
||||||
|
labelPrefix={`${project.title} — ${s.edit.fields.technology}`}
|
||||||
|
addLabel={s.edit.addTechnology}
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
<div className="project-card-techs">
|
<div className="project-card-techs">
|
||||||
{project.technologies.slice(0, 4).map((tech) => (
|
{project.technologies.slice(0, 4).map((tech) => (
|
||||||
<span key={tech} className="tag">
|
<span key={tech} className="tag">
|
||||||
@@ -57,10 +78,37 @@ export function ProjectsListPage() {
|
|||||||
</span>
|
</span>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
|
)}
|
||||||
<span className="project-card-cta">{s.projects.viewDetails} →</span>
|
<span className="project-card-cta">{s.projects.viewDetails} →</span>
|
||||||
</MotionLink>
|
</MotionLink>
|
||||||
))}
|
)
|
||||||
|
return edit ? (
|
||||||
|
<div key={project.id} className="edit-record-shell">
|
||||||
|
<RecordControls
|
||||||
|
label={project.title}
|
||||||
|
canUp={i > 0}
|
||||||
|
canDown={i < c.projects.length - 1}
|
||||||
|
onUp={() => edit.moveItem('projects', '', i, i - 1)}
|
||||||
|
onDown={() => edit.moveItem('projects', '', i, i + 1)}
|
||||||
|
onDelete={() => edit.deleteRecord('project', { id: project.id })}
|
||||||
|
onSettings={() => setSettingsFor(project.id)}
|
||||||
|
/>
|
||||||
|
{card}
|
||||||
</div>
|
</div>
|
||||||
|
) : (
|
||||||
|
card
|
||||||
|
)
|
||||||
|
})}
|
||||||
|
{edit && <AddGhost variant="card" label={s.edit.addProject} onClick={() => edit.addRecord('project')} />}
|
||||||
|
</div>
|
||||||
|
{edit && settingsFor && (
|
||||||
|
<RecordSettings title={s.edit.settings} onClose={() => setSettingsFor(null)}>
|
||||||
|
{(() => {
|
||||||
|
const project = c.projects.find((p) => p.id === settingsFor)
|
||||||
|
return project ? <ProjectSettingsPanel project={project} /> : null
|
||||||
|
})()}
|
||||||
|
</RecordSettings>
|
||||||
|
)}
|
||||||
</motion.section>
|
</motion.section>
|
||||||
</InView>
|
</InView>
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in new issue
Block a user