diff --git a/src/components/note.jsx b/src/components/note.jsx index ea7c966..b63b8ee 100644 --- a/src/components/note.jsx +++ b/src/components/note.jsx @@ -1,23 +1,21 @@ -import React, { useContext, useState } from "react"; +import React, { useContext } from "react"; import { NoteContext } from "../pages/editor"; export default function Note(props) { const { setNotes } = useContext(NoteContext); - const [size, setSize] = useState({ w: 180, h: 88 }); + const w = 180; const r = 3; const fold = 24; const handleChange = (e) => { const textarea = document.getElementById(`note_${props.data.id}`); - const newHeight = textarea.scrollHeight + 16 + 20 + 4; - setSize((prevSize) => ({ ...prevSize, h: newHeight })); textarea.style.height = "0"; textarea.style.height = textarea.scrollHeight + "px"; - + const newHeight = textarea.scrollHeight + 16 + 20 + 4; setNotes((prev) => prev.map((n) => { if (n.id === props.data.id) { - return { ...n, content: e.target.value }; + return { ...n, content: e.target.value, height: newHeight }; } return n; }) @@ -28,17 +26,17 @@ export default function Note(props) {
@@ -69,7 +67,8 @@ export default function Note(props) { id={`note_${props.data.id}`} value={props.data.content} onInput={handleChange} - className="mt-1 w-full resize-none outline-none overflow-y-hidden border-none select-none bg-[#fcf7ac]" + className="mt-1 w-full resize-none outline-none overflow-y-hidden border-none select-none" + style={{backgroundColor: props.data.color}} >
diff --git a/src/components/notes_overview.jsx b/src/components/notes_overview.jsx index d3a816c..6cd3774 100644 --- a/src/components/notes_overview.jsx +++ b/src/components/notes_overview.jsx @@ -1,27 +1,83 @@ -import React, { useContext } from "react"; +import React, { useContext, useState } from "react"; import { Empty, Row, Col, Button, -// Input, -// Popover, -// Toast, + Collapse, + AutoComplete, + TextArea, + Popover, + Toast, } from "@douyinfe/semi-ui"; import { IllustrationNoContent, IllustrationNoContentDark, } from "@douyinfe/semi-illustrations"; -import { IconPlus } from "@douyinfe/semi-icons"; +import { + IconDeleteStroked, + IconPlus, + IconSearch, + IconCheckboxTick, +} from "@douyinfe/semi-icons"; import { NoteContext } from "../pages/editor"; +import { defaultNoteTheme, noteThemes } from "../data/data"; export default function NotesOverview(props) { const { notes, setNotes } = useContext(NoteContext); + const [value, setValue] = useState(""); + const [activeKey, setActiveKey] = useState(""); + const [filteredResult, setFilteredResult] = useState( + notes.map((t) => { + return t.title; + }) + ); + + const handleStringSearch = (value) => { + setFilteredResult( + notes + .map((t) => { + return t.title; + }) + .filter((i) => i.includes(value)) + ); + }; + + const updateNote = (id, values) => { + setNotes((prev) => + prev.map((note) => { + if (note.id === id) { + return { ...note, ...values }; + } + return note; + }) + ); + }; return (
- + + } + placeholder="Search..." + emptyContent={
No notes found
} + onSearch={(v) => handleStringSearch(v)} + onChange={(v) => setValue(v)} + onSelect={(v) => { + const { id } = notes.find((t) => t.title === v); + setActiveKey(`${id}`); + document + .getElementById(`scroll_note_${id}`) + .scrollIntoView({ behavior: "smooth" }); + }} + className="w-full" + /> + +