Skip to content

armgit / mimik

Public Imported from GitHub
0

🎬 A browser extension and desktop app that turns your clicks into step-by-step guides with annotated screenshots πŸ“–

feat(ui): add a read-only mode to the step list and step card

Luis Ortiz77a04572fcf1
diff --git a/src/ui/fullview/components/GuideStepList.tsx b/src/ui/fullview/components/GuideStepList.tsx
index a0cb4ed..b50bcc6 100644
--- a/src/ui/fullview/components/GuideStepList.tsx
+++ b/src/ui/fullview/components/GuideStepList.tsx
@@ -14,6 +14,7 @@ interface GuideStepListProps {
onDelete: (stepId: string) => void;
onOpenEditor: (stepId: string, tool: 'annotate' | 'redact' | 'crop' | 'target') => void;
onReorder: (newSteps: Step[]) => void;
+ readOnly?: boolean;
}
export default function GuideStepList({
@@ -24,6 +25,7 @@ export default function GuideStepList({
onDelete,
onOpenEditor,
onReorder,
+ readOnly,
}: GuideStepListProps) {
const { scrollToStepId, setActiveStepId } = useFullview((s) => ({
scrollToStepId: s.scrollToStepId,
@@ -97,17 +99,22 @@ export default function GuideStepList({
onDescriptionChange={onDescriptionChange}
onDelete={onDelete}
onOpenEditor={onOpenEditor}
- dragHandleProps={{
- onDragStart: (e: React.DragEvent) => {
- setDragIndex(idx);
- e.dataTransfer.effectAllowed = 'move';
- },
- onDragOver: (e: React.DragEvent) => {
- e.preventDefault();
- setDragOverIndex(idx);
- },
- onDragEnd: handleDragEnd,
- }}
+ readOnly={readOnly}
+ dragHandleProps={
+ readOnly
+ ? undefined
+ : {
+ onDragStart: (e: React.DragEvent) => {
+ setDragIndex(idx);
+ e.dataTransfer.effectAllowed = 'move';
+ },
+ onDragOver: (e: React.DragEvent) => {
+ e.preventDefault();
+ setDragOverIndex(idx);
+ },
+ onDragEnd: handleDragEnd,
+ }
+ }
/>
</div>
))}
diff --git a/src/ui/sidepanel/StepCard.tsx b/src/ui/sidepanel/StepCard.tsx
index 78a04ea..d308c6c 100644
--- a/src/ui/sidepanel/StepCard.tsx
+++ b/src/ui/sidepanel/StepCard.tsx
@@ -23,6 +23,7 @@ interface StepCardProps {
onOpenEditor?: (stepId: string, tool: 'annotate' | 'redact' | 'crop' | 'target') => void;
onCopy?: (stepId: string) => void;
placeholderRatio?: number;
+ readOnly?: boolean;
}
export default function StepCard({
@@ -33,6 +34,7 @@ export default function StepCard({
dragHandleProps,
onOpenEditor,
placeholderRatio,
+ readOnly,
}: StepCardProps) {
const [description, setDescription] = useState(step.description);
const [dragOver, setDragOver] = useState(false);
@@ -100,7 +102,8 @@ export default function StepCard({
alt={`Step ${step.index + 1} screenshot`}
className="!rounded-none !border-0"
crop
- onOpenEditor={onOpenEditor ? (tool) => onOpenEditor(step.id, tool) : undefined}
+ readOnly={readOnly}
+ onOpenEditor={!readOnly && onOpenEditor ? (tool) => onOpenEditor(step.id, tool) : undefined}
/>
) : (
<ImagePlaceholder
@@ -115,13 +118,19 @@ export default function StepCard({
<span className="flex items-center justify-center w-[22px] h-[22px] rounded-full text-[11px] font-bold shrink-0 bg-primary text-primary-foreground">
{step.index + 1}
</span>
- <textarea
- className="w-full text-[13px] font-medium resize-none outline-none border-0 bg-transparent p-0 leading-snug flex-1 text-foreground"
- value={description}
- rows={1}
- onChange={(e) => setDescription(e.target.value)}
- onBlur={handleDescriptionBlur}
- />
+ {readOnly ? (
+ <p className="text-[13px] font-medium leading-snug flex-1 text-foreground whitespace-pre-wrap">
+ {step.description}
+ </p>
+ ) : (
+ <textarea
+ className="w-full text-[13px] font-medium resize-none outline-none border-0 bg-transparent p-0 leading-snug flex-1 text-foreground"
+ value={description}
+ rows={1}
+ onChange={(e) => setDescription(e.target.value)}
+ onBlur={handleDescriptionBlur}
+ />
+ )}
</div>
<div className="flex items-center justify-end mt-1">
<div className="flex items-center gap-0.5">
@@ -134,13 +143,15 @@ export default function StepCard({
{copied ? <Check size={13} /> : <Copy size={13} />}
</button>
)}
- <button
- onClick={() => setConfirmDelete(true)}
- className="p-1 rounded-md transition-colors text-border hover:text-destructive"
- title={i18n.t('recording.deleteStep')}
- >
- <Trash2 size={13} />
- </button>
+ {!readOnly && (
+ <button
+ onClick={() => setConfirmDelete(true)}
+ className="p-1 rounded-md transition-colors text-border hover:text-destructive"
+ title={i18n.t('recording.deleteStep')}
+ >
+ <Trash2 size={13} />
+ </button>
+ )}
</div>
</div>
</div>