mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-16 21:50:35 +02:00
add grid item card size presets
This commit is contained in:
@@ -135,6 +135,7 @@ export interface ItemCardDerivativeProps extends Omit<ItemCardProps, 'type'> {
|
||||
const CompactItemCard = ({
|
||||
controls,
|
||||
data,
|
||||
enableDrag,
|
||||
enableExpansion,
|
||||
enableNavigation,
|
||||
internalState,
|
||||
@@ -150,6 +151,53 @@ const CompactItemCard = ({
|
||||
: undefined;
|
||||
const isSelected = useItemSelectionState(internalState, itemRowId || undefined);
|
||||
|
||||
const { isDragging: isDraggingLocal, ref } = useDragDrop<HTMLDivElement>({
|
||||
drag: {
|
||||
getId: () => {
|
||||
if (!data) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const draggedItems = getDraggedItems(data, internalState);
|
||||
return draggedItems.map((item) => item.id);
|
||||
},
|
||||
getItem: () => {
|
||||
if (!data) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const draggedItems = getDraggedItems(data, internalState);
|
||||
return draggedItems;
|
||||
},
|
||||
itemType,
|
||||
onDragStart: () => {
|
||||
if (!data) {
|
||||
return;
|
||||
}
|
||||
|
||||
const draggedItems = getDraggedItems(data, internalState);
|
||||
if (internalState) {
|
||||
internalState.setDragging(draggedItems);
|
||||
}
|
||||
},
|
||||
onDrop: () => {
|
||||
if (internalState) {
|
||||
internalState.setDragging([]);
|
||||
}
|
||||
},
|
||||
operation:
|
||||
itemType === LibraryItem.QUEUE_SONG
|
||||
? [DragOperation.REORDER, DragOperation.ADD]
|
||||
: [DragOperation.ADD],
|
||||
target: DragTarget.ALBUM,
|
||||
},
|
||||
isEnabled: !!enableDrag && !!data,
|
||||
});
|
||||
|
||||
const itemId = data && internalState ? data.id : undefined;
|
||||
const isDraggingState = useItemDraggingState(internalState, itemId);
|
||||
const isDragging = isDraggingState || isDraggingLocal;
|
||||
|
||||
const handleClick = useDoubleClick({
|
||||
onDoubleClick: (e: React.MouseEvent<HTMLDivElement>) => {
|
||||
if (!data || !controls || !internalState) {
|
||||
@@ -289,8 +337,10 @@ const CompactItemCard = ({
|
||||
return (
|
||||
<div
|
||||
className={clsx(styles.container, styles.compact, {
|
||||
[styles.dragging]: isDragging,
|
||||
[styles.selected]: isSelected,
|
||||
})}
|
||||
ref={ref}
|
||||
>
|
||||
{enableNavigation && navigationPath && !internalState ? (
|
||||
<Link
|
||||
|
||||
Reference in New Issue
Block a user