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 πŸ“–

refactor(ui): use the dominant ratio for placeholders and drop siblingRatio

Luis Ortiz8a77e9bbc15e
diff --git a/src/ui/fullview/components/GuideStepList.tsx b/src/ui/fullview/components/GuideStepList.tsx
index ce3ff03..eb40f8c 100644
--- a/src/ui/fullview/components/GuideStepList.tsx
+++ b/src/ui/fullview/components/GuideStepList.tsx
@@ -3,7 +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 { dominantRatio, siblingRatio } from '@/ui/shared/ImagePlaceholder';
+import { dominantRatio } from '@/ui/shared/ImagePlaceholder';
import StepCard from '@/ui/sidepanel/StepCard';
interface GuideStepListProps {
@@ -37,7 +37,6 @@ 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);
const frameRatio = dominantRatio(screenshots);
useEffect(() => {
@@ -98,7 +97,7 @@ export default function GuideStepList({
<StepCard
step={step}
screenshot={screenshots.get(step.id)}
- placeholderRatio={placeholderRatio}
+ placeholderRatio={frameRatio}
frameRatio={frameRatio}
onDescriptionChange={onDescriptionChange}
onDelete={onDelete}
diff --git a/src/ui/shared/ImagePlaceholder.tsx b/src/ui/shared/ImagePlaceholder.tsx
index 698de46..a7d3df6 100644
--- a/src/ui/shared/ImagePlaceholder.tsx
+++ b/src/ui/shared/ImagePlaceholder.tsx
@@ -22,14 +22,6 @@ export default function ImagePlaceholder({ label, ratio = DEFAULT_RATIO, classNa
);
}
-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;
-}
-
const RATIO_BUCKET_PRECISION = 100;
export function dominantRatio(screenshots: Map<string, Screenshot>): number | undefined {
diff --git a/src/ui/sidepanel/GuideEditor.tsx b/src/ui/sidepanel/GuideEditor.tsx
index c06c310..d640176 100644
--- a/src/ui/sidepanel/GuideEditor.tsx
+++ b/src/ui/sidepanel/GuideEditor.tsx
@@ -18,7 +18,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 { dominantRatio, siblingRatio } from '@/ui/shared/ImagePlaceholder';
+import { dominantRatio } from '@/ui/shared/ImagePlaceholder';
import ExportMenu from './ExportMenu';
import StepCard from './StepCard';
@@ -231,7 +231,7 @@ export default function GuideEditor({ guideId, onBack, onGuideMe }: GuideEditorP
<StepCard
step={step}
screenshot={data.screenshots.get(step.id)}
- placeholderRatio={siblingRatio(data.screenshots)}
+ placeholderRatio={dominantRatio(data.screenshots)}
frameRatio={dominantRatio(data.screenshots)}
onDescriptionChange={handleDescriptionChange}
onDelete={handleDeleteStep}