Skip to content

Commit

Permalink
feat: use date-picker instead of raw datetime input
Browse files Browse the repository at this point in the history
  • Loading branch information
johnnyjoygh committed Oct 19, 2024
1 parent 199d568 commit cf1be81
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 17 deletions.
1 change: 1 addition & 0 deletions web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"lucide-react": "^0.437.0",
"mermaid": "^11.2.1",
"react": "^18.3.1",
"react-datepicker": "^7.5.0",
"react-dom": "^18.3.1",
"react-force-graph-2d": "^1.25.6",
"react-hot-toast": "^2.4.1",
Expand Down
42 changes: 42 additions & 0 deletions web/pnpm-lock.yaml

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

18 changes: 8 additions & 10 deletions web/src/components/MemoEditor/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { Select, Option, Button, Divider } from "@mui/joy";
import { isEqual } from "lodash-es";
import { SendIcon } from "lucide-react";
import React, { useEffect, useMemo, useRef, useState } from "react";
import DatePicker from "react-datepicker";
import "react-datepicker/dist/react-datepicker.css";
import { toast } from "react-hot-toast";
import { useTranslation } from "react-i18next";
import useLocalStorage from "react-use/lib/useLocalStorage";
Expand Down Expand Up @@ -428,16 +430,12 @@ const MemoEditor = (props: Props) => {
onCompositionEnd={handleCompositionEnd}
>
{memoName && displayTime && (
<div className="relative text-sm">
<span className="cursor-pointer text-gray-400 dark:text-gray-500">{displayTime.toLocaleString()}</span>
<input
className="inset-0 absolute z-1 opacity-0"
type="datetime-local"
value={displayTime.toLocaleString()}
onFocus={(e: any) => e.target.showPicker()}
onChange={(e) => setDisplayTime(new Date(e.target.value))}
/>
</div>
<DatePicker
selected={displayTime}
onChange={(date) => date && setDisplayTime(date)}
showTimeSelect
customInput={<span className="cursor-pointer text-sm text-gray-400 dark:text-gray-500">{displayTime.toLocaleString()}</span>}
/>
)}
<Editor ref={editorRef} {...editorConfig} />
<ResourceListView resourceList={state.resourceList} setResourceList={handleSetResourceList} />
Expand Down
7 changes: 0 additions & 7 deletions web/src/components/UserStatisticsView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,6 @@ const UserStatisticsView = () => {
<div className="relative text-base font-medium leading-6 flex flex-row items-center dark:text-gray-400">
<CalendarDaysIcon className="w-5 h-auto mr-1 opacity-60" strokeWidth={1.5} />
<span>{dayjs(visibleMonthString).toDate().toLocaleString(i18n.language, { year: "numeric", month: "long" })}</span>
<input
className="inset-0 absolute z-1 opacity-0"
type="month"
value={visibleMonthString}
onFocus={(e: any) => e.target.showPicker()}
onChange={(e) => setVisibleMonthString(e.target.value || dayjs().format("YYYY-MM"))}
/>
</div>
<div className="invisible group-hover:visible flex justify-end items-center">
<Popover>
Expand Down

0 comments on commit cf1be81

Please sign in to comment.