Skip to content

Commit 5186235

Browse files
authored
Merge pull request #174 from mercedes-benz/develop
VULCAN-874/Ultrawide screen
2 parents 1130f3e + 9872256 commit 5186235

File tree

2 files changed

+54
-4
lines changed

2 files changed

+54
-4
lines changed

src/component/groupreport/GroupReport.tsx

+29-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Box } from '@mui/material';
22
import React from 'react';
33
import NeoCard from '../../card/Card';
4+
import useUltraWide from '../../utils/useUltraWide';
45

56
export default function GroupReport({
67
groupedReports,
@@ -14,14 +15,38 @@ export default function GroupReport({
1415
getAddCardButtonPosition,
1516
onClonePressed,
1617
}) {
18+
const isUltraWide = useUltraWide();
1719
return groupedReports[groupId].length > 0 ? (
1820
<Box display='grid' gridTemplateColumns='repeat(24, 1fr)' columnGap={1} sx={getBorderSpecsForGroupId(groupId)}>
1921
{groupedReports[groupId]
20-
.sort((a: any, b: any) => a.groupOrder - b.groupOrder)
21-
.map((report: { id: any; width: any; height: any }) => {
22-
const { id, width: w, height: h } = report;
22+
.sort((a: any, b: any) => {
23+
const aGroupOrder = a.groupOrder;
24+
const bGroupOrder = b.groupOrder;
25+
const aUwGroupOrder = a.uwGroupOrder ?? 0;
26+
const bUwGroupOrder = b.uwGroupOrder ?? 0;
27+
const isUwHeightPresent = a.uwHeight && b.uwHeight;
28+
29+
if (isUltraWide && isUwHeightPresent) {
30+
return aUwGroupOrder - bUwGroupOrder;
31+
}
32+
return aGroupOrder - bGroupOrder;
33+
})
34+
.map((report: { id: any; width: any; height: any; x: any; y: any; uwHeight: number }) => {
35+
const { id, width: w, height: h, uwHeight } = report;
36+
let modifiedWidth = w;
37+
let modifiedHeight = h;
38+
if (isUltraWide && uwHeight) {
39+
modifiedWidth = w / 2;
40+
modifiedHeight = uwHeight ?? 2;
41+
}
42+
2343
return (
24-
<Box id={id} gridColumn={`span ${w}`} gridRow={`span ${h}`} sx={{ height: h * 100, paddingBottom: '15px' }}>
44+
<Box
45+
id={id}
46+
gridColumn={`span ${modifiedWidth}`}
47+
gridRow={`span ${modifiedHeight}`}
48+
sx={{ height: modifiedHeight * 100, paddingBottom: '15px' }}
49+
>
2550
<NeoCard
2651
id={id}
2752
key={getReportKey(pagenumber, id)}

src/utils/useUltraWide.ts

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { useEffect, useState } from 'react';
2+
3+
const useUltraWide = (): boolean => {
4+
const [isUltraWide, setIsUltraWide] = useState<boolean>(false);
5+
6+
useEffect(() => {
7+
const mediaQuery = '(min-aspect-ratio: 21/9)';
8+
9+
const updateUltraWideStatus = () => {
10+
const ultraWideQuery = window.matchMedia(mediaQuery);
11+
setIsUltraWide(ultraWideQuery.matches);
12+
};
13+
14+
updateUltraWideStatus();
15+
window.addEventListener('resize', updateUltraWideStatus);
16+
17+
return () => {
18+
window.removeEventListener('resize', updateUltraWideStatus);
19+
};
20+
}, []);
21+
22+
return isUltraWide;
23+
};
24+
25+
export default useUltraWide;

0 commit comments

Comments
 (0)