Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions components/NumaTimer.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { useCallback } from "react"
import { useCallback, useRef } from "react"

import {
DOMAIN_LABEL,
formatDuration,
type DomainKey,
type NumaTimerUiState
} from "~lib/config"
import { pickReminderMessage } from "~lib/messages"
import { useTimer } from "~hooks/useTimer"
import type { DeepPartial } from "~lib/deepMerge"

Expand Down Expand Up @@ -40,6 +41,7 @@ const DOMAIN_THEME: Record<
}
}


export const NumaTimer = ({
domain,
uiState,
Expand All @@ -54,6 +56,7 @@ export const NumaTimer = ({
const { displaySeconds } = useTimer(domain)
const theme = DOMAIN_THEME[domain]
const isCollapsed = uiState.collapsed[domain]
const reminderMessageRef = useRef(pickReminderMessage())

const handleToggleCollapsed = useCallback(() => {
void setUiState((prev) => ({
Expand Down Expand Up @@ -160,7 +163,7 @@ export const NumaTimer = ({
fontSize: "14px",
color: theme.subText
}}>
この時間はもう戻りません
{reminderMessageRef.current}
</div>
</>
)}
Expand Down
10 changes: 10 additions & 0 deletions lib/messages.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const REMINDER_MESSAGES = [
"この時間はもう戻りません",
"今日の時間は有限です",
"いまの使い方で未来が決まる",
"今この瞬間も、過去に変わっています",
"一度きりの今日を大切に",
] as const

export const pickReminderMessage = () =>
REMINDER_MESSAGES[Math.floor(Math.random() * REMINDER_MESSAGES.length)]
Loading