2025-12-11 22:20:23 +00:00
|
|
|
import { SetStateAction } from "react";
|
|
|
|
|
// @ts-ignore
|
|
|
|
|
import FolderPlusIcon from "@assets/fontawesome/svg/folder-plus.svg?react";
|
|
|
|
|
// @ts-ignore
|
2025-12-18 18:12:23 +00:00
|
|
|
import TagsIcon from "@assets/fontawesome/svg/tags.svg?react";
|
|
|
|
|
// @ts-ignore
|
2025-12-11 22:20:23 +00:00
|
|
|
import FileCirclePlusIcon from "@assets/fontawesome/svg/file-circle-plus.svg?react";
|
|
|
|
|
import { useNoteStore } from "@/stores/notesStore";
|
2025-12-18 18:12:23 +00:00
|
|
|
import { useUIStore } from "@/stores/uiStore";
|
2025-12-11 22:20:23 +00:00
|
|
|
|
|
|
|
|
export const SidebarHeader = ({
|
|
|
|
|
setNewFolder,
|
|
|
|
|
}: {
|
|
|
|
|
setNewFolder: React.Dispatch<SetStateAction<boolean>>;
|
|
|
|
|
}) => {
|
|
|
|
|
const { createNote, selectedFolder } = useNoteStore();
|
2025-12-18 18:12:23 +00:00
|
|
|
const { setSideBarView, sideBarView } = useUIStore();
|
2025-12-11 22:20:23 +00:00
|
|
|
const handleCreate = async () => {
|
|
|
|
|
await createNote({
|
|
|
|
|
title: "Untitled",
|
|
|
|
|
content: "",
|
|
|
|
|
folder_id: selectedFolder,
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
return (
|
|
|
|
|
<div className="flex items-center justify-center w-full gap-2 bg-ctp-mantle border-b border-ctp-surface0 p-1">
|
|
|
|
|
<button
|
|
|
|
|
onClick={() => setNewFolder(true)}
|
2025-12-18 18:12:23 +00:00
|
|
|
className="hover:bg-ctp-mauve group transition-colors rounded-sm p-1 m-1"
|
2025-12-11 22:20:23 +00:00
|
|
|
title="New folder"
|
|
|
|
|
>
|
2025-12-18 18:12:23 +00:00
|
|
|
<FolderPlusIcon className="w-5 h-5 group-hover:fill-ctp-base transition-colors fill-ctp-mauve" />
|
|
|
|
|
</button>
|
|
|
|
|
<button
|
|
|
|
|
onClick={() =>
|
|
|
|
|
setSideBarView(sideBarView == "tags" ? "folders" : "tags")
|
|
|
|
|
}
|
|
|
|
|
className="hover:bg-ctp-mauve group transition-colors rounded-sm p-1 m-1"
|
|
|
|
|
title="Tags"
|
|
|
|
|
>
|
|
|
|
|
<TagsIcon className="w-5 h-5 group-hover:fill-ctp-base transition-colors fill-ctp-mauve" />
|
2025-12-11 22:20:23 +00:00
|
|
|
</button>
|
|
|
|
|
<button
|
|
|
|
|
onClick={handleCreate}
|
2025-12-18 18:12:23 +00:00
|
|
|
className="hover:bg-ctp-mauve group transition-colors rounded-sm p-1 m-1 fill-ctp-mauve hover:fill-ctp-base"
|
2025-12-11 22:20:23 +00:00
|
|
|
title="New note"
|
|
|
|
|
>
|
2025-12-18 18:12:23 +00:00
|
|
|
<FileCirclePlusIcon className="w-5 h-5 text-ctp-mauve group-hover:text-ctp-base transition-colors" />
|
2025-12-11 22:20:23 +00:00
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
};
|