1
- import React , { useState , useEffect } from "react" ;
1
+ import React , { useState } from "react" ;
2
2
import "./recipeBox.css"
3
3
4
- type size = "small" | "large"
4
+ type Size = "small" | "large"
5
5
6
- export default function AuthMode ( props : { text : string , size : size , path : string , icon : string , img ?: string } ) {
7
- const [ image , setImage ] = useState ( { default : "" } ) ;
8
- const [ imageOnHover , setImageOnHover ] = useState ( { default : "" } ) ;
9
- const [ imageToShow , setImageToShow ] = useState ( { default : "" } ) ;
6
+ export default function AuthMode ( props : { text : string , size : Size , path : string , icon : string , img ?: string } ) {
10
7
const [ hover , setHover ] = useState ( false ) ;
11
- useEffect ( ( ) => {
12
- setImage ( require ( `../../../static/img/guides/${ props . icon } .svg` ) ) ;
13
- setImageOnHover ( require ( `../../../static/img/guides/${ props . icon } -orange.svg` ) ) ;
14
- if ( props . size == "large" && props . img ) {
15
- setImageToShow ( require ( `../../../static/img/guides/${ props . img } .png` ) )
16
- }
17
- } , [ props . size ] ) ;
8
+
9
+ const regularIconPath = `/img/guides/${ props . icon } .svg` ;
10
+ const onHoverIconPath = `/img/guides/${ props . icon } -orange.svg` ;
18
11
19
12
const handleMouseOver = ( ) => {
20
13
setHover ( true ) ;
@@ -25,7 +18,7 @@ export default function AuthMode(props: { text: string, size: size, path: string
25
18
26
19
return < a href = { props . path } className = { `recipe_box ${ props . size } ` } onMouseOver = { handleMouseOver } onMouseOut = { handleMouseOut } >
27
20
< div className = "recipe_box__icon_wrapper" >
28
- < img src = { hover ? imageOnHover . default : image . default } alt = { props . text } />
21
+ < img src = { hover ? onHoverIconPath : regularIconPath } alt = { props . text } />
29
22
</ div >
30
23
< div className = "recipe_box__text" > { props . text } </ div >
31
24
< div className = "recipe_box__full_image" >
0 commit comments