From 1b244e7d7754e0184233855f50e70f39c192d8e4 Mon Sep 17 00:00:00 2001 From: FRVGS <143963989+frvgs@users.noreply.github.com> Date: Wed, 6 Sep 2023 11:54:54 +0200 Subject: [PATCH 1/2] Rescale UI Elements for 4K Displays --- nui/src/components/MainPage/MainPageList.tsx | 14 ++++++- nui/src/components/MainPage/MenuListItem.tsx | 35 ++++++++++++++--- nui/src/components/MenuRootContent.tsx | 40 ++++++++++++++------ nui/src/components/misc/HelpTooltip.tsx | 16 +++++++- nui/src/components/misc/PageTabs.tsx | 10 ++++- 5 files changed, 93 insertions(+), 22 deletions(-) diff --git a/nui/src/components/MainPage/MainPageList.tsx b/nui/src/components/MainPage/MainPageList.tsx index 6027eb225..5334913d6 100644 --- a/nui/src/components/MainPage/MainPageList.tsx +++ b/nui/src/components/MainPage/MainPageList.tsx @@ -46,6 +46,9 @@ const BoxFadeTop = styled(Box)(({ theme }) => ({ position: "relative", bottom: listHeight + fadeHeight - 4, height: fadeHeight, + '@media (min-height: 2160px)': { + bottom: 600 + fadeHeight - 4, + } })); const BoxFadeBottom = styled(Box)(({ theme }) => ({ @@ -68,6 +71,9 @@ const StyledList = styled(List)({ "&::-webkit-scrollbar": { display: "none", }, + '@media (min-height: 2160px)': { + maxHeight: 800, + } }); // TODO: This component is kinda getting out of hand, might want to split it somehow @@ -565,6 +571,12 @@ export const MainPageList: React.FC = () => { [playerMode, teleportMode, vehicleMode, healMode, serverCtx, isRedm] ); + const StyledExpandMore = styled(ExpandMore)({ + fontSize: '1rem', + '@media (min-height: 2160px)': { + fontSize: '2.8rem', + }, + }); return ( // add pb={2} if we don't have that arrow at the bottom @@ -590,7 +602,7 @@ export const MainPageList: React.FC = () => { = 6 ? 0 : 1 }} /> - + {/* ({ [`& .${classes.overrideText}`]: { color: theme.palette.text.primary, fontSize: 16, - } + }, + '@media (min-height: 2160px)': { + [`& .${classes.root}`]: { + padding: 12, + borderRadius: 20, + }, + [`& .${classes.icon}`]: { + fontSize: '2.8rem', + padding: 8, + }, + [`& .${classes.largeIcon}`]: { + fontSize: '2.8rem', + }, + [`& .${classes.overrideText}`]: { + fontSize: '2.4rem', + marginLeft: 50, + }, + [`& .${classes.largeTypography}`]: { + fontSize: '1.8rem', + }, + }, })); export interface MenuListItemProps { @@ -114,12 +136,15 @@ export const MenuListItem: React.FC = memo( return ( onSelect()} className={isUserAllowed ? classes.root : classes.rootDisabled} dense selected={selected} > - {icon} + + {React.cloneElement(icon, { className: classes.largeIcon })} + = memo( selected={selected} > - {actions[curState]?.icon ?? icon} + {React.cloneElement(actions[curState]?.icon ?? icon, { className: classes.largeIcon })} {title}:  - + {actions[curState]?.name ?? "???"} diff --git a/nui/src/components/MenuRootContent.tsx b/nui/src/components/MenuRootContent.tsx index f92150e8e..2e43972fa 100644 --- a/nui/src/components/MenuRootContent.tsx +++ b/nui/src/components/MenuRootContent.tsx @@ -10,13 +10,33 @@ interface TxAdminLogoProps { themeName: string; } +const StyledImage = styled('img')({ + width: '100%', + maxWidth: '200px', + '@media (min-height: 2160px)': { + maxWidth: '300px', + }, +}); + +const StyledTypography = styled(Typography)({ + fontWeight: 500, + marginTop: -20, + textAlign: "right", + fontSize: 12, + '@media (min-height: 2160px)': { + fontSize: 20, + marginTop: -32, + marginRight: 65, + }, +}); + const TxAdminLogo: React.FC = ({ themeName }) => { const imgName = themeName === 'fivem' ? 'txadmin.png' : 'txadmin-redm.png'; return ( - txAdmin logo + - ) + ); }; const StyledRoot = styled(Box)(({ theme }) => ({ @@ -27,6 +47,10 @@ const StyledRoot = styled(Box)(({ theme }) => ({ display: "flex", flexDirection: "column", userSelect: "none", + '@media (min-height: 2160px)': { + width: 750, + borderRadius: 30, + }, })); export const MenuRootContent: React.FC = React.memo(() => { @@ -45,18 +69,10 @@ export const MenuRootContent: React.FC = React.memo(() => { return ( - + v{serverCtx.txAdminVersion} {versionPad} - + ( borderRadius: 10, padding: 10, transformOrigin: "bottom", + '@media (min-height: 2160px)': { + minWidth: '700px !important', + padding: 15, + }, + }, [`& .${tooltipClasses.arrow}`]: { color: theme.palette.background.default, }, })); +const StyledTypography = styled(Typography)({ + fontSize: '1rem', + '@media (min-height: 2160px)': { + fontSize: '2rem', + }, +}); + interface HelpTooltipProps { children: ReactNode; } @@ -30,9 +42,9 @@ export const HelpTooltip: React.FC = ({ children }) => { + {tooltipText} - + } //FIXME: is it needed? it was there in Taso's version // PopperProps={{ diff --git a/nui/src/components/misc/PageTabs.tsx b/nui/src/components/misc/PageTabs.tsx index 3926bc539..eabe3546f 100644 --- a/nui/src/components/misc/PageTabs.tsx +++ b/nui/src/components/misc/PageTabs.tsx @@ -6,9 +6,15 @@ import { useTabDisabledValue } from "../../state/keys.state"; import { useIsMenuVisibleValue } from "../../state/visibility.state"; import { useServerCtxValue } from "../../state/server.state"; -const StyledTab = styled(Tab)({ +const StyledTab = styled(Tab)(({ theme }) => ({ minWidth: 100, -}); + '@media (min-height: 2160px)': { + '&.MuiTab-root': { + fontSize: '2.2rem', + marginTop: 20, + }, + }, +})); export const PageTabs: React.FC = () => { const [page, setPage] = usePage(); From a0567e31251e619c820328f8899b39bf67e255bf Mon Sep 17 00:00:00 2001 From: FRVGS <143963989+frvgs@users.noreply.github.com> Date: Wed, 6 Sep 2023 22:30:31 +0200 Subject: [PATCH 2/2] Update MenuListItem.tsx fonSize to match the original proportion --- nui/src/components/MainPage/MenuListItem.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nui/src/components/MainPage/MenuListItem.tsx b/nui/src/components/MainPage/MenuListItem.tsx index 7048d36bc..b57ed471a 100644 --- a/nui/src/components/MainPage/MenuListItem.tsx +++ b/nui/src/components/MainPage/MenuListItem.tsx @@ -67,7 +67,7 @@ const Root = styled('div')(({ theme }) => ({ marginLeft: 50, }, [`& .${classes.largeTypography}`]: { - fontSize: '1.8rem', + fontSize: '2.4rem', }, }, }));