react-icons/ri#RiFileEditFill JavaScript Examples
The following examples show how to use
react-icons/ri#RiFileEditFill.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: NotesPreview.js From fokus with GNU General Public License v3.0 | 4 votes |
export default function NotesPreview({ note, setNoteInPreview }) {
const dispatch = useDispatch();
const [editNote, setEditNote] = useState();
const [noteContent, setNoteContent] = useState();
const [noteColor, setNoteColor] = useState();
useEffect(() => {
if (note !== null) {
setNoteContent(note.content);
setNoteColor(note.color);
setEditNote(true);
}
}, [note]);
const handleContentChange = (updatedNoteContent) => {
setNoteContent(updatedNoteContent);
debouncedUpdateNoteContent(dispatch, note.id, updatedNoteContent);
};
const handleColorUpdate = (note, noteColor) => {
let updatePayload = {
id: note.id,
noteColor,
};
dispatch(update(updatePayload));
setNoteColor(noteColor);
};
const handleDeleteNoteAction = (id) => {
dispatch(remove(id));
setNoteInPreview(null);
};
const handleCloseAction = () => {
dispatch(remove(null)); // clears all empty body notes
setNoteInPreview(null);
};
return (
<AnimatePresence>
<NotesPreviewContainer
initial={{
flex: note === null ? "0 1 0" : "2 1 0",
}}
animate={{
flex: note === null ? "0 1 0" : "2 1 0",
}}
>
{note !== null && (
<>
<NoteActionMenu>
<MenuActionButtonGroup>
<MenuActionButton onClick={() => handleCloseAction()}>
<FaArrowRight data-for="closeAction" data-tip="" />
<ReactTooltip id="closeAction" getContent={() => "Close Note"} />
</MenuActionButton>
<MenuActionButton data-for="viewOrEditAction" data-tip="" onClick={() => setEditNote(!editNote)}>
{editNote ? <AiFillEye /> : <RiFileEditFill />}
<ReactTooltip id="viewOrEditAction" getContent={() => (editNote ? "View Markdown" : "Edit Note")} />
</MenuActionButton>
<MenuActionButton onClick={() => navigator.clipboard.writeText(noteContent)}>
<FaClipboard data-for="copyAction" data-tip="" />
<ReactTooltip id="copyAction" getContent={() => "Copy Note"} />
</MenuActionButton>
<MenuActionButton onClick={() => handleDeleteNoteAction(note.id)}>
<FaTrash data-for="deleteAction" data-tip="" />
<ReactTooltip id="deleteAction" getContent={() => "Delete Note"} />
</MenuActionButton>
</MenuActionButtonGroup>
<NoteColorSelectionBox>
{Object.keys(colorOptions).map((color, idx) => (
<ColorOption
key={idx}
onClick={() => handleColorUpdate(note, colorOptions[color])}
isSelected={noteColor === colorOptions[color]}
color={colorOptions[color]}
/>
))}
</NoteColorSelectionBox>
</NoteActionMenu>
<NoteContentDiv>
{editNote ? (
<EditNoteInput
placeholder="Type note here.."
autoFocus
type="text"
value={noteContent}
onChange={(e) => handleContentChange(e.target.value)}
/>
) : (
<MarkdownWrapper>
<ReactMarkdown children={noteContent} />
</MarkdownWrapper>
)}
</NoteContentDiv>
</>
)}
</NotesPreviewContainer>
</AnimatePresence>
);
}