snapsteps/src/features/guides/components/Frame.tsx
johannes-hernehult f214b0ac4d feat: add frame reordering and improve file upload accessibility
- Add Up/Down reorder controls to Frame component
- Add handleReOrderFrames hook using splice swap
- Improve FileUpload: keyboard support, aria attributes, fix accept=image/* typo
- Extract component-level CSS for Frame, Step, FileUpload
- Update focus-visible styles; scope border style to .file-upload
2026-06-15 19:49:00 +02:00

58 lines
1.5 KiB
TypeScript

import "./Frame.css";
import type { FrameType, StepType } from "../../../lib/schemas";
import Step from "./Step";
export default function Frame({
frame,
frameIndex,
onRemove,
addStep,
removeStep,
updateStep,
updateTitle,
reOrder,
}: {
frame: FrameType;
frameIndex: number;
onRemove: (frameId: string) => void;
addStep: (frameId: string) => void;
removeStep: (stepId: string) => void;
updateStep: (stepId: string, text: string) => void;
updateTitle: (frameId: string, title: string) => void;
reOrder: (startIndex: number, endIndex: number) => void;
}) {
return (
<div>
<button type="button" onClick={() => reOrder(frameIndex, frameIndex - 1)}>
Up
</button>
<button type="button" onClick={() => reOrder(frameIndex, frameIndex + 1)}>
Down
</button>
<button type="button" onClick={() => onRemove(frame.id)}>
Remove Frame
</button>
<label>
Title
<input
type="text"
onChange={(e) => updateTitle(frame.id, e.target.value)}
/>
</label>
<img src={URL.createObjectURL(frame.file)} alt={frame.title} />
<button type="button" onClick={() => addStep(frame.id)}>
Add Step
</button>
{frame.steps.map((step: StepType, index: number) => (
<Step
key={step.id}
step={step}
index={index}
removeStep={removeStep}
updateStep={updateStep}
/>
))}
</div>
);
}