Add zoom controls to admin debugging

This commit is contained in:
Sam Becker 2025-01-26 13:05:41 -06:00
parent ad83dbb2e3
commit c9c470d43c
4 changed files with 25 additions and 7 deletions

View File

@ -92,6 +92,7 @@ export default function CommandKClient({
selectedPhotoIds, selectedPhotoIds,
setSelectedPhotoIds, setSelectedPhotoIds,
isGridHighDensity, isGridHighDensity,
areZoomControlsEnabled,
arePhotosMatted, arePhotosMatted,
shouldShowBaselineGrid, shouldShowBaselineGrid,
shouldDebugImageFallbacks, shouldDebugImageFallbacks,
@ -99,6 +100,7 @@ export default function CommandKClient({
setShouldRespondToKeyboardCommands, setShouldRespondToKeyboardCommands,
setShouldShowBaselineGrid, setShouldShowBaselineGrid,
setIsGridHighDensity, setIsGridHighDensity,
setAreZoomControlsEnabled,
setArePhotosMatted, setArePhotosMatted,
setShouldDebugImageFallbacks, setShouldDebugImageFallbacks,
} = useAppState(); } = useAppState();
@ -250,6 +252,10 @@ export default function CommandKClient({
heading: 'Debug Tools', heading: 'Debug Tools',
accessory: <RiToolsFill size={16} className="translate-x-[-1px]" />, accessory: <RiToolsFill size={16} className="translate-x-[-1px]" />,
items: [{ items: [{
label: 'Toggle Zoom Controls',
action: () => setAreZoomControlsEnabled?.(prev => !prev),
annotation: areZoomControlsEnabled ? <FaCheck size={12} /> : undefined,
}, {
label: 'Toggle Photo Matting', label: 'Toggle Photo Matting',
action: () => setArePhotosMatted?.(prev => !prev), action: () => setArePhotosMatted?.(prev => !prev),
annotation: arePhotosMatted ? <FaCheck size={12} /> : undefined, annotation: arePhotosMatted ? <FaCheck size={12} /> : undefined,

View File

@ -55,7 +55,6 @@ export default function PhotoLarge({
shouldShareCamera, shouldShareCamera,
shouldShareSimulation, shouldShareSimulation,
shouldShareFocalLength, shouldShareFocalLength,
shouldShowZoomControls,
includeFavoriteInAdminMenu, includeFavoriteInAdminMenu,
onVisible, onVisible,
}: { }: {
@ -76,13 +75,18 @@ export default function PhotoLarge({
shouldShareSimulation?: boolean shouldShareSimulation?: boolean
shouldShareFocalLength?: boolean shouldShareFocalLength?: boolean
shouldScrollOnShare?: boolean shouldScrollOnShare?: boolean
shouldShowZoomControls?: boolean
includeFavoriteInAdminMenu?: boolean includeFavoriteInAdminMenu?: boolean
onVisible?: () => void onVisible?: () => void
}) { }) {
const ref = useRef<HTMLDivElement>(null); const ref = useRef<HTMLDivElement>(null);
const refZoomControls = useRef<HTMLDivElement>(null); const refZoomControls = useRef<HTMLDivElement>(null);
const {
areZoomControlsEnabled,
arePhotosMatted,
isUserSignedIn,
} = useAppState();
const tags = sortTags(photo.tags, primaryTag); const tags = sortTags(photo.tags, primaryTag);
const camera = cameraFromPhoto(photo); const camera = cameraFromPhoto(photo);
@ -93,9 +97,7 @@ export default function PhotoLarge({
useOnVisible(ref, onVisible); useOnVisible(ref, onVisible);
useImageZoomControls(refZoomControls, shouldShowZoomControls); useImageZoomControls(refZoomControls, areZoomControlsEnabled);
const { arePhotosMatted, isUserSignedIn } = useAppState();
const hasTitle = const hasTitle =
showTitle && showTitle &&
@ -151,7 +153,7 @@ export default function PhotoLarge({
)}> )}>
<div <div
ref={refZoomControls} ref={refZoomControls}
className={clsx(shouldShowZoomControls && 'cursor-zoom-in')} className={clsx(areZoomControlsEnabled && 'cursor-zoom-in')}
> >
<ImageLarge <ImageLarge
className={clsx(arePhotosMatted && 'h-full')} className={clsx(arePhotosMatted && 'h-full')}

View File

@ -33,6 +33,8 @@ export interface AppStateContext {
// DEBUG // DEBUG
isGridHighDensity?: boolean isGridHighDensity?: boolean
setIsGridHighDensity?: Dispatch<SetStateAction<boolean>> setIsGridHighDensity?: Dispatch<SetStateAction<boolean>>
areZoomControlsEnabled?: boolean
setAreZoomControlsEnabled?: Dispatch<SetStateAction<boolean>>
arePhotosMatted?: boolean arePhotosMatted?: boolean
setArePhotosMatted?: Dispatch<SetStateAction<boolean>> setArePhotosMatted?: Dispatch<SetStateAction<boolean>>
shouldDebugImageFallbacks?: boolean shouldDebugImageFallbacks?: boolean

View File

@ -6,7 +6,11 @@ import { AnimationConfig } from '@/components/AnimateItems';
import usePathnames from '@/utility/usePathnames'; import usePathnames from '@/utility/usePathnames';
import { getAuthAction } from '@/auth/actions'; import { getAuthAction } from '@/auth/actions';
import useSWR from 'swr'; import useSWR from 'swr';
import { HIGH_DENSITY_GRID, MATTE_PHOTOS } from '@/site/config'; import {
HIGH_DENSITY_GRID,
MATTE_PHOTOS,
ZOOM_CONTROLS_ENABLED,
} from '@/site/config';
import { getPhotosHiddenMetaCachedAction } from '@/photo/actions'; import { getPhotosHiddenMetaCachedAction } from '@/photo/actions';
import { ShareModalProps } from '@/share'; import { ShareModalProps } from '@/share';
import { storeTimezoneCookie } from '@/utility/timezone'; import { storeTimezoneCookie } from '@/utility/timezone';
@ -46,6 +50,8 @@ export default function AppStateProvider({
// DEBUG // DEBUG
const [isGridHighDensity, setIsGridHighDensity] = const [isGridHighDensity, setIsGridHighDensity] =
useState(HIGH_DENSITY_GRID); useState(HIGH_DENSITY_GRID);
const [areZoomControlsEnabled, setAreZoomControlsEnabled] =
useState(ZOOM_CONTROLS_ENABLED);
const [arePhotosMatted, setArePhotosMatted] = const [arePhotosMatted, setArePhotosMatted] =
useState(MATTE_PHOTOS); useState(MATTE_PHOTOS);
const [shouldDebugImageFallbacks, setShouldDebugImageFallbacks] = const [shouldDebugImageFallbacks, setShouldDebugImageFallbacks] =
@ -116,6 +122,8 @@ export default function AppStateProvider({
// DEBUG // DEBUG
isGridHighDensity, isGridHighDensity,
setIsGridHighDensity, setIsGridHighDensity,
areZoomControlsEnabled,
setAreZoomControlsEnabled,
arePhotosMatted, arePhotosMatted,
setArePhotosMatted, setArePhotosMatted,
shouldDebugImageFallbacks, shouldDebugImageFallbacks,