π¬ A browser extension and desktop app that turns your clicks into step-by-step guides with annotated screenshots π
TypeScript browser-extensionchrome-extensiondocumentationfirefox-extensionguide-generatorlocal-firstmanifest-v3privacy-firstproductivityreactscreenshotstep-by-step-guidetutorialtypescriptworkflowwxt
fix(ui): size the missing-image placeholder like a real screenshot
Luis Ortizc63ebed2892a
diff --git a/src/ui/fullview/components/GuideStepList.tsx b/src/ui/fullview/components/GuideStepList.tsxindex 6428fc6..a0cb4ed 100644--- a/src/ui/fullview/components/GuideStepList.tsx+++ b/src/ui/fullview/components/GuideStepList.tsx@@ -3,6 +3,7 @@ import { reorderSteps } from '@/core/guides/service';import type { Screenshot, Step } from '@/core/guides/types';import { useFullview } from '@/stores/fullview';import EmptyGuideState from '@/ui/shared/EmptyGuideState';+import { siblingRatio } from '@/ui/shared/ImagePlaceholder';import StepCard from '@/ui/sidepanel/StepCard';interface GuideStepListProps {@@ -32,6 +33,7 @@ export default function GuideStepList({const [dragIndex, setDragIndex] = useState<number | null>(null);const [dragOverIndex, setDragOverIndex] = useState<number | null>(null);const stepRefs = useRef<Map<string, HTMLDivElement>>(new Map());+ const placeholderRatio = siblingRatio(screenshots);useEffect(() => {if (scrollToStepId) {@@ -91,6 +93,7 @@ export default function GuideStepList({<StepCardstep={step}screenshot={screenshots.get(step.id)}+ placeholderRatio={placeholderRatio}onDescriptionChange={onDescriptionChange}onDelete={onDelete}onOpenEditor={onOpenEditor}diff --git a/src/ui/shared/ImagePlaceholder.tsx b/src/ui/shared/ImagePlaceholder.tsxindex 4d1ccc8..ab6068f 100644--- a/src/ui/shared/ImagePlaceholder.tsx+++ b/src/ui/shared/ImagePlaceholder.tsx@@ -1,4 +1,6 @@import { ImageOff } from 'lucide-react';+import type { Screenshot } from '@/core/guides/types';+import { resolveViewport } from '@/core/screenshot/geometry';interface ImagePlaceholderProps {label: string;@@ -6,11 +8,13 @@ interface ImagePlaceholderProps {className?: string;}-export default function ImagePlaceholder({ label, ratio, className = '' }: ImagePlaceholderProps) {+const DEFAULT_RATIO = 16 / 10;++export default function ImagePlaceholder({ label, ratio = DEFAULT_RATIO, className = '' }: ImagePlaceholderProps) {return (<divclassName={`flex flex-col items-center justify-center gap-2 rounded-lg border border-dashed border-border bg-secondary/60 ${className}`}- style={ratio ? { aspectRatio: ratio } : undefined}+ style={{ aspectRatio: ratio }}><span className="flex items-center justify-center w-11 h-11 rounded-full bg-card text-muted-foreground shadow-sm"><ImageOff size={19} />@@ -19,3 +23,11 @@ export default function ImagePlaceholder({ label, ratio, className = '' }: Image</div>);}++export function siblingRatio(screenshots: Map<string, Screenshot>): number | undefined {+ for (const screenshot of screenshots.values()) {+ const viewport = resolveViewport(screenshot);+ if (viewport.width && viewport.height) return viewport.width / viewport.height;+ }+ return undefined;+}diff --git a/src/ui/sidepanel/GuideEditor.tsx b/src/ui/sidepanel/GuideEditor.tsxindex 0bde229..7c197f6 100644--- a/src/ui/sidepanel/GuideEditor.tsx+++ b/src/ui/sidepanel/GuideEditor.tsx@@ -9,6 +9,7 @@ import { getMostCommonDomain } from '@/lib/utils';import { Input } from '@/ui/components/ui/input';import EmptyGuideState from '@/ui/shared/EmptyGuideState';import FaviconImg from '@/ui/shared/FaviconImg';+import { siblingRatio } from '@/ui/shared/ImagePlaceholder';import ExportMenu from './ExportMenu';import StepCard from './StepCard';@@ -183,6 +184,7 @@ export default function GuideEditor({ guideId, onBack, onGuideMe }: GuideEditorP<StepCardstep={step}screenshot={data.screenshots.get(step.id)}+ placeholderRatio={siblingRatio(data.screenshots)}onDescriptionChange={handleDescriptionChange}onDelete={handleDeleteStep}onOpenEditor={(stepId, tool) => openInFullView(guideId, stepId, tool)}diff --git a/src/ui/sidepanel/StepCard.tsx b/src/ui/sidepanel/StepCard.tsxindex f889e16..78a04ea 100644--- a/src/ui/sidepanel/StepCard.tsx+++ b/src/ui/sidepanel/StepCard.tsx@@ -22,6 +22,7 @@ interface StepCardProps {dragHandleProps?: DragHandleProps;onOpenEditor?: (stepId: string, tool: 'annotate' | 'redact' | 'crop' | 'target') => void;onCopy?: (stepId: string) => void;+ placeholderRatio?: number;}export default function StepCard({@@ -31,6 +32,7 @@ export default function StepCard({onDelete,dragHandleProps,onOpenEditor,+ placeholderRatio,}: StepCardProps) {const [description, setDescription] = useState(step.description);const [dragOver, setDragOver] = useState(false);@@ -103,7 +105,8 @@ export default function StepCard({) : (<ImagePlaceholderlabel={i18n.t('editor.noScreenshot')}- className="w-full h-32 !rounded-none border-x-0 border-t-0"+ ratio={placeholderRatio}+ className="w-full !rounded-none border-x-0 border-t-0"/>)}