@@ -14,11 +14,11 @@ interface Props {
1414export default function ImageEmbed ( props : Props ) {
1515 const { content, depth } = props ;
1616 const imageCount = content . images . length ;
17- const [ showImage , setShowImage ] = useState < number | undefined > ( undefined ) ;
17+ const [ currentImage , setCurrentImage ] = useState < number > ( ) ;
1818
1919 const generateImageLayout = (
2020 count : number ,
21- images : AppBskyEmbedImages . ViewImage [ ] ,
21+ images : AppBskyEmbedImages . ViewImage [ ]
2222 ) => {
2323 // adjust image grid layout based on number of images
2424 switch ( count ) {
@@ -36,7 +36,7 @@ export default function ImageEmbed(props: Props) {
3636 className = "rounded-md h-full max-h-62 object-cover cursor-pointer hover:brightness-90 border border-skin-base"
3737 onClick = { ( e ) => {
3838 e . stopPropagation ( ) ;
39- setShowImage ( i ) ;
39+ setCurrentImage ( i ) ;
4040 } }
4141 />
4242 { image . alt && < AltTag text = { image . alt } /> }
@@ -60,7 +60,7 @@ export default function ImageEmbed(props: Props) {
6060 className = "rounded-md object-cover h-full cursor-pointer hover:brightness-90 border border-skin-base"
6161 onClick = { ( e ) => {
6262 e . stopPropagation ( ) ;
63- setShowImage ( 0 ) ;
63+ setCurrentImage ( 0 ) ;
6464 } }
6565 />
6666 { images [ 2 ] . alt && < AltTag text = { images [ 2 ] . alt } /> }
@@ -78,7 +78,7 @@ export default function ImageEmbed(props: Props) {
7878 className = "rounded-md object-cover w-full h-full cursor-pointer hover:brightness-90 border border-skin-base"
7979 onClick = { ( e ) => {
8080 e . stopPropagation ( ) ;
81- setShowImage ( 1 ) ;
81+ setCurrentImage ( 1 ) ;
8282 } }
8383 />
8484 { images [ 1 ] . alt && < AltTag text = { images [ 1 ] . alt } /> }
@@ -94,7 +94,7 @@ export default function ImageEmbed(props: Props) {
9494 className = "rounded-md object-cover w-full h-full cursor-pointer hover:brightness-90 border border-skin-base"
9595 onClick = { ( e ) => {
9696 e . stopPropagation ( ) ;
97- setShowImage ( 2 ) ;
97+ setCurrentImage ( 2 ) ;
9898 } }
9999 />
100100 { images [ 2 ] . alt && < AltTag text = { images [ 2 ] . alt } /> }
@@ -117,7 +117,7 @@ export default function ImageEmbed(props: Props) {
117117 className = "object-cover aspect-square rounded-md h-full max-h-64 cursor-pointer hover:brightness-90 border border-skin-base"
118118 onClick = { ( e ) => {
119119 e . stopPropagation ( ) ;
120- setShowImage ( i ) ;
120+ setCurrentImage ( i ) ;
121121 } }
122122 />
123123 { images [ i ] . alt && < AltTag text = { images [ i ] . alt } /> }
@@ -140,7 +140,7 @@ export default function ImageEmbed(props: Props) {
140140 className = "rounded-md max-h-96 w-full object-cover cursor-pointer hover:brightness-90 border border-skin-base"
141141 onClick = { ( e ) => {
142142 e . stopPropagation ( ) ;
143- setShowImage ( 0 ) ;
143+ setCurrentImage ( 0 ) ;
144144 } }
145145 />
146146 { images [ 0 ] . alt && < AltTag text = { images [ 0 ] . alt } /> }
@@ -153,11 +153,15 @@ export default function ImageEmbed(props: Props) {
153153
154154 return (
155155 < >
156- { showImage !== undefined && (
156+ { currentImage !== undefined && (
157157 < 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 ) }
161165 />
162166 ) }
163167 { depth < 2 && (
0 commit comments