Skip to content

Commit 25d8102

Browse files
committed
Add support for XXL in useDeviceSize
1 parent 91a9449 commit 25d8102

File tree

2 files changed

+19
-16
lines changed

2 files changed

+19
-16
lines changed

src/app/components/elements/FastTrackProgress.tsx

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ export function FastTrackProgress({doc, search}: {doc: IsaacFastTrackQuestionPag
7171
}, [search]);
7272

7373
const deviceSize = useDeviceSize();
74-
const hexagonUnitLength = {xl: 28, lg: 26, md: 22, sm: 22, xs: 12.5}[deviceSize];
75-
const hexagonPadding = {xl: 4, lg: 4, md: 3, sm: 3, xs: 2}[deviceSize];
74+
const hexagonUnitLength = {xxl: 28, xl: 28, lg: 26, md: 22, sm: 22, xs: 12.5}[deviceSize];
75+
const hexagonPadding = {xxl: 4, xl: 4, lg: 4, md: 3, sm: 3, xs: 2}[deviceSize];
7676
const hexagonHalfWidth = hexagonUnitLength;
7777
const hexagonQuarterHeight = hexagonUnitLength / Math.sqrt(3);
7878
const progressBarPadding = ["xs"].includes(deviceSize) ? 1 : 5;
@@ -115,7 +115,7 @@ export function FastTrackProgress({doc, search}: {doc: IsaacFastTrackQuestionPag
115115
quarterHeight: hexagonQuarterHeight,
116116
base: {
117117
stroke: {
118-
width: {xl: 3, lg: 3, md: 2, sm: 2, xs: 2}[deviceSize],
118+
width: {xxl: 3, xl: 3, lg: 3, md: 2, sm: 2, xs: 2}[deviceSize],
119119
colour: '#ddd'
120120
},
121121
fill: {
@@ -127,7 +127,7 @@ export function FastTrackProgress({doc, search}: {doc: IsaacFastTrackQuestionPag
127127
},
128128
questionPartProgress: {
129129
stroke: {
130-
width: {xl: 3, lg: 3, md: 2, sm: 2, xs: 2}[deviceSize],
130+
width: {xxl: 3, xl: 3, lg: 3, md: 2, sm: 2, xs: 2}[deviceSize],
131131
colour: '#009acd'
132132
},
133133
fill: {colour: 'none'},
@@ -137,7 +137,7 @@ export function FastTrackProgress({doc, search}: {doc: IsaacFastTrackQuestionPag
137137
const conceptConnectionProperties = {
138138
fill: 'none',
139139
stroke: '#fea100',
140-
strokeWidth: {xl: 3, lg: 3, md: 2, sm: 2, xs: 2}[deviceSize],
140+
strokeWidth: {xxl: 3, xl: 3, lg: 3, md: 2, sm: 2, xs: 2}[deviceSize],
141141
strokeDasharray: 4
142142
};
143143

@@ -289,12 +289,12 @@ export function FastTrackProgress({doc, search}: {doc: IsaacFastTrackQuestionPag
289289

290290
function generateHexagonTitle(title: string, isCurrentQuestion: boolean) {
291291
const isTwoCharLength = ("" + title).length > 1;
292-
const xSingleCharPosition = hexagon.halfWidth - {xl: 8, lg: 8, md: 6, sm: 6, xs: 5}[deviceSize];
293-
const xTwoCharPosition = hexagon.halfWidth - {xl: 14, lg: 14, md: 11, sm: 11, xs: 10}[deviceSize];
294-
const yPosition = hexagon.quarterHeight * 2 + {xl: 9, lg: 9, md: 7, sm: 7, xs: 6}[deviceSize];
292+
const xSingleCharPosition = hexagon.halfWidth - {xxl: 8, xl: 8, lg: 8, md: 6, sm: 6, xs: 5}[deviceSize];
293+
const xTwoCharPosition = hexagon.halfWidth - {xxl: 14, xl: 14, lg: 14, md: 11, sm: 11, xs: 10}[deviceSize];
294+
const yPosition = hexagon.quarterHeight * 2 + {xxl: 9, xl: 9, lg: 9, md: 7, sm: 7, xs: 6}[deviceSize];
295295
return <text
296296
fontFamily="Exo 2"
297-
fontSize={{xl: 26, lg: 26, md: 18, sm: 18, xs: 18}[deviceSize]}
297+
fontSize={{xxl: 26, xl: 26, lg: 26, md: 18, sm: 18, xs: 18}[deviceSize]}
298298
fontStyle="italic"
299299
fontWeight={["xs"].includes(deviceSize) ? 500 : 600}
300300
fill={isCurrentQuestion ? '#333' : '#ccc'}
@@ -310,10 +310,10 @@ export function FastTrackProgress({doc, search}: {doc: IsaacFastTrackQuestionPag
310310
function generateCompletionTick(isCurrentQuestion: boolean) {
311311
return <image
312312
href="/assets/common/icons/tick-bg.png"
313-
height={{xl: 36, lg: 34, md: 29, sm: 29, xs: 18}[deviceSize]}
314-
width={{xl: 36, lg: 34, md: 29, sm: 29, xs: 18}[deviceSize]}
315-
x={hexagon.halfWidth - {xl: 18, lg: 17, md: 15, sm: 15, xs: 9}[deviceSize]}
316-
y={hexagon.quarterHeight - {xl: 2, lg: 2, md: 2, sm: 2, xs: 2}[deviceSize]}
313+
height={{xxl: 36, xl: 36, lg: 34, md: 29, sm: 29, xs: 18}[deviceSize]}
314+
width={{xxl: 36, xl: 36, lg: 34, md: 29, sm: 29, xs: 18}[deviceSize]}
315+
x={hexagon.halfWidth - {xxl: 18, xl: 18, lg: 17, md: 15, sm: 15, xs: 9}[deviceSize]}
316+
y={hexagon.quarterHeight - {xxl: 2, xl: 2, lg: 2, md: 2, sm: 2, xs: 2}[deviceSize]}
317317
opacity={isCurrentQuestion ? 1 : 0.3}
318318
/>;
319319
}

src/app/services/device.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export const isTouchDevice = () => {
1414
export const isNotTouchDevice = () => !isTouchDevice();
1515

1616
export enum DeviceSize {
17+
XXL = "xxl",
1718
XL = "xl",
1819
LG = "lg",
1920
MD = "md",
@@ -26,12 +27,13 @@ export enum DeviceOrientation {
2627
LANDSCAPE = "landscape",
2728
}
2829

29-
const descDeviceSizes = [DeviceSize.XL, DeviceSize.LG, DeviceSize.MD, DeviceSize.SM, DeviceSize.XS];
30+
const descDeviceSizes = [DeviceSize.XXL, DeviceSize.XL, DeviceSize.LG, DeviceSize.MD, DeviceSize.SM, DeviceSize.XS];
3031

3132
export const useDeviceSize = () => {
3233
const getSize = (): DeviceSize => {
3334
const width = window.innerWidth;
34-
if (width >= 1200) return DeviceSize.XL;
35+
if (width >= 1400) return DeviceSize.XXL;
36+
else if (width >= 1200) return DeviceSize.XL;
3537
else if (width >= 992) return DeviceSize.LG;
3638
else if (width >= 768) return DeviceSize.MD;
3739
else if (width >= 576) return DeviceSize.SM;
@@ -52,7 +54,8 @@ export const useDeviceSize = () => {
5254
export const useDeviceHeight = () => {
5355
const getHeight = (): DeviceSize => {
5456
const height = window.innerHeight;
55-
if (height >= 1200) return DeviceSize.XL;
57+
if (height >= 1400) return DeviceSize.XXL;
58+
else if (height >= 1200) return DeviceSize.XL;
5659
else if (height >= 992) return DeviceSize.LG;
5760
else if (height >= 768) return DeviceSize.MD;
5861
else if (height >= 576) return DeviceSize.SM;

0 commit comments

Comments
 (0)