1
1
import {
2
2
AnnotationGroupInfo ,
3
+ AnnotationShareControl ,
3
4
AnnotationTimestamps ,
4
5
AnnotationUser ,
5
6
MarkdownView ,
@@ -12,7 +13,7 @@ import {
12
13
Link ,
13
14
} from '@hypothesis/frontend-shared' ;
14
15
import classnames from 'classnames' ;
15
- import { useContext } from 'preact/hooks' ;
16
+ import { useContext , useMemo } from 'preact/hooks' ;
16
17
17
18
import { Config } from '../config' ;
18
19
import { quote , username } from '../utils/annotation-metadata' ;
@@ -29,6 +30,17 @@ export default function AnnotationCard({ annotation }: AnnotationCardProps) {
29
30
annotation . user_info ?. display_name ??
30
31
username ( annotation . user ) ??
31
32
annotation . user ;
33
+ const group = useMemo (
34
+ ( ) =>
35
+ config . context . group && {
36
+ type : config . context . group . type ,
37
+ name : config . context . group . name ,
38
+ links : {
39
+ html : config . context . group . link ,
40
+ } ,
41
+ } ,
42
+ [ config . context . group ] ,
43
+ ) ;
32
44
33
45
return (
34
46
< article >
@@ -48,17 +60,9 @@ export default function AnnotationCard({ annotation }: AnnotationCardProps) {
48
60
annotationUpdated = { annotation . updated }
49
61
/>
50
62
</ div >
51
- { config . context . group && (
63
+ { group && (
52
64
< div className = "flex gap-x-1 items-baseline flex-wrap-reverse" >
53
- < AnnotationGroupInfo
54
- group = { {
55
- type : config . context . group . type ,
56
- name : config . context . group . name ,
57
- links : {
58
- html : config . context . group . link ,
59
- } ,
60
- } }
61
- />
65
+ < AnnotationGroupInfo group = { group } />
62
66
< AnnotationDocument annotation = { annotation } />
63
67
</ div >
64
68
) }
@@ -98,7 +102,7 @@ export default function AnnotationCard({ annotation }: AnnotationCardProps) {
98
102
99
103
< footer className = "flex items-center justify-between" >
100
104
< div />
101
- < div className = "flex items-center gap-3 " >
105
+ < div className = "flex items-center gap-1 " >
102
106
< Link
103
107
variant = "text-light"
104
108
href = { annotation . links . incontext }
@@ -109,6 +113,7 @@ export default function AnnotationCard({ annotation }: AnnotationCardProps) {
109
113
>
110
114
< ExternalIcon />
111
115
</ Link >
116
+ < AnnotationShareControl annotation = { annotation } group = { group } />
112
117
</ div >
113
118
</ footer >
114
119
</ CardContent >
0 commit comments