mirror of
https://github.com/outline/outline.git
synced 2026-11-22 05:51:43 +03:00
* chore: Remove unused lint disable directives Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WJegM4QsoYSKrBKb6eB4CH * chore: Replace TODO type suppressions with typed code Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WJegM4QsoYSKrBKb6eB4CH * chore: Remove obsolete workaround comments in tests and MediaDimension Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WJegM4QsoYSKrBKb6eB4CH * chore: Remove Tippy compatibility props from Tooltip Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WJegM4QsoYSKrBKb6eB4CH * chore: Decouple DropdownMenu props from Tooltip and clarify sharing styles Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WJegM4QsoYSKrBKb6eB4CH * chore: Remove stale retention TODOs from cleanup tasks Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WJegM4QsoYSKrBKb6eB4CH * chore: Register relations synchronously and clarify workaround comments Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WJegM4QsoYSKrBKb6eB4CH * chore: Replace Notion import TODOs with descriptive comments Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WJegM4QsoYSKrBKb6eB4CH --------- Co-authored-by: Claude <noreply@anthropic.com>
61 lines
1.4 KiB
TypeScript
61 lines
1.4 KiB
TypeScript
import * as React from "react";
|
|
import type { locales } from "@shared/utils/date";
|
|
import Tooltip from "~/components/Tooltip";
|
|
import { useLocaleTime } from "~/hooks/useLocaleTime";
|
|
|
|
export type Props = {
|
|
children?: React.ReactNode;
|
|
dateTime: string;
|
|
addSuffix?: boolean;
|
|
shorten?: boolean;
|
|
relative?: boolean;
|
|
format?: Partial<Record<keyof typeof locales, string>>;
|
|
/** Additional content shown below the date in the tooltip. */
|
|
tooltipDetail?: React.ReactNode;
|
|
};
|
|
|
|
const LocaleTime: React.FC<Props> = ({
|
|
children,
|
|
tooltipDetail,
|
|
...rest
|
|
}: Props) => {
|
|
const { tooltipContent, content } = useLocaleTime(rest);
|
|
const [isInteractive, setIsInteractive] = React.useState(false);
|
|
// Detail is only available in the tooltip, so it must be reachable by keyboard.
|
|
const hasDetail = !!tooltipDetail;
|
|
|
|
const time = (
|
|
<time
|
|
dateTime={rest.dateTime}
|
|
tabIndex={hasDetail ? 0 : undefined}
|
|
onPointerEnter={() => setIsInteractive(true)}
|
|
onFocus={() => setIsInteractive(true)}
|
|
>
|
|
{children || content}
|
|
</time>
|
|
);
|
|
|
|
return isInteractive || hasDetail ? (
|
|
<Tooltip
|
|
content={
|
|
hasDetail ? (
|
|
<>
|
|
{tooltipContent}
|
|
<br />
|
|
{tooltipDetail}
|
|
</>
|
|
) : (
|
|
tooltipContent
|
|
)
|
|
}
|
|
side="bottom"
|
|
>
|
|
{time}
|
|
</Tooltip>
|
|
) : (
|
|
time
|
|
);
|
|
};
|
|
|
|
export default LocaleTime;
|