From 54846eecd48e189dc6272743ae9908925a82ba41 Mon Sep 17 00:00:00 2001 From: myl7 Date: Mon, 7 Feb 2022 17:01:33 +0800 Subject: [PATCH 1/3] prevent ctrl+k default avoid opening browser search box in chrome when pressing ctrl+k --- components/Navbar.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/components/Navbar.tsx b/components/Navbar.tsx index a2d6236..1651a30 100644 --- a/components/Navbar.tsx +++ b/components/Navbar.tsx @@ -21,7 +21,10 @@ const Navbar = () => { const [isOpen, setIsOpen] = useState(false) const [searchOpen, setSearchOpen] = useState(false) - const openSearchBox = () => setSearchOpen(true) + const openSearchBox = (e: KeyboardEvent) => { + setSearchOpen(true) + e.preventDefault() + } useHotkeys(`${os === 'mac' ? 'cmd' : 'ctrl'}+k`, openSearchBox) From 343eb15dd265947507d8e3d6eb962734a28b0b02 Mon Sep 17 00:00:00 2001 From: myl7 Date: Mon, 7 Feb 2022 17:15:37 +0800 Subject: [PATCH 2/3] fix type error by modifying useHotKeys hook directly --- components/Navbar.tsx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/components/Navbar.tsx b/components/Navbar.tsx index 1651a30..49fde9c 100644 --- a/components/Navbar.tsx +++ b/components/Navbar.tsx @@ -21,12 +21,12 @@ const Navbar = () => { const [isOpen, setIsOpen] = useState(false) const [searchOpen, setSearchOpen] = useState(false) - const openSearchBox = (e: KeyboardEvent) => { - setSearchOpen(true) - e.preventDefault() - } + const openSearchBox = () => setSearchOpen(true) - useHotkeys(`${os === 'mac' ? 'cmd' : 'ctrl'}+k`, openSearchBox) + useHotkeys(`${os === 'mac' ? 'cmd' : 'ctrl'}+k`, e => { + openSearchBox() + e.preventDefault() + }) useEffect(() => { const storedToken = () => { From 223e7e3d6aa277ba0816df32f5e7d5d3a7dd917a Mon Sep 17 00:00:00 2001 From: myl7 Date: Tue, 8 Feb 2022 20:06:02 +0800 Subject: [PATCH 3/3] allow to customize datetime format via dayjs --- components/previews/AudioPreview.tsx | 7 ++----- config/site.config.js | 5 +++++ package.json | 1 + pnpm-lock.yaml | 6 ++++++ utils/fileDetails.ts | 13 +++++-------- 5 files changed, 19 insertions(+), 13 deletions(-) diff --git a/components/previews/AudioPreview.tsx b/components/previews/AudioPreview.tsx index e2eea60..5a10308 100644 --- a/components/previews/AudioPreview.tsx +++ b/components/previews/AudioPreview.tsx @@ -7,6 +7,7 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' import DownloadButtonGroup from '../DownloadBtnGtoup' import { DownloadBtnContainer, PreviewContainer } from './Containers' import { LoadingIcon } from '../Loading' +import { formatModifiedDateTime } from '../../utils/fileDetails' enum PlayerState { Loading, @@ -36,11 +37,7 @@ const AudioPreview: FC<{ file: OdFileObject }> = ({ file }) => {
{file.name}
- Last modified:{' '} - {new Date(file.lastModifiedDateTime).toLocaleString(undefined, { - dateStyle: 'short', - timeStyle: 'short', - })} + Last modified: {formatModifiedDateTime(file.lastModifiedDateTime)}
{ * @returns Human readable form of the file or folder last modified date */ export const formatModifiedDateTime = (lastModifedDateTime: string) => { - return new Date(lastModifedDateTime).toLocaleString('en-US', { - year: 'numeric', - month: '2-digit', - day: '2-digit', - hour: '2-digit', - minute: '2-digit', - hour12: false, - }) + return dayjs(lastModifedDateTime).format(siteConfig.datetimeFormat) }