37 lines
859 B
TypeScript
Raw Normal View History

2024-04-06 19:03:04 -04:00
import { type ClassValue, clsx } from "clsx"
2024-04-30 01:56:43 -04:00
// import { toast } from "sonner"
2024-04-06 19:03:04 -04:00
import { twMerge } from "tailwind-merge"
export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs))
}
2024-04-27 00:28:00 -04:00
export function processFileType(file: string) {
const ending = file.split(".").pop()
if (ending === "ts" || ending === "tsx") return "typescript"
if (ending === "js" || ending === "jsx") return "javascript"
if (ending) return ending
return "plaintext"
}
2024-04-28 20:06:47 -04:00
2024-04-29 00:50:25 -04:00
export function validateName(
newName: string,
oldName: string,
type: "file" | "folder"
) {
if (
2024-04-30 01:56:43 -04:00
newName === oldName ||
newName.length === 0 ||
2024-04-29 00:50:25 -04:00
newName.includes("/") ||
newName.includes("\\") ||
newName.includes(" ") ||
(type === "file" && !newName.includes(".")) ||
(type === "folder" && newName.includes("."))
) {
return false
}
return true
}