feat: pointer cursor for boards and deals

This commit is contained in:
2025-08-05 16:52:26 +04:00
parent 236c0dcf10
commit c13cc4a0a5
4 changed files with 13 additions and 5 deletions

View File

@ -4,7 +4,6 @@ import DealCard from "@/app/deals/components/DealCard/DealCard";
import { DealSchema } from "@/client"; import { DealSchema } from "@/client";
import { SortableItem } from "@/components/SortableDnd/SortableItem"; import { SortableItem } from "@/components/SortableDnd/SortableItem";
type Props = { type Props = {
deal: DealSchema; deal: DealSchema;
}; };
@ -14,7 +13,11 @@ const DealContainer: FC<Props> = ({ deal }) => {
return ( return (
<Box> <Box>
<SortableItem id={deal.id}>{dealBody}</SortableItem> <SortableItem
dragHandleStyle={{ cursor: "pointer" }}
id={deal.id}>
{dealBody}
</SortableItem>
</Box> </Box>
); );
}; };

View File

@ -1,11 +1,12 @@
import React, { ReactNode, useContext } from "react"; import React, { CSSProperties, ReactNode, useContext } from "react";
import SortableItemContext from "@/components/SortableDnd/SortableItemContext"; import SortableItemContext from "@/components/SortableDnd/SortableItemContext";
type Props = { type Props = {
children: ReactNode; children: ReactNode;
style?: CSSProperties;
}; };
const DragHandle = ({ children }: Props) => { const DragHandle = ({ children, style }: Props) => {
const { attributes, listeners, ref } = useContext(SortableItemContext); const { attributes, listeners, ref } = useContext(SortableItemContext);
return ( return (
@ -15,6 +16,7 @@ const DragHandle = ({ children }: Props) => {
style={{ style={{
width: "100%", width: "100%",
cursor: "grab", cursor: "grab",
...style,
}} }}
ref={ref}> ref={ref}>
{children} {children}

View File

@ -109,6 +109,7 @@ const SortableDnd = <T extends BaseItem>({
onItemClick(item); onItemClick(item);
}}> }}>
<SortableItem <SortableItem
dragHandleStyle={{ cursor: "pointer" }}
itemStyle={itemStyle} itemStyle={itemStyle}
id={item.id}> id={item.id}>
{renderItem(item)} {renderItem(item)}

View File

@ -7,12 +7,14 @@ import SortableItemContext from "./SortableItemContext";
type Props = { type Props = {
id: number | string; id: number | string;
itemStyle?: CSSProperties; itemStyle?: CSSProperties;
dragHandleStyle?: CSSProperties;
}; };
export const SortableItem = ({ export const SortableItem = ({
children, children,
itemStyle, itemStyle,
id, id,
dragHandleStyle,
}: PropsWithChildren<Props>) => { }: PropsWithChildren<Props>) => {
const { const {
attributes, attributes,
@ -45,7 +47,7 @@ export const SortableItem = ({
<div <div
ref={setNodeRef} ref={setNodeRef}
style={style}> style={style}>
<DragHandle>{children}</DragHandle> <DragHandle style={dragHandleStyle}>{children}</DragHandle>
</div> </div>
</SortableItemContext.Provider> </SortableItemContext.Provider>
); );