Fase 2 stap B (frontend): uitsnede per slide in het scherm, herstelpunt in het plan
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -18,9 +18,11 @@ interface FocusDialogProps {
|
||||
/** Keeps the change locally: it is sent and made live when the hero is saved, and dropped when the page is left. */
|
||||
onApply: (imageId: string, request: HeroFocusRequest) => void;
|
||||
onClose: () => void;
|
||||
/** The slide has a crop of its own: offers "use the crop of the photo again". */
|
||||
onReset?: () => void;
|
||||
}
|
||||
|
||||
export function FocusDialog({ image, onApply, onClose }: FocusDialogProps) {
|
||||
export function FocusDialog({ image, onApply, onClose, onReset }: FocusDialogProps) {
|
||||
const { t } = useTranslation();
|
||||
return (
|
||||
<Dialog open={image !== null} onOpenChange={(next) => { if (!next) onClose(); }}>
|
||||
@@ -29,7 +31,7 @@ export function FocusDialog({ image, onApply, onClose }: FocusDialogProps) {
|
||||
<DialogTitle>{t('hero.focus.title')}</DialogTitle>
|
||||
</DialogHeader>
|
||||
{/* Mounted only while open, so every opening starts from the stored values. */}
|
||||
{image && <FocusEditor image={image} onApply={onApply} onClose={onClose} />}
|
||||
{image && <FocusEditor image={image} onApply={onApply} onClose={onClose} onReset={onReset} />}
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
@@ -37,7 +39,7 @@ export function FocusDialog({ image, onApply, onClose }: FocusDialogProps) {
|
||||
|
||||
const percent = (fraction: number) => Math.round(fraction * 1000) / 10;
|
||||
|
||||
function FocusEditor({ image, onApply, onClose }: { image: HeroImageDto; onApply: (imageId: string, request: HeroFocusRequest) => void; onClose: () => void }) {
|
||||
function FocusEditor({ image, onApply, onClose, onReset }: { image: HeroImageDto; onApply: (imageId: string, request: HeroFocusRequest) => void; onClose: () => void; onReset?: () => void }) {
|
||||
const { t } = useTranslation();
|
||||
const area = useRef<HTMLDivElement>(null);
|
||||
// The whole picture: image.src is already a crop of the wide shape and would be shown stretched and out of place.
|
||||
@@ -235,7 +237,21 @@ function FocusEditor({ image, onApply, onClose }: { image: HeroImageDto; onApply
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="flex justify-end gap-2">
|
||||
<div className="flex flex-wrap justify-end gap-2">
|
||||
{onReset && (
|
||||
<Button
|
||||
type="button"
|
||||
variant="ghost"
|
||||
className="mr-auto"
|
||||
onClick={() => {
|
||||
onReset();
|
||||
onClose();
|
||||
}}
|
||||
data-testid="focus-reset"
|
||||
>
|
||||
{t('hero.focus.reset')}
|
||||
</Button>
|
||||
)}
|
||||
<Button type="button" variant="outline" onClick={onClose} data-testid="focus-cancel">
|
||||
{t('common.cancel')}
|
||||
</Button>
|
||||
|
||||
Reference in New Issue
Block a user