11/* eslint-disable @next/next/no-img-element */
22
33'use client' ;
4- import { Send } from '@mui/icons-material' ;
4+ import styled from '@emotion/styled' ;
5+ import { Autorenew , Send } from '@mui/icons-material' ;
56import Avatar from '@mui/material/Avatar' ;
67import Button from '@mui/material/Button' ;
8+ import { purple } from '@mui/material/colors' ;
79import Stack from '@mui/material/Stack' ;
810import React , { useEffect , useState } from 'react' ;
911
@@ -12,6 +14,28 @@ import { useClientContext } from '@/hooks/useClientContext';
1214
1315import SubmitButton from '@/components/shared/SubmitButton' ;
1416
17+ const StyledRefreshButton = styled . div `
18+ position: absolute;
19+ right: 0;
20+ top: 0;
21+ margin: 0.5rem;
22+ cursor: pointer;
23+ svg {
24+ width: 20px;
25+ height: 20px;
26+ }
27+ :hover {
28+ svg {
29+ path {
30+ fill: ${ purple [ 500 ] } ;
31+ }
32+ }
33+ .MuiAvatar-circular {
34+ background-color: ${ purple [ 50 ] } ;
35+ }
36+ }
37+ ` ;
38+
1539const DisplayRandomPicture = ( ) => {
1640 const [ imageUrl , setImageUrl ] = useState ( '' ) ;
1741 const [ loading , setLoading ] = useState ( true ) ;
@@ -59,6 +83,7 @@ const DisplayRandomPicture = () => {
5983 justifyContent = 'center'
6084 alignItems = 'center'
6185 spacing = { 2 }
86+ sx = { { position : 'relative' , width : '300px' , margin : '0 auto' } }
6287 >
6388 { error && < p > { error } </ p > }
6489 { imageUrl && (
@@ -88,6 +113,11 @@ const DisplayRandomPicture = () => {
88113 Get Another Picture
89114 </ Button >
90115 </ SubmitButton >
116+ < StyledRefreshButton onClick = { fetchRandomPicture } >
117+ < Avatar sx = { { width : 24 , height : 24 } } >
118+ < Autorenew />
119+ </ Avatar >
120+ </ StyledRefreshButton >
91121 { renderAlertBar ( ) }
92122 </ Stack >
93123 ) ;
0 commit comments