feat(67): show resolved bug geometry on the watermarks screen
Replace the raw <img> preview in the Watermarks editor's Image row with the shared BugPreview component, so the on-screen bug's location/size/ margins/opacity render the same way as the other three preview spots. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -95,4 +95,15 @@ describe('WatermarksScreen', () => {
|
||||
await waitFor(() => expect(screen.getByDisplayValue('Logo (copy)')).toBeInTheDocument());
|
||||
expect(screen.getByText('New watermark')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('renders a geometry preview of the watermark image in the editor', async () => {
|
||||
window.history.pushState({}, '', '/app/watermarks/3');
|
||||
mockApi();
|
||||
render(<WatermarksScreen />);
|
||||
|
||||
const preview = await screen.findByAltText('On-screen bug preview');
|
||||
expect(preview).toHaveAttribute('src', '/artwork/watermarks/logo.png');
|
||||
// BottomRight at 5% margins, 15% width, 100% opacity (see watermarkDetail fixture)
|
||||
expect(preview).toHaveStyle({ bottom: '5%', right: '5%', width: '15%' });
|
||||
});
|
||||
});
|
||||
|
||||
@@ -2,7 +2,7 @@ import { useCallback, useEffect, useRef, useState, type ReactNode } from 'react'
|
||||
import { ArrowLeft, Check, Copy, Image as ImageIcon, Plus, Trash2, TriangleAlert, Upload } from 'lucide-react';
|
||||
import { navigateToPath } from '../routing';
|
||||
import { usePrimaryAction } from '../primaryAction';
|
||||
import { Badge, Button, Card, Checkbox, ConfirmDialog, IconButton, Input, Select, Spinner } from '../components';
|
||||
import { Badge, BugPreview, Button, Card, Checkbox, ConfirmDialog, IconButton, Input, Select, Spinner } from '../components';
|
||||
import {
|
||||
createWatermark,
|
||||
deleteWatermark,
|
||||
@@ -532,10 +532,14 @@ function WatermarkEditor({ mode }: { mode: { id: number; kind: 'edit' } | { from
|
||||
Upload image
|
||||
</Button>
|
||||
{custom && draft.image && (
|
||||
<img
|
||||
alt="Watermark preview"
|
||||
<BugPreview
|
||||
horizontalMargin={draft.horizontalMargin}
|
||||
location={draft.location}
|
||||
opacity={draft.opacity}
|
||||
size={draft.size}
|
||||
src={watermarkImageUrl(draft.image)}
|
||||
style={{ maxHeight: 60, maxWidth: 200, objectFit: 'contain' }}
|
||||
verticalMargin={draft.verticalMargin}
|
||||
width={draft.width}
|
||||
/>
|
||||
)}
|
||||
{uploadError && (
|
||||
|
||||
Reference in New Issue
Block a user