@@ -2,12 +2,12 @@ import {GameboardDTO, GameboardItem, IsaacFastTrackQuestionPageDTO} from "../../
2
2
import queryString from "query-string" ;
3
3
import { useDispatch , useSelector } from "react-redux" ;
4
4
import { AppState } from "../../state/reducers" ;
5
- import { useMediaQuery } from "react-responsive" ;
6
5
import React , { useEffect } from "react" ;
7
6
import { fetchFasttrackConcepts } from "../../state/actions" ;
8
7
import * as RS from "reactstrap" ;
9
8
import { board } from "../../state/selectors" ;
10
9
import { Link } from "react-router-dom" ;
10
+ import { useDeviceSize } from "../../services/device" ;
11
11
12
12
type QuestionLevel = "topTen" | "upper" | "lower" ;
13
13
@@ -103,15 +103,12 @@ export function FastTrackProgress({doc, search}: {doc: IsaacFastTrackQuestionPag
103
103
const gameboardMaybeNull = useSelector ( board . currentGameboard ) ;
104
104
const fasttrackConcepts = useSelector ( ( appState : AppState ) => appState && appState . fasttrackConcepts ) ;
105
105
106
- const smDevice = useMediaQuery ( { query : '(min-width: 768px)' } ) ;
107
- const mdDevice = useMediaQuery ( { query : '(min-width: 992px)' } ) ;
108
- const lgDevice = useMediaQuery ( { query : '(min-width: 1200px)' } ) ;
109
- const deviceSize = lgDevice ? "lg" : mdDevice ? "md" : smDevice ? "sm" : "xs" ;
110
- const hexagonUnitLength = { lg : 28 , md : 26 , sm : 22 , xs : 12.5 } [ deviceSize ] ;
111
- const hexagonPadding = { lg : 4 , md : 4 , sm : 3 , xs : 2 } [ deviceSize ] ;
106
+ const deviceSize = useDeviceSize ( ) ;
107
+ const hexagonUnitLength = { xl : 28 , lg : 26 , md : 22 , sm : 22 , xs : 12.5 } [ deviceSize ] ;
108
+ const hexagonPadding = { xl : 4 , lg : 4 , md : 3 , sm : 3 , xs : 2 } [ deviceSize ] ;
112
109
const hexagonHalfWidth = hexagonUnitLength ;
113
110
const hexagonQuarterHeight = hexagonUnitLength / Math . sqrt ( 3 ) ;
114
- const progressBarPadding = deviceSize !== 'xs' ? 5 : 1 ;
111
+ const progressBarPadding = [ "xs" ] . includes ( deviceSize ) ? 1 : 5 ;
115
112
116
113
const conceptQuestions =
117
114
gameboardMaybeNull && fasttrackConcepts && fasttrackConcepts . gameboardId === gameboardMaybeNull . id && fasttrackConcepts . concept === doc . title ?
@@ -164,7 +161,7 @@ export function FastTrackProgress({doc, search}: {doc: IsaacFastTrackQuestionPag
164
161
} ,
165
162
base : {
166
163
stroke : {
167
- width : { lg : 3 , md : 3 , sm : 2 , xs : 2 } [ deviceSize ] ,
164
+ width : { xl : 3 , lg : 3 , md : 2 , sm : 2 , xs : 2 } [ deviceSize ] ,
168
165
colour : '#ddd'
169
166
} ,
170
167
fill : {
@@ -176,7 +173,7 @@ export function FastTrackProgress({doc, search}: {doc: IsaacFastTrackQuestionPag
176
173
} ,
177
174
questionPartProgress : {
178
175
stroke : {
179
- width : { lg : 3 , md : 3 , sm : 2 , xs : 2 } [ deviceSize ] ,
176
+ width : { xl : 3 , lg : 3 , md : 2 , sm : 2 , xs : 2 } [ deviceSize ] ,
180
177
colour : '#009acd'
181
178
} ,
182
179
fill : { colour : 'none' } ,
@@ -187,7 +184,7 @@ export function FastTrackProgress({doc, search}: {doc: IsaacFastTrackQuestionPag
187
184
fill : 'none' ,
188
185
stroke : {
189
186
colour : '#fea100' ,
190
- width : { lg : 3 , md : 3 , sm : 2 , xs : 2 } [ deviceSize ] ,
187
+ width : { xl : 3 , lg : 3 , md : 2 , sm : 2 , xs : 2 } [ deviceSize ] ,
191
188
dashArray : 4
192
189
} ,
193
190
} ;
@@ -340,14 +337,14 @@ export function FastTrackProgress({doc, search}: {doc: IsaacFastTrackQuestionPag
340
337
341
338
function generateHexagonTitle ( title : string , isCurrentQuestion : boolean ) {
342
339
let isTwoCharLength = ( "" + title ) . length > 1 ;
343
- let xSingleCharPosition = hexagon . halfWidth - { lg : 8 , md : 8 , sm : 6 , xs : 5 } [ deviceSize ] ;
344
- let xTwoCharPosition = hexagon . halfWidth - { lg : 14 , md : 14 , sm : 11 , xs : 10 } [ deviceSize ] ;
345
- let yPosition = hexagon . quarterHeight * 2 + { lg : 9 , md : 9 , sm : 7 , xs : 6 } [ deviceSize ] ;
340
+ let xSingleCharPosition = hexagon . halfWidth - { xl : 8 , lg : 8 , md : 6 , sm : 6 , xs : 5 } [ deviceSize ] ;
341
+ let xTwoCharPosition = hexagon . halfWidth - { xl : 14 , lg : 14 , md : 11 , sm : 11 , xs : 10 } [ deviceSize ] ;
342
+ let yPosition = hexagon . quarterHeight * 2 + { xl : 9 , lg : 9 , md : 7 , sm : 7 , xs : 6 } [ deviceSize ] ;
346
343
return < text
347
344
fontFamily = "Exo 2"
348
- fontSize = { { lg : 26 , md : 26 , sm : 18 , xs : 18 } [ deviceSize ] }
345
+ fontSize = { { xl : 26 , lg : 26 , md : 18 , sm : 18 , xs : 18 } [ deviceSize ] }
349
346
fontStyle = "italic"
350
- fontWeight = { deviceSize === 'xs' ? 500 : 600 }
347
+ fontWeight = { [ "xs" ] . includes ( deviceSize ) ? 500 : 600 }
351
348
fill = { isCurrentQuestion ? '#333' : '#ccc' }
352
349
stroke = "none"
353
350
strokeWidth = { 1 }
@@ -361,10 +358,10 @@ export function FastTrackProgress({doc, search}: {doc: IsaacFastTrackQuestionPag
361
358
function generateCompletionTick ( isCurrentQuestion : boolean ) {
362
359
return < image
363
360
href = "/assets/tick-bg.png"
364
- height = { { lg : 36 , md : 34 , sm : 29 , xs : 18 } [ deviceSize ] }
365
- width = { { lg : 36 , md : 34 , sm : 29 , xs : 18 } [ deviceSize ] }
366
- x = { hexagon . halfWidth - { lg : 18 , md : 17 , sm : 15 , xs : 9 } [ deviceSize ] }
367
- y = { hexagon . quarterHeight - { lg : 2 , md : 2 , sm : 2 , xs : 2 } [ deviceSize ] }
361
+ height = { { xl : 36 , lg : 34 , md : 29 , sm : 29 , xs : 18 } [ deviceSize ] }
362
+ width = { { xl : 36 , lg : 34 , md : 29 , sm : 29 , xs : 18 } [ deviceSize ] }
363
+ x = { hexagon . halfWidth - { xl : 18 , lg : 17 , md : 15 , sm : 15 , xs : 9 } [ deviceSize ] }
364
+ y = { hexagon . quarterHeight - { xl : 2 , lg : 2 , md : 2 , sm : 2 , xs : 2 } [ deviceSize ] }
368
365
opacity = { isCurrentQuestion ? 1 : 0.3 }
369
366
/> ;
370
367
}
0 commit comments