style: format frontend with prettier
Mechanical one-shot pass of pnpm format over src/, tests/, tools/, and root configs. No functional changes; build and type-check verified.
This commit is contained in:
@@ -1,66 +1,67 @@
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
import { useGalleryStore } from "../store";
|
||||
import { BulkAlbumPopover } from "./bulk/BulkAlbumPopover";
|
||||
import { BulkDeleteConfirm } from "./bulk/BulkDeleteConfirm";
|
||||
import { BulkRatingPopover } from "./bulk/BulkRatingPopover";
|
||||
import { BulkSelectionSummary } from "./bulk/BulkSelectionSummary";
|
||||
import { BulkTagPopover } from "./bulk/BulkTagPopover";
|
||||
import { type BulkPanel } from "./bulk/types";
|
||||
import { useDismissable } from "./menu";
|
||||
import { Tooltip } from "./Tooltip";
|
||||
import { CloseIcon } from "./icons";
|
||||
import { useEffect, useRef, useState } from 'react'
|
||||
import { useGalleryStore } from '../store'
|
||||
import { BulkAlbumPopover } from './bulk/BulkAlbumPopover'
|
||||
import { BulkDeleteConfirm } from './bulk/BulkDeleteConfirm'
|
||||
import { BulkRatingPopover } from './bulk/BulkRatingPopover'
|
||||
import { BulkSelectionSummary } from './bulk/BulkSelectionSummary'
|
||||
import { BulkTagPopover } from './bulk/BulkTagPopover'
|
||||
import { type BulkPanel } from './bulk/types'
|
||||
import { useDismissable } from './menu'
|
||||
import { Tooltip } from './Tooltip'
|
||||
import { CloseIcon } from './icons'
|
||||
|
||||
export function BulkActionBar() {
|
||||
const selectedCount = useGalleryStore((state) => state.gallerySelectedIds.size);
|
||||
const selectedIds = useGalleryStore((state) => state.gallerySelectedIds);
|
||||
const clearGallerySelection = useGalleryStore((state) => state.clearGallerySelection);
|
||||
const selectAllGallery = useGalleryStore((state) => state.selectAllGallery);
|
||||
const loadedCount = useGalleryStore((state) => state.loadedCount);
|
||||
const totalImages = useGalleryStore((state) => state.totalImages);
|
||||
const bulkSetFavorite = useGalleryStore((state) => state.bulkSetFavorite);
|
||||
const bulkSetRating = useGalleryStore((state) => state.bulkSetRating);
|
||||
const bulkDeleteSelected = useGalleryStore((state) => state.bulkDeleteSelected);
|
||||
const activeView = useGalleryStore((state) => state.activeView);
|
||||
const selectedAlbumId = useGalleryStore((state) => state.selectedAlbumId);
|
||||
const addToAlbum = useGalleryStore((state) => state.addToAlbum);
|
||||
const removeFromAlbum = useGalleryStore((state) => state.removeFromAlbum);
|
||||
const selectedCount = useGalleryStore((state) => state.gallerySelectedIds.size)
|
||||
const selectedIds = useGalleryStore((state) => state.gallerySelectedIds)
|
||||
const clearGallerySelection = useGalleryStore((state) => state.clearGallerySelection)
|
||||
const selectAllGallery = useGalleryStore((state) => state.selectAllGallery)
|
||||
const loadedCount = useGalleryStore((state) => state.loadedCount)
|
||||
const totalImages = useGalleryStore((state) => state.totalImages)
|
||||
const bulkSetFavorite = useGalleryStore((state) => state.bulkSetFavorite)
|
||||
const bulkSetRating = useGalleryStore((state) => state.bulkSetRating)
|
||||
const bulkDeleteSelected = useGalleryStore((state) => state.bulkDeleteSelected)
|
||||
const activeView = useGalleryStore((state) => state.activeView)
|
||||
const selectedAlbumId = useGalleryStore((state) => state.selectedAlbumId)
|
||||
const addToAlbum = useGalleryStore((state) => state.addToAlbum)
|
||||
const removeFromAlbum = useGalleryStore((state) => state.removeFromAlbum)
|
||||
|
||||
const [panel, setPanel] = useState<BulkPanel>(null);
|
||||
const [deleting, setDeleting] = useState(false);
|
||||
const barRef = useRef<HTMLDivElement>(null);
|
||||
const [panel, setPanel] = useState<BulkPanel>(null)
|
||||
const [deleting, setDeleting] = useState(false)
|
||||
const barRef = useRef<HTMLDivElement>(null)
|
||||
|
||||
// Close any open popover when clicking outside the bar or pressing Escape.
|
||||
useDismissable(barRef, () => setPanel(null), panel !== null);
|
||||
useDismissable(barRef, () => setPanel(null), panel !== null)
|
||||
|
||||
// Reset transient UI whenever the selection empties.
|
||||
useEffect(() => {
|
||||
if (selectedCount === 0) setPanel(null);
|
||||
}, [selectedCount]);
|
||||
if (selectedCount === 0) setPanel(null)
|
||||
}, [selectedCount])
|
||||
|
||||
if (selectedCount === 0) return null;
|
||||
if (selectedCount === 0) return null
|
||||
|
||||
const ids = Array.from(selectedIds);
|
||||
const inAlbumView = activeView === "album" && selectedAlbumId !== null;
|
||||
const togglePanel = (next: Exclude<BulkPanel, null>) => setPanel((current) => (current === next ? null : next));
|
||||
const ids = Array.from(selectedIds)
|
||||
const inAlbumView = activeView === 'album' && selectedAlbumId !== null
|
||||
const togglePanel = (next: Exclude<BulkPanel, null>) =>
|
||||
setPanel((current) => (current === next ? null : next))
|
||||
|
||||
const handleDelete = async () => {
|
||||
setDeleting(true);
|
||||
setDeleting(true)
|
||||
try {
|
||||
await bulkDeleteSelected();
|
||||
await bulkDeleteSelected()
|
||||
} finally {
|
||||
setDeleting(false);
|
||||
setPanel(null);
|
||||
setDeleting(false)
|
||||
setPanel(null)
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
const handlePickAlbum = async (albumId: number) => {
|
||||
await addToAlbum(albumId, ids);
|
||||
setPanel(null);
|
||||
};
|
||||
await addToAlbum(albumId, ids)
|
||||
setPanel(null)
|
||||
}
|
||||
|
||||
const btn = "rounded-md px-2.5 py-1.5 text-xs font-medium transition-colors";
|
||||
const btnIdle = `${btn} text-gray-300 hover:bg-white/10 hover:text-white`;
|
||||
const btnActive = `${btn} bg-white/10 text-white`;
|
||||
const btn = 'rounded-md px-2.5 py-1.5 text-xs font-medium transition-colors'
|
||||
const btnIdle = `${btn} text-gray-300 hover:bg-white/10 hover:text-white`
|
||||
const btnActive = `${btn} bg-white/10 text-white`
|
||||
|
||||
return (
|
||||
<div
|
||||
@@ -78,17 +79,25 @@ export function BulkActionBar() {
|
||||
<div className="h-5 w-px bg-white/10" />
|
||||
|
||||
<div className="relative">
|
||||
<button className={panel === "tag" ? btnActive : btnIdle} onClick={() => togglePanel("tag")}>
|
||||
<button
|
||||
className={panel === 'tag' ? btnActive : btnIdle}
|
||||
onClick={() => togglePanel('tag')}
|
||||
>
|
||||
Tag
|
||||
</button>
|
||||
{panel === "tag" ? <BulkTagPopover onClose={() => setPanel(null)} /> : null}
|
||||
{panel === 'tag' ? <BulkTagPopover onClose={() => setPanel(null)} /> : null}
|
||||
</div>
|
||||
|
||||
<div className="relative">
|
||||
<button className={panel === "rating" ? btnActive : btnIdle} onClick={() => togglePanel("rating")}>
|
||||
<button
|
||||
className={panel === 'rating' ? btnActive : btnIdle}
|
||||
onClick={() => togglePanel('rating')}
|
||||
>
|
||||
Rating
|
||||
</button>
|
||||
{panel === "rating" ? <BulkRatingPopover onSetRating={bulkSetRating} onClose={() => setPanel(null)} /> : null}
|
||||
{panel === 'rating' ? (
|
||||
<BulkRatingPopover onSetRating={bulkSetRating} onClose={() => setPanel(null)} />
|
||||
) : null}
|
||||
</div>
|
||||
<Tooltip label="Mark as favorite" followCursor>
|
||||
<button className={btnIdle} onClick={() => void bulkSetFavorite(true)}>
|
||||
@@ -96,10 +105,13 @@ export function BulkActionBar() {
|
||||
</button>
|
||||
</Tooltip>
|
||||
<div className="relative">
|
||||
<button className={panel === "album" ? btnActive : btnIdle} onClick={() => togglePanel("album")}>
|
||||
<button
|
||||
className={panel === 'album' ? btnActive : btnIdle}
|
||||
onClick={() => togglePanel('album')}
|
||||
>
|
||||
Add to album
|
||||
</button>
|
||||
{panel === "album" ? <BulkAlbumPopover onPick={handlePickAlbum} /> : null}
|
||||
{panel === 'album' ? <BulkAlbumPopover onPick={handlePickAlbum} /> : null}
|
||||
</div>
|
||||
|
||||
{inAlbumView ? (
|
||||
@@ -117,17 +129,17 @@ export function BulkActionBar() {
|
||||
<Tooltip label="Delete files from disk" followCursor>
|
||||
<button
|
||||
className={
|
||||
panel === "delete"
|
||||
panel === 'delete'
|
||||
? `${btn} bg-red-500/15 text-red-300`
|
||||
: `${btn} text-gray-300 hover:bg-red-500/10 hover:text-red-300`
|
||||
}
|
||||
onClick={() => togglePanel("delete")}
|
||||
onClick={() => togglePanel('delete')}
|
||||
disabled={deleting}
|
||||
>
|
||||
{deleting ? "Deleting…" : "Delete"}
|
||||
{deleting ? 'Deleting…' : 'Delete'}
|
||||
</button>
|
||||
</Tooltip>
|
||||
{panel === "delete" ? (
|
||||
{panel === 'delete' ? (
|
||||
<BulkDeleteConfirm
|
||||
deleting={deleting}
|
||||
selectedCount={selectedCount}
|
||||
@@ -145,5 +157,5 @@ export function BulkActionBar() {
|
||||
</button>
|
||||
</Tooltip>
|
||||
</div>
|
||||
);
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user