diff --git a/src/app/view/components/Body/components/Table/Table.module.css b/src/app/view/components/Body/components/Table/Note/Note.module.css similarity index 100% rename from src/app/view/components/Body/components/Table/Table.module.css rename to src/app/view/components/Body/components/Table/Note/Note.module.css diff --git a/src/app/view/components/Body/components/Table/Note/Note.tsx b/src/app/view/components/Body/components/Table/Note/Note.tsx new file mode 100644 index 0000000..02cea67 --- /dev/null +++ b/src/app/view/components/Body/components/Table/Note/Note.tsx @@ -0,0 +1,43 @@ +import clsx from "clsx"; +import { AiOutlineCalendar, AiOutlineUser } from "react-icons/ai"; + +import style from "./Note.module.css"; +import formatDate from "@/lib/utils/formatDate"; +import timeInterval from "@/lib/utils/timeInterval"; + +import { NoteDatabseType } from "@/types/notes"; +import MarkdownRenderer from "@/components/MarkdownRenderer/MarkdownRenderer"; + +interface NoteProps { + note: NoteDatabseType; + intervalFomatDate: boolean; + setIntervalFomatDate: React.Dispatch>; +} + +export default function Note({ note, intervalFomatDate, setIntervalFomatDate }: NoteProps) { + const toggleIntervalFomatDate = () => setIntervalFomatDate((prev) => !prev); + + return ( +
  • +
    +

    + + {note.name} +

    + + + + {note.useMarkdown && ( + Md + )} +
    + + {note.useMarkdown && } + {!note.useMarkdown &&

    {note.content}

    } +
  • + ); +} diff --git a/src/app/view/components/Body/components/Table/Table.tsx b/src/app/view/components/Body/components/Table/Table.tsx index 11e954c..35485ce 100644 --- a/src/app/view/components/Body/components/Table/Table.tsx +++ b/src/app/view/components/Body/components/Table/Table.tsx @@ -1,27 +1,18 @@ "use client"; -import clsx from "clsx"; import { useMemo } from "react"; -import { AiOutlineCalendar, AiOutlineUser } from "react-icons/ai"; -import style from "./Table.module.css"; import groupBy from "@/lib/utils/groupBy"; -import formatDate from "@/lib/utils/formatDate"; -import timeInterval from "@/lib/utils/timeInterval"; import usePersistantState from "@/hooks/usePersistantState"; - import { NoteDatabseType } from "@/types/notes"; -import MarkdownRenderer from "@/components/MarkdownRenderer/MarkdownRenderer"; + +import Note from "./Note/Note"; export default function Table({ notes }: { notes: NoteDatabseType[] }) { const [intervalFomatDate, setIntervalFomatDate] = usePersistantState("view-interval-format-date", true); const notesGroupedByWeek = useMemo(() => groupBy(notes, (note) => `#第${note.week}周`), [notes]); - function toggleIntervalFomatDate() { - setIntervalFomatDate((prev) => !prev); - } - return (