chore: generate
This commit is contained in:
@@ -361,11 +361,7 @@ export function App({ catalog }: AppProps) {
|
||||
}),
|
||||
)
|
||||
if (window.location.hash.startsWith("#annotations=")) url.hash = window.location.hash
|
||||
window.history.replaceState(
|
||||
null,
|
||||
"",
|
||||
url,
|
||||
)
|
||||
window.history.replaceState(null, "", url)
|
||||
}, [activeVariant.id, activeFlow?.id, selectedScreen, ui.mode, ui.viewerOpen])
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
@@ -51,8 +51,14 @@ export function AnnotationEditor(props: AnnotationEditorProps) {
|
||||
onPointerDown={(event) => {
|
||||
if (event.target !== event.currentTarget) return
|
||||
const bounds = event.currentTarget.getBoundingClientRect()
|
||||
const column = Math.min(props.cols - 1, Math.max(0, Math.floor(((event.clientX - bounds.left) / bounds.width) * props.cols)))
|
||||
const row = Math.min(props.rows - 1, Math.max(0, Math.floor(((event.clientY - bounds.top) / bounds.height) * props.rows)))
|
||||
const column = Math.min(
|
||||
props.cols - 1,
|
||||
Math.max(0, Math.floor(((event.clientX - bounds.left) / bounds.width) * props.cols)),
|
||||
)
|
||||
const row = Math.min(
|
||||
props.rows - 1,
|
||||
Math.max(0, Math.floor(((event.clientY - bounds.top) / bounds.height) * props.rows)),
|
||||
)
|
||||
setDraft({ row, column, note: "" })
|
||||
}}
|
||||
>
|
||||
@@ -83,7 +89,9 @@ export function AnnotationEditor(props: AnnotationEditorProps) {
|
||||
>
|
||||
<header>
|
||||
<span>{draft.id ? "Edit annotation" : "New annotation"}</span>
|
||||
<small>R{draft.row + 1} · C{draft.column + 1}</small>
|
||||
<small>
|
||||
R{draft.row + 1} · C{draft.column + 1}
|
||||
</small>
|
||||
</header>
|
||||
<textarea
|
||||
ref={textareaRef}
|
||||
@@ -117,8 +125,12 @@ export function AnnotationEditor(props: AnnotationEditorProps) {
|
||||
>
|
||||
Delete
|
||||
</button>
|
||||
) : <span />}
|
||||
<button type="button" onClick={() => setDraft(undefined)}>Cancel</button>
|
||||
) : (
|
||||
<span />
|
||||
)}
|
||||
<button type="button" onClick={() => setDraft(undefined)}>
|
||||
Cancel
|
||||
</button>
|
||||
<button type="button" className="annotation-composer-save" disabled={!draft.note.trim()} onClick={save}>
|
||||
{draft.id ? "Save" : "Add"}
|
||||
</button>
|
||||
@@ -130,16 +142,22 @@ export function AnnotationEditor(props: AnnotationEditorProps) {
|
||||
<header>
|
||||
<div>
|
||||
<strong>Annotations</strong>
|
||||
<span>{props.annotations.length === 0 ? "Click anywhere on the terminal" : `${props.annotations.length} placed`}</span>
|
||||
<span>
|
||||
{props.annotations.length === 0 ? "Click anywhere on the terminal" : `${props.annotations.length} placed`}
|
||||
</span>
|
||||
</div>
|
||||
<button type="button" onClick={props.onDone}>Done</button>
|
||||
<button type="button" onClick={props.onDone}>
|
||||
Done
|
||||
</button>
|
||||
</header>
|
||||
<div className="annotation-list">
|
||||
{props.annotations.map((annotation, index) => (
|
||||
<button key={annotation.id} type="button" className="annotation-list-row" onClick={() => edit(annotation)}>
|
||||
<span className="annotation-list-pin">{index + 1}</span>
|
||||
<span>
|
||||
<small>Row {annotation.row + 1} · Column {annotation.column + 1}</small>
|
||||
<small>
|
||||
Row {annotation.row + 1} · Column {annotation.column + 1}
|
||||
</small>
|
||||
<strong>{annotation.note}</strong>
|
||||
</span>
|
||||
</button>
|
||||
@@ -155,7 +173,11 @@ export function AnnotationEditor(props: AnnotationEditorProps) {
|
||||
>
|
||||
Open GitHub issue
|
||||
</a>
|
||||
<span>{complete.length === 0 ? "Add a note to continue" : `${complete.length} note${complete.length === 1 ? "" : "s"} will be included`}</span>
|
||||
<span>
|
||||
{complete.length === 0
|
||||
? "Add a note to continue"
|
||||
: `${complete.length} note${complete.length === 1 ? "" : "s"} will be included`}
|
||||
</span>
|
||||
</footer>
|
||||
</aside>
|
||||
</>
|
||||
|
||||
@@ -6,7 +6,13 @@ import { CaptureSetSwitcher } from "./CaptureSetSwitcher"
|
||||
import { CaptureContextMenu } from "./CaptureContextMenu"
|
||||
import { feedbackIssueUrl } from "../feedback"
|
||||
import { CaptureActionsMenu } from "./CaptureActionsMenu"
|
||||
import { annotationUrl, readAnnotationDraft, readAnnotations, type Annotation, type AnnotationDocument } from "../annotations"
|
||||
import {
|
||||
annotationUrl,
|
||||
readAnnotationDraft,
|
||||
readAnnotations,
|
||||
type Annotation,
|
||||
type AnnotationDocument,
|
||||
} from "../annotations"
|
||||
import { AnnotationEditor } from "./AnnotationEditor"
|
||||
|
||||
interface ViewerProps {
|
||||
@@ -56,7 +62,8 @@ export function Viewer({
|
||||
const [annotating, setAnnotating] = useState(() => window.location.hash.startsWith("#annotations="))
|
||||
const [annotations, setAnnotations] = useState<ReadonlyArray<Annotation>>(() => {
|
||||
const linked = readAnnotations(new URL(window.location.href), identifier, variant.id)
|
||||
if (linked.length > 0) return linked.filter((annotation) => annotation.row < frame.rows && annotation.column < frame.cols)
|
||||
if (linked.length > 0)
|
||||
return linked.filter((annotation) => annotation.row < frame.rows && annotation.column < frame.cols)
|
||||
try {
|
||||
const stored = localStorage.getItem(storageKey)
|
||||
if (!stored) return []
|
||||
@@ -186,7 +193,9 @@ export function Viewer({
|
||||
setAnnotations([...annotations, annotation])
|
||||
}}
|
||||
onChange={(id, note) =>
|
||||
setAnnotations(annotations.map((annotation) => annotation.id === id ? { ...annotation, note } : annotation))
|
||||
setAnnotations(
|
||||
annotations.map((annotation) => (annotation.id === id ? { ...annotation, note } : annotation)),
|
||||
)
|
||||
}
|
||||
onDelete={(id) => setAnnotations(annotations.filter((annotation) => annotation.id !== id))}
|
||||
onDone={() => {
|
||||
|
||||
@@ -1334,7 +1334,9 @@ kbd {
|
||||
transform: translate(-50%, 1.2rem);
|
||||
border-radius: 0.85rem;
|
||||
background: #1a1a1a;
|
||||
box-shadow: 0 12px 40px rgb(0 0 0 / 55%), 0 0 0 1px rgb(255 255 255 / 9%);
|
||||
box-shadow:
|
||||
0 12px 40px rgb(0 0 0 / 55%),
|
||||
0 0 0 1px rgb(255 255 255 / 9%);
|
||||
cursor: default;
|
||||
animation: annotation-composer-in 150ms cubic-bezier(0.34, 1.56, 0.64, 1);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user