From 241fb2107bc3ad7064e9b1391fc4c8e01b389f54 Mon Sep 17 00:00:00 2001 From: Luke <39926192+LukeWasTakenn@users.noreply.github.com> Date: Sat, 18 Nov 2023 16:06:27 +0100 Subject: [PATCH] style(web/skillcheck): adjust scaling for 1440p and beyond --- web/src/features/skillcheck/index.tsx | 60 ++++++++++++++++++----- web/src/features/skillcheck/indicator.tsx | 13 +---- 2 files changed, 48 insertions(+), 25 deletions(-) diff --git a/web/src/features/skillcheck/index.tsx b/web/src/features/skillcheck/index.tsx index 678d587..cd3cb66 100644 --- a/web/src/features/skillcheck/index.tsx +++ b/web/src/features/skillcheck/index.tsx @@ -15,27 +15,61 @@ const difficultyOffsets = { hard: 25, }; -const useStyles = createStyles((theme) => ({ +const useStyles = createStyles((theme, params: { difficultyOffset: number }) => ({ svg: { position: 'absolute', top: '50%', left: '50%', transform: 'translate(-50%, -50%)', + r: 50, + width: 500, + height: 500, }, track: { fill: 'transparent', stroke: theme.colors.dark[5], strokeWidth: 8, + r: 50, + cx: 250, + cy: 250, + strokeDasharray: circleCircumference, + '@media (min-height: 1440px)': { + strokeWidth: 10, + r: 65, + strokeDasharray: 2 * 65 * Math.PI, + }, }, skillArea: { fill: 'transparent', stroke: theme.fn.primaryColor(), strokeWidth: 8, + r: 50, + cx: 250, + cy: 250, + strokeDasharray: circleCircumference, + strokeDashoffset: circleCircumference - (Math.PI * 50 * params.difficultyOffset) / 180, + '@media (min-height: 1440px)': { + strokeWidth: 10, + r: 65, + strokeDasharray: 2 * 65 * Math.PI, + strokeDashoffset: 2 * 65 * Math.PI - (Math.PI * 65 * params.difficultyOffset) / 180, + }, }, indicator: { stroke: 'red', strokeWidth: 16, fill: 'transparent', + r: 50, + cx: 250, + cy: 250, + strokeDasharray: circleCircumference, + strokeDashoffset: circleCircumference - 3, + '@media (min-height: 1440px)': { + strokeWidth: 18, + r: 65, + strokeDasharray: 2 * 65 * Math.PI, + strokeDashoffset: 2 * 65 * Math.PI - 5, + }, }, button: { position: 'absolute', @@ -49,11 +83,18 @@ const useStyles = createStyles((theme) => ({ borderRadius: 5, fontSize: 16, fontWeight: 500, + display: 'flex', + justifyContent: 'center', + alignItems: 'center', + '@media (min-height: 1440px)': { + width: 30, + height: 30, + fontSize: 22, + }, }, })); const SkillCheck: React.FC = () => { - const { classes } = useStyles(); const [visible, setVisible] = useState(false); const dataRef = useRef<{ difficulty: GameDifficulty | GameDifficulty[]; inputs?: string[] } | null>(null); const dataIndexRef = useRef(0); @@ -63,6 +104,7 @@ const SkillCheck: React.FC = () => { difficulty: 'easy', key: 'e', }); + const { classes } = useStyles({ difficultyOffset: skillCheck.difficultyOffset }); useNuiEvent('startSkillCheck', (data: { difficulty: GameDifficulty | GameDifficulty[]; inputs?: string[] }) => { dataRef.current = data; @@ -117,19 +159,11 @@ const SkillCheck: React.FC = () => { <> {visible && ( <> - + {/*Circle track*/} - + {/*SkillCheck area*/} - + = ({ angle, offset, multiplier, handleComplete, setKeyPressed(false); }, [keyPressed]); - return ( - - ); + return ; }; export default Indicator;