//
// Copyright 2026 DXOS.org
//
import '../../theme/index.css';
import { type Meta, type StoryObj } from '@storybook/react-vite';
import React, { Fragment, useState } from 'react';
import { expect, waitFor, within } from 'storybook/test';
import { expectTooltip, realHover } from '../../testing/geometry.ts';
import { withLayout, withTheme } from '../../testing/index.ts';
import * as Typography from '../Typography/Typography.tsx';
import { Timestamp } from './Timestamp.tsx';
const NOW = new Date('2026-06-15T12:00:00Z');
const minutesBefore = (minutes: number, now = NOW): Date => new Date(now.getTime() - minutes * 60_000);
/** One row per age, so the ladder (counter, then hours, then a date) reads at once. */
const LADDER: Array<{ label: string; minutes: number }> = [
{ label: 'just now', minutes: 0 },
{ label: 'a minute', minutes: 1 },
{ label: 'under an hour', minutes: 42 },
{ label: 'past the hour, still minutes', minutes: 90 },
{ label: 'hours', minutes: 5 * 60 },
{ label: 'most of a day', minutes: 23 * 60 },
{ label: 'yesterday', minutes: 26 * 60 },
{ label: 'last month', minutes: 40 * 24 * 60 },
];
type StoryArgs = { live?: boolean };
const DefaultStory = ({ live }: StoryArgs) => {
// Held in state so the instants keep their identity across renders.
const [now] = useState(() => (live ? new Date() : NOW));
return (
{LADDER.map(({ label, minutes }) => (
{label}
))}
);
};
const meta = {
title: 'ui/react-ui-core/components/Timestamp',
render: DefaultStory,
decorators: [withLayout({ classNames: 'p-4 w-[24rem]' }), withTheme()],
args: { live: true },
parameters: { layout: 'centered' },
} satisfies Meta;
export default meta;
type Story = StoryObj;
export const Default: Story = {};
/** The ladder against a fixed clock, a machine-readable `