- add Timestamp component with moment relative time and ISO tooltip - add Timestamp stories (JustNow, MinutesAgo, HoursAgo, DaysAgo, MonthsAgo) - add ESLint 10 with typescript-eslint, react-hooks, react-refresh, prettier - add Prettier config with singleQuote, semi, trailingComma all, printWidth 100 - add lint, lint:fix, format, test:storybook scripts to package.json - fix react-hooks/set-state-in-effect in all page components - auto-fix 113 Prettier formatting issues across src and .storybook
19 lines
407 B
TypeScript
19 lines
407 B
TypeScript
import moment from 'moment';
|
|
import styles from './Timestamp.module.css';
|
|
|
|
export interface TimestampProps {
|
|
value: string | number | Date;
|
|
}
|
|
|
|
export function Timestamp({ value }: TimestampProps) {
|
|
const m = moment(value);
|
|
const iso = m.toISOString();
|
|
const relative = m.fromNow();
|
|
|
|
return (
|
|
<span className={styles.timestamp} title={iso} aria-label={iso}>
|
|
{relative}
|
|
</span>
|
|
);
|
|
}
|