Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Notes App | draggable notes and categories #717

Merged
merged 12 commits into from
Jun 1, 2024
25 changes: 25 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"date-fns": "^2.30.0",
"dompurify": "^3.0.5",
"dotenv": "^16.0.3",
"framer-motion": "^11.0.14",
"fs-extra": "^11.1.1",
"highlight.js": "^11.8.0",
"html2canvas": "^1.4.1",
Expand Down
54 changes: 30 additions & 24 deletions src/components/Dashboard/Notetaker/Category/CategoryItem.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { deleteNotesCategory, updateNotesCategory } from "src/features/notes/not
import "src/components/Dashboard/Notetaker/NoteApp.css";
import ModifyCategory from "./ModifyCategory";
import { toast } from "react-toastify";
import { motion } from "framer-motion";

const CategoryItem = ({
category,
Expand Down Expand Up @@ -83,30 +84,35 @@ const CategoryItem = ({
pickedCategoryId={id}
/>
) : (
<CategoryItemElementContainer>
<CategoryItemElement onClick={() => onPick(category)} isPicked={isPicked}>
<CategoryItemShortTitle>{category.name.slice(0, 23)}</CategoryItemShortTitle>
</CategoryItemElement>
<CategoryOptionsMenuContainer>
<SlOptionsVertical
size="16"
className="icon icon-options"
onClick={() => handleOpenCategoryMenu(!isCategoryMenuOpen)}
/>
{isCategoryMenuOpen && (
<CategoryMenuButtons onMouseLeave={() => handleOpenCategoryMenu(false)}>
<CategoryMenuButton onClick={() => handleEditCategory(true)}>
<TbEditCircle className="icon icon-edit icon-not-hover-effect" size="18px" />
<CategoryMenuButtonLabel>Edit</CategoryMenuButtonLabel>
</CategoryMenuButton>
<CategoryMenuButton onClick={handleDeleteCategory}>
<AiTwotoneDelete className="icon icon-delete icon-not-hover-effect" size="18px" />
<CategoryMenuButtonLabel>Delete</CategoryMenuButtonLabel>
</CategoryMenuButton>
</CategoryMenuButtons>
)}
</CategoryOptionsMenuContainer>
</CategoryItemElementContainer>
<motion.div whileHover={{ scale: 0.9 }}>
<CategoryItemElementContainer>
<CategoryItemElement onClick={() => onPick(category)} isPicked={isPicked}>
<CategoryItemShortTitle>{category.name.slice(0, 23)}</CategoryItemShortTitle>
</CategoryItemElement>
<CategoryOptionsMenuContainer>
<SlOptionsVertical
size="16"
className="icon icon-options"
onClick={() => handleOpenCategoryMenu(!isCategoryMenuOpen)}
/>
{isCategoryMenuOpen && (
<CategoryMenuButtons onMouseLeave={() => handleOpenCategoryMenu(false)}>
<CategoryMenuButton onClick={() => handleEditCategory(true)}>
<TbEditCircle className="icon icon-edit icon-not-hover-effect" size="18px" />
<CategoryMenuButtonLabel>Edit</CategoryMenuButtonLabel>
</CategoryMenuButton>
<CategoryMenuButton onClick={handleDeleteCategory}>
<AiTwotoneDelete
className="icon icon-delete icon-not-hover-effect"
size="18px"
/>
<CategoryMenuButtonLabel>Delete</CategoryMenuButtonLabel>
</CategoryMenuButton>
</CategoryMenuButtons>
)}
</CategoryOptionsMenuContainer>
</CategoryItemElementContainer>
</motion.div>
)}
</>
);
Expand Down
31 changes: 23 additions & 8 deletions src/components/Dashboard/Notetaker/NoteItem.jsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,37 @@
import React from "react";
// import { useEffect } from "react";
// import { useDispatch, useSelector } from "react-redux";
import {
NoteItemElement,
NoteItemElementContainer,
NoteItemPinningContainer,
NoteItemShortTitle,
} from "./NoteElements";
import NotePinning from "./NotePinning";
import { motion } from "framer-motion";
// import { Reorder } from "framer-motion";
// import { getNotes, noteReset } from "src/features/notes/notesSlice";

const NoteItem = ({ _id, title, pinned, onPick, onPin, isPicked }) => {
// const dispatch = useDispatch();
// const { notes, isNoteError, noteMessage } = useSelector((state) => state.notes);
// useEffect(() => {
// dispatch(getNotes());
// return () => dispatch(noteReset());
// }, [dispatch, isNoteError, noteMessage]);
return (
<NoteItemElementContainer>
<NoteItemElement isPinned={pinned} onClick={() => onPick(_id)} isPicked={isPicked}>
<NoteItemShortTitle>{title.slice(0, 23)}</NoteItemShortTitle>
</NoteItemElement>
<NoteItemPinningContainer isPinned={pinned}>
<NotePinning isPinned={pinned} onPin={onPin} noteId={_id} />
</NoteItemPinningContainer>
</NoteItemElementContainer>
// <Reorder.Group axis="y" values={notes} onReorder={(newValues)=>dispatch(notesReorder(newValues))} >
<motion.div whileHover={{ scale: 0.9 }}>
<NoteItemElementContainer>
<NoteItemElement isPinned={pinned} onClick={() => onPick(_id)} isPicked={isPicked}>
<NoteItemShortTitle>{title.slice(0, 23)}</NoteItemShortTitle>
</NoteItemElement>
<NoteItemPinningContainer isPinned={pinned}>
<NotePinning isPinned={pinned} onPin={onPin} noteId={_id} />
</NoteItemPinningContainer>
</NoteItemElementContainer>
</motion.div>
// </Reorder.Group>
);
};
export default NoteItem;