-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
155 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import {store} from "@/app/store" | ||
import theme from "@/themes" | ||
import {CType} from "@/types" | ||
import {MantineProvider, Stack, Text} from "@mantine/core" | ||
import {IconFile, IconFolder} from "@tabler/icons-react" | ||
|
||
interface Args { | ||
nodeID: string | ||
} | ||
|
||
export default function DraggingIcon({nodeID}: Args) { | ||
const state = store.getState() | ||
const draggedNodeIDs = state.ui.dragndrop?.nodeIDs | ||
const draggedNodes = Object.values(state.nodes.entities).filter( | ||
i => draggedNodeIDs?.includes(i.id) || i.id == nodeID | ||
) | ||
const count = dedup(draggedNodeIDs || []).length | ||
// unique list of used ctypes | ||
const usedCTypes: Array<CType> = dedup(draggedNodes.map(n => n.ctype)) | ||
const folderOnly = usedCTypes.includes("folder") && usedCTypes.length == 1 | ||
const icon: JSX.Element = folderOnly ? <IconFolder /> : <IconFile /> | ||
|
||
return ( | ||
<MantineProvider theme={theme}> | ||
<Stack> | ||
{icon} | ||
<Text>Move {count} items</Text> | ||
</Stack> | ||
</MantineProvider> | ||
) | ||
} | ||
|
||
function dedup<T>(arr: Array<T>): Array<T> { | ||
return [...new Set(arr)] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters