From ab6992709fe5366df242f4f45dc3140bc632bdf5 Mon Sep 17 00:00:00 2001 From: v4ltages Date: Tue, 5 Aug 2025 15:09:13 +0300 Subject: [PATCH] Same margin for all pages & messiala map scaling for smaller devices --- src/app/haldus/meeskonnad/page.tsx | 2 +- src/app/haldus/page.tsx | 2 +- src/app/kodukord/page.tsx | 2 +- src/app/messiala/page.tsx | 53 ++++++++++++++++++++++++++---- src/app/turniirid/page.tsx | 19 +++++++---- 5 files changed, 62 insertions(+), 16 deletions(-) diff --git a/src/app/haldus/meeskonnad/page.tsx b/src/app/haldus/meeskonnad/page.tsx index b7290f5..d86a6a3 100644 --- a/src/app/haldus/meeskonnad/page.tsx +++ b/src/app/haldus/meeskonnad/page.tsx @@ -44,7 +44,7 @@ export default async function AdminTeams() { }); return ( -
+
diff --git a/src/app/haldus/page.tsx b/src/app/haldus/page.tsx index f44a1a7..bccd5b6 100644 --- a/src/app/haldus/page.tsx +++ b/src/app/haldus/page.tsx @@ -96,7 +96,7 @@ export default async function Admin({ const teamsData = await db.query.teams.findMany(); return ( -
+
{showSuccess && }
diff --git a/src/app/kodukord/page.tsx b/src/app/kodukord/page.tsx index c4b30f4..6173c05 100644 --- a/src/app/kodukord/page.tsx +++ b/src/app/kodukord/page.tsx @@ -2,7 +2,7 @@ import { vipnagorgialla } from "@/components/Vipnagorgialla"; export default function Rulebook() { return ( -
+

diff --git a/src/app/messiala/page.tsx b/src/app/messiala/page.tsx index d702776..35b7d8b 100644 --- a/src/app/messiala/page.tsx +++ b/src/app/messiala/page.tsx @@ -16,9 +16,25 @@ export default function Expo() { const scene = new THREE.Scene(); scene.background = new THREE.Color(0x0e0f19); - // Isometric camera setup - const aspect = 800 / 600; - const frustumSize = 14; + // Get responsive dimensions + const getResponsiveDimensions = () => { + const container = mountRef.current; + if (!container) return { width: 800, height: 600 }; + + const containerWidth = container.offsetWidth; + const maxWidth = Math.min(containerWidth, 800); + const width = Math.max(maxWidth, 300); // Minimum width + const height = (width * 600) / 800; // Maintain aspect ratio + + return { width, height }; + }; + + const { width, height } = getResponsiveDimensions(); + + // Isometric camera setup with responsive sizing + const aspect = width / height; + const baseFrustumSize = 14; + const frustumSize = width < 600 ? baseFrustumSize * 0.8 : baseFrustumSize; // Smaller frustum for mobile const camera = new THREE.OrthographicCamera( (frustumSize * aspect) / -2, (frustumSize * aspect) / 2, @@ -34,7 +50,7 @@ export default function Expo() { // Renderer const renderer = new THREE.WebGLRenderer({ antialias: true }); - renderer.setSize(800, 600); + renderer.setSize(width, height); renderer.shadowMap.enabled = true; renderer.shadowMap.type = THREE.PCFSoftShadowMap; mountRef.current.appendChild(renderer.domElement); @@ -197,6 +213,28 @@ export default function Expo() { ground2.receiveShadow = true; scene.add(ground2); + // Resize handler + const handleResize = () => { + const { width: newWidth, height: newHeight } = getResponsiveDimensions(); + + // Update camera + const newAspect = newWidth / newHeight; + const newFrustumSize = + newWidth < 600 ? baseFrustumSize * 0.8 : baseFrustumSize; + + camera.left = (newFrustumSize * newAspect) / -2; + camera.right = (newFrustumSize * newAspect) / 2; + camera.top = newFrustumSize / 2; + camera.bottom = newFrustumSize / -2; + camera.updateProjectionMatrix(); + + // Update renderer + renderer.setSize(newWidth, newHeight); + }; + + // Add resize event listener + window.addEventListener("resize", handleResize); + // Mouse event handlers const onMouseMove = (event: MouseEvent) => { const rect = renderer.domElement.getBoundingClientRect(); @@ -258,6 +296,7 @@ export default function Expo() { // Cleanup return () => { + window.removeEventListener("resize", handleResize); renderer.domElement.removeEventListener("mousemove", onMouseMove); if (mountRef.current && renderer.domElement) { mountRef.current.removeChild(renderer.domElement); @@ -267,7 +306,7 @@ export default function Expo() { }, []); return ( -
+

@@ -344,8 +383,8 @@ export default function Expo() {

-
-
+
+
{/* Tooltip */} diff --git a/src/app/turniirid/page.tsx b/src/app/turniirid/page.tsx index d527446..e9d72c9 100644 --- a/src/app/turniirid/page.tsx +++ b/src/app/turniirid/page.tsx @@ -1,10 +1,17 @@ import { vipnagorgialla } from "@/components/Vipnagorgialla"; export default function Tourney() { - return ( -
-

Turniirid

-

Kui tahate oma oskusi proovile panna, siis vaadake siia tagasi! Rohkem infot lähiajal.

-
- ); + return ( +
+

+ Turniirid +

+

+ Kui tahate oma oskusi proovile panna, siis vaadake siia tagasi! Rohkem + infot lähiajal. +

+
+ ); }