From 7a84167ed98f7b9d20dc66bec2fa700969e798a3 Mon Sep 17 00:00:00 2001 From: Shusui MOYATANI Date: Fri, 17 Mar 2023 20:12:53 +0900 Subject: [PATCH] feat: config for dateFormat --- src/components/Config.tsx | 61 ++++++++++++++++++++- src/components/textNote/TextNoteDisplay.tsx | 4 +- src/nostr/useConfig.ts | 2 +- 3 files changed, 61 insertions(+), 6 deletions(-) diff --git a/src/components/Config.tsx b/src/components/Config.tsx index e254f4f..d098ff2 100644 --- a/src/components/Config.tsx +++ b/src/components/Config.tsx @@ -1,4 +1,4 @@ -import useConfig from '@/nostr/useConfig'; +import useConfig, { type Config } from '@/nostr/useConfig'; import { createSignal, For, type JSX } from 'solid-js'; type ConfigProps = { @@ -48,7 +48,61 @@ const RelayConfig = () => { ); }; -const Config = (props: ConfigProps) => { +const dateFormats: { id: Config['dateFormat']; name: string; example: string }[] = [ + { + id: 'relative', + name: '相対', + example: '〜秒前', + }, + { + id: 'absolute-short', + name: '絶対 (短形式)', + example: '昨日 12:34', + }, + { + id: 'absolute-long', + name: '絶対 (長形式)', + example: '2023', + }, +]; + +const DateFormatConfig = () => { + const { config, setConfig } = useConfig(); + + const updateDateFormat = (dateFormat: Config['dateFormat']) => { + setConfig((current) => ({ ...current, dateFormat })); + }; + + return ( +
+

時刻の表記

+
+ + {({ id, name, example }) => ( +
+ + {example} +
+ )} +
+
+
+ ); +}; + +const ConfigUI = (props: ConfigProps) => { let containerRef: HTMLDivElement | undefined; const handleClickContainer: JSX.EventHandler = (ev) => { @@ -72,9 +126,10 @@ const Config = (props: ConfigProps) => { + ); }; -export default Config; +export default ConfigUI; diff --git a/src/components/textNote/TextNoteDisplay.tsx b/src/components/textNote/TextNoteDisplay.tsx index d489406..54df82e 100644 --- a/src/components/textNote/TextNoteDisplay.tsx +++ b/src/components/textNote/TextNoteDisplay.tsx @@ -173,7 +173,7 @@ const TextNoteDisplay: Component = (props) => { {(id) => ( -
+
)} @@ -233,7 +233,7 @@ const TextNoteDisplay: Component = (props) => {
{reactions().length}
-
+