This commit is contained in:
Shusui MOYATANI
2023-03-17 09:38:28 +09:00
parent 158d0e3a20
commit c34143065b
23 changed files with 421 additions and 246 deletions

11
src/hooks/useFileInput.ts Normal file
View File

@@ -0,0 +1,11 @@
import { createSignal, type JSX } from 'solid-js';
const useFileInput = () => {
const [file, setFile] = createSignal<File | undefined>();
const handleChange: JSX.EventHandler<HTMLInputElement, Event> = (ev) => {
setFile(ev.currentTarget.files?.[0]);
};
return { file, handleChange };
};

View File

@@ -1,20 +1,24 @@
import { createMemo } from 'solid-js';
import useConfig from '@/nostr/useConfig';
import useDatePulser from '@/hooks/useDatePulser';
import { formatRelative, formatAbsolute } from '@/utils/formatDate';
import { formatRelative, formatAbsoluteLong, formatAbsoluteShort } from '@/utils/formatDate';
const useFormatDate = () => {
const { config } = useConfig();
const currentDate = useDatePulser();
return (date: Date) => {
if (config().dateFormat === 'absolute') {
return formatAbsolute(date);
switch (config().dateFormat) {
case 'absolute-long':
return formatAbsoluteLong(date, currentDate());
case 'absolute-short':
return formatAbsoluteShort(date, currentDate());
case 'relative':
return formatRelative(date, currentDate());
default:
return formatRelative(date, currentDate());
}
return formatRelative(date, currentDate());
};
};