Files
outline/app/components/Time.tsx
dependabot[bot] f9fb57abf4 chore(deps-dev): bump eslint-plugin-react from 7.21.5 to 7.33.2 (#6226)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Tom Moor <tom.moor@gmail.com>
2023-12-11 16:55:37 -08:00

32 lines
817 B
TypeScript

import * as React from "react";
import { dateToRelative } from "@shared/utils/date";
import type { Props as LocaleTimeProps } from "~/components/LocaleTime";
import lazyWithRetry from "~/utils/lazyWithRetry";
const LocaleTime = lazyWithRetry(() => import("~/components/LocaleTime"));
type Props = LocaleTimeProps & {
onClick?: () => void;
};
function Time({ onClick, ...props }: Props) {
const content = dateToRelative(Date.parse(props.dateTime), {
addSuffix: props.addSuffix,
shorten: props.shorten,
});
return (
<span onClick={onClick}>
<React.Suspense
fallback={
<time dateTime={props.dateTime}>{props.children || content}</time>
}
>
<LocaleTime tooltipDelay={250} {...props} />
</React.Suspense>
</span>
);
}
export default Time;