@@ -14,11 +14,11 @@ interface Props {
14
14
export default function ImageEmbed ( props : Props ) {
15
15
const { content, depth } = props ;
16
16
const imageCount = content . images . length ;
17
- const [ showImage , setShowImage ] = useState < number | undefined > ( undefined ) ;
17
+ const [ currentImage , setCurrentImage ] = useState < number > ( ) ;
18
18
19
19
const generateImageLayout = (
20
20
count : number ,
21
- images : AppBskyEmbedImages . ViewImage [ ] ,
21
+ images : AppBskyEmbedImages . ViewImage [ ]
22
22
) => {
23
23
// adjust image grid layout based on number of images
24
24
switch ( count ) {
@@ -36,7 +36,7 @@ export default function ImageEmbed(props: Props) {
36
36
className = "rounded-md h-full max-h-62 object-cover cursor-pointer hover:brightness-90 border border-skin-base"
37
37
onClick = { ( e ) => {
38
38
e . stopPropagation ( ) ;
39
- setShowImage ( i ) ;
39
+ setCurrentImage ( i ) ;
40
40
} }
41
41
/>
42
42
{ image . alt && < AltTag text = { image . alt } /> }
@@ -60,7 +60,7 @@ export default function ImageEmbed(props: Props) {
60
60
className = "rounded-md object-cover h-full cursor-pointer hover:brightness-90 border border-skin-base"
61
61
onClick = { ( e ) => {
62
62
e . stopPropagation ( ) ;
63
- setShowImage ( 0 ) ;
63
+ setCurrentImage ( 0 ) ;
64
64
} }
65
65
/>
66
66
{ images [ 2 ] . alt && < AltTag text = { images [ 2 ] . alt } /> }
@@ -78,7 +78,7 @@ export default function ImageEmbed(props: Props) {
78
78
className = "rounded-md object-cover w-full h-full cursor-pointer hover:brightness-90 border border-skin-base"
79
79
onClick = { ( e ) => {
80
80
e . stopPropagation ( ) ;
81
- setShowImage ( 1 ) ;
81
+ setCurrentImage ( 1 ) ;
82
82
} }
83
83
/>
84
84
{ images [ 1 ] . alt && < AltTag text = { images [ 1 ] . alt } /> }
@@ -94,7 +94,7 @@ export default function ImageEmbed(props: Props) {
94
94
className = "rounded-md object-cover w-full h-full cursor-pointer hover:brightness-90 border border-skin-base"
95
95
onClick = { ( e ) => {
96
96
e . stopPropagation ( ) ;
97
- setShowImage ( 2 ) ;
97
+ setCurrentImage ( 2 ) ;
98
98
} }
99
99
/>
100
100
{ images [ 2 ] . alt && < AltTag text = { images [ 2 ] . alt } /> }
@@ -117,7 +117,7 @@ export default function ImageEmbed(props: Props) {
117
117
className = "object-cover aspect-square rounded-md h-full max-h-64 cursor-pointer hover:brightness-90 border border-skin-base"
118
118
onClick = { ( e ) => {
119
119
e . stopPropagation ( ) ;
120
- setShowImage ( i ) ;
120
+ setCurrentImage ( i ) ;
121
121
} }
122
122
/>
123
123
{ images [ i ] . alt && < AltTag text = { images [ i ] . alt } /> }
@@ -140,7 +140,7 @@ export default function ImageEmbed(props: Props) {
140
140
className = "rounded-md max-h-96 w-full object-cover cursor-pointer hover:brightness-90 border border-skin-base"
141
141
onClick = { ( e ) => {
142
142
e . stopPropagation ( ) ;
143
- setShowImage ( 0 ) ;
143
+ setCurrentImage ( 0 ) ;
144
144
} }
145
145
/>
146
146
{ images [ 0 ] . alt && < AltTag text = { images [ 0 ] . alt } /> }
@@ -153,11 +153,15 @@ export default function ImageEmbed(props: Props) {
153
153
154
154
return (
155
155
< >
156
- { showImage !== undefined && (
156
+ { currentImage !== undefined && (
157
157
< Gallery
158
- images = { content . images }
159
- startingIndex = { showImage }
160
- onClose = { ( ) => setShowImage ( undefined ) }
158
+ images = { content . images . map ( ( img ) => ( {
159
+ src : img . fullsize ,
160
+ alt : img . alt ,
161
+ aspectRatio : img . aspectRatio ,
162
+ } ) ) }
163
+ startingIndex = { currentImage }
164
+ onClose = { ( ) => setCurrentImage ( undefined ) }
161
165
/>
162
166
) }
163
167
{ depth < 2 && (
0 commit comments