@@ -4,14 +4,29 @@ import {
44 formatRelativeDate ,
55 formatDateTime ,
66} from '@hypothesis/frontend-shared' ;
7+ import classnames from 'classnames' ;
78import { useEffect , useMemo , useState } from 'preact/hooks' ;
89
10+ /**
11+ * `subtle`: Small text with inherited font weight.
12+ * `prominent`: Bold text with inherited font size.
13+ */
14+ export type EditedTimestampVariant = 'subtle' | 'prominent' ;
15+
916export type AnnotationTimestampsProps = {
1017 annotationCreated : string ;
1118 annotationUpdated : string ;
1219 annotationURL ?: string ;
13- /** Display a relative last-updated timestamp */
14- withEditedTimestamp ?: boolean ;
20+
21+ /**
22+ * Whether a relative last-updated timestamp should be displayed or not.
23+ * - `false`: do not display edited timestamp
24+ * - `true`: display using default variant, `subtle`
25+ * - {variant_name}: display using specified variant
26+ *
27+ * Defaults to `false`.
28+ */
29+ withEditedTimestamp ?: boolean | EditedTimestampVariant ;
1530} ;
1631
1732/**
@@ -72,13 +87,19 @@ export default function AnnotationTimestamps({
7287 updated && updated . relative !== created . relative
7388 ? `edited ${ updated . relative } `
7489 : 'edited' ;
90+ const editedTimestampVariant : EditedTimestampVariant =
91+ typeof withEditedTimestamp === 'string' ? withEditedTimestamp : 'subtle' ;
7592
7693 return (
7794 < div >
7895 { withEditedTimestamp && (
7996 < span
80- className = "text-color-text-light text-xs italic"
97+ className = { classnames ( 'text-color-text-light italic' , {
98+ 'text-xs' : editedTimestampVariant === 'subtle' ,
99+ 'font-bold' : editedTimestampVariant === 'prominent' ,
100+ } ) }
81101 data-testid = "timestamp-edited"
102+ data-variant = { editedTimestampVariant }
82103 title = { updated . absolute }
83104 >
84105 ({ editedString } ){ ' ' }
0 commit comments