File tree Expand file tree Collapse file tree 2 files changed +33
-28
lines changed Expand file tree Collapse file tree 2 files changed +33
-28
lines changed Original file line number Diff line number Diff line change 1
- import useBaseUrl from '@docusaurus/useBaseUrl'
2
- import React , { useState } from 'react'
1
+ import React from 'react'
3
2
4
3
export default function Image ( { alt, src} ) {
5
- const [ isActive , setIsActive ] = useState ( false )
6
-
7
4
return (
8
- < div style = { { marginBottom : '20px' , textAlign : 'center' } } >
5
+ < div className = 'ZoomableImage' >
9
6
< img
7
+ className = 'Thumbnail'
10
8
alt = { alt }
11
- className = 'ZoomableImage'
12
- onClick = { ( ) => setIsActive ( true ) }
13
- src = { useBaseUrl ( src ) }
9
+ src = { src }
10
+ tabIndex = { 0 }
14
11
/>
15
- { isActive && (
16
- < >
17
- < div
18
- className = 'ImageOverlayBackdrop'
19
- onClick = { ( ) => setIsActive ( false ) }
20
- />
21
- < img
22
- alt = { alt }
23
- className = 'ImageOverlay'
24
- onClick = { ( ) => setIsActive ( false ) }
25
- src = { useBaseUrl ( src ) }
26
- />
27
- </ >
28
- ) }
29
- < div
30
- style = { {
31
- fontStyle : 'italic' ,
32
- fontSize : '75%'
33
- } }
34
- > { alt } </ div >
12
+ < div className = 'ImageOverlayBackdrop' />
13
+ < img alt = { alt } className = 'ImageOverlay' src = { src } />
14
+ < div className = 'AltText' > { alt } </ div >
35
15
</ div >
36
16
)
37
17
}
Original file line number Diff line number Diff line change @@ -52,6 +52,11 @@ body {
52
52
}
53
53
54
54
.ZoomableImage {
55
+ margin-bottom : 20px ;
56
+ text-align : center;
57
+ }
58
+
59
+ .ZoomableImage > .Thumbnail {
55
60
box-shadow : 0 0 15px rgba (24 , 96 , 141 , 0.2 );
56
61
margin : 15px 0 0 ;
57
62
object-fit : contain;
@@ -60,7 +65,13 @@ body {
60
65
cursor : zoom-in;
61
66
}
62
67
68
+ .ZoomableImage > .AltText {
69
+ font-style : italic;
70
+ font-size : 75% ;
71
+ }
72
+
63
73
.ImageOverlayBackdrop {
74
+ display : none;
64
75
cursor : zoom-out;
65
76
position : fixed;
66
77
top : 0 ;
72
83
}
73
84
74
85
.ImageOverlay {
86
+ display : none;
75
87
box-shadow : 0 0 15px rgba (24 , 96 , 141 , 0.2 );
76
88
cursor : zoom-out;
77
89
position : fixed;
@@ -83,6 +95,19 @@ body {
83
95
transform : translate (-50% , -50% );
84
96
}
85
97
98
+ .ZoomableImage : focus-within {
99
+ border : 1px solid red;
100
+ }
101
+
102
+ .ZoomableImage : focus-within > .ImageOverlayBackdrop {
103
+ display : block;
104
+ }
105
+
106
+ .ZoomableImage : focus-within > .ImageOverlay {
107
+ display : block;
108
+ }
109
+
110
+
86
111
/* Github link taken from https://github.com/facebook/docusaurus/blob/master/website/src/css/custom.css */
87
112
.header-github-link : hover {
88
113
opacity : 0.6 ;
You can’t perform that action at this time.
0 commit comments