@@ -12,7 +12,7 @@ import {
12
12
PopoverArrow ,
13
13
useMediaQuery ,
14
14
} from '@chakra-ui/react'
15
- import { ReactElement , useReducer } from 'react'
15
+ import { ReactElement , useEffect , useReducer , useState } from 'react'
16
16
import { FaGraduationCap } from 'react-icons/fa'
17
17
import { IoTimerOutline } from 'react-icons/io5'
18
18
import {
@@ -137,13 +137,26 @@ export const PomodoroTimer = (props: any) => {
137
137
const { isRunning, status, timeRemaining } = state
138
138
139
139
const { variant, ...rest } = props
140
- const [ isBigScreen ] = useMediaQuery ( '(min-width: 62em)' )
141
- const maxPopoverWidth = isBigScreen ? '14rem' : '11rem'
140
+ const [ isBigScreenMediaQuery ] = useMediaQuery ( '(min-width: 62em)' )
141
+ const [ isBigScreen , setIsBigScreen ] = useState ( false )
142
+ const [ maxPopoverWidth , setMaxPopoverWidth ] = useState ( '14rem' )
143
+
144
+ useEffect ( ( ) => {
145
+ setIsBigScreen ( isBigScreenMediaQuery )
146
+ } , [ isBigScreenMediaQuery ] )
147
+
148
+ useEffect ( ( ) => {
149
+ setMaxPopoverWidth ( isBigScreen ? '14rem' : '11rem' )
150
+ } , [ isBigScreen ] )
142
151
143
152
const timerStyle = useStyleConfig ( 'PomodoroTimer' , { variant } )
144
153
const iconStyle = useStyleConfig ( 'PomodoroIcon' , { variant } )
145
154
146
- const getButton = ( data : TimerEventData , idx : number ) => {
155
+ const getButton = (
156
+ data : TimerEventData ,
157
+ idx : number ,
158
+ isBigScreen : boolean ,
159
+ ) => {
147
160
return data . eventIcon ? (
148
161
isBigScreen ? (
149
162
< Button
@@ -194,7 +207,7 @@ export const PomodoroTimer = (props: any) => {
194
207
{ status ? < Status > { status } </ Status > : < Status > </ Status > }
195
208
< TimeRemaining time = { time } />
196
209
< ButtonGroup variant = "pomodoroControl" size = "sm" gap = "0" isAttached >
197
- { events . map ( ( e , idx ) => getButton ( e , idx ) ) }
210
+ { events . map ( ( e , idx ) => getButton ( e , idx , isBigScreen ) ) }
198
211
</ ButtonGroup >
199
212
</ Stack >
200
213
</ PopoverContent >
0 commit comments