mirror of
https://github.com/umami-software/umami.git
synced 2026-02-06 05:37:20 +01:00
Updated events/sessions pages. Added DateDistance component.
This commit is contained in:
parent
8b64029409
commit
5b300f1ff5
13 changed files with 44 additions and 35 deletions
17
src/components/common/DateDistance.tsx
Normal file
17
src/components/common/DateDistance.tsx
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
import { Tooltip, TooltipTrigger, Text, Focusable } from '@umami/react-zen';
|
||||
import { formatDistanceToNow } from 'date-fns';
|
||||
import { useLocale, useTimezone } from '@/components/hooks';
|
||||
|
||||
export function DateDistance({ date }: { date: Date }) {
|
||||
const { formatTimezoneDate } = useTimezone();
|
||||
const { dateLocale } = useLocale();
|
||||
|
||||
return (
|
||||
<TooltipTrigger delay={0}>
|
||||
<Focusable>
|
||||
<Text>{formatDistanceToNow(date, { addSuffix: true, locale: dateLocale })}</Text>
|
||||
</Focusable>
|
||||
<Tooltip>{formatTimezoneDate(date.toISOString(), 'PPPpp')}</Tooltip>
|
||||
</TooltipTrigger>
|
||||
);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue