Skip to content

Commit e12e1e5

Browse files
committed
Add calculator page and enhance header navigation; refactor imports and improve layout
1 parent 621cc80 commit e12e1e5

File tree

9 files changed

+55
-26
lines changed

9 files changed

+55
-26
lines changed

app/calculator/page.tsx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
'use client';
2+
3+
import Header from "../components/Header"; // Adjusted import path
4+
import Calculator from "../components/calculator/Calculator"; // Adjusted import path
5+
import { WallCalculatorProvider } from "../components/calculator/context/WallCalculatorContext"; // Adjusted import path
6+
7+
export default function CalculatorPage() { // Renamed function for clarity
8+
return (
9+
<div className="min-h-screen flex flex-col">
10+
<Header />
11+
<WallCalculatorProvider>
12+
<Calculator />
13+
</WallCalculatorProvider>
14+
</div>
15+
);
16+
}

app/components/Header.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import Link from "next/link"; // Add Link import
12
import { MoveRight } from "lucide-react"
23
import { Button } from "@/components/ui/button"
34

@@ -10,6 +11,10 @@ export default function Header() {
1011
Calculate thermal performance of wall assemblies
1112
</p>
1213
</div>
14+
<nav className="flex gap-4 items-center"> {/* Add nav container */}
15+
<Link href="/" legacyBehavior><a className="text-sm font-medium hover:underline underline-offset-4">Home</a></Link>
16+
<Link href="/calculator" legacyBehavior><a className="text-sm font-medium hover:underline underline-offset-4">Calculator</a></Link>
17+
</nav>
1318
<Button
1419
variant="ghost"
1520
size="sm"

app/components/calculator/WallVisualization3D.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { Geometry, Base, Subtraction } from '@react-three/csg'
66
import { WallComponent, commonMaterials, StudWallConfig } from "./types"
77
import { findDewPointPosition } from "@/app/components/calculator/components/TemperatureGradient";
88
import * as THREE from "three"; // NEW: Import THREE for DoubleSide
9+
import { getComponentColor } from "./utils/visualizationHelpers"; // Import the function
910

1011
interface WallVisualization3DProps {
1112
components: WallComponent[];
@@ -15,10 +16,6 @@ interface WallVisualization3DProps {
1516
dewPoint: number;
1617
}
1718

18-
export const getComponentColor = (material: string) => {
19-
const materialInfo = commonMaterials.find(m => m.name === material)
20-
return materialInfo ? materialInfo.color : "#95a5a6"
21-
}
2219

2320
function Studs({ config, depth }: { config: StudWallConfig, depth: number }) {
2421
const studDepth = config.studDepth / 1000;
@@ -246,4 +243,4 @@ export function WallVisualization3D({ components, studWallConfig, insideTemp, ou
246243
</div>
247244
</div>
248245
)
249-
}
246+
}

app/components/house-sample/components/WallSection.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import { useMemo } from "react";
44
import * as THREE from "three";
55
import { WallComponent } from "@/app/components/calculator/types";
6-
import { getComponentColor } from "@/app/components/calculator/WallVisualization3D";
6+
import { getComponentColor } from "@/app/components/calculator/utils/visualizationHelpers"; // Corrected import path
77

88
interface WallSectionProps {
99
position: [number, number, number];
@@ -115,4 +115,4 @@ export function WallSection({
115115
}
116116

117117
return <group position={position} rotation={rotation}>{wallComponents}</group>;
118-
}
118+
}

app/components/house-sample/utils/houseCalculations.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,3 @@ export function calculateRoofHypotenuse(angle: number, width: number): number {
3333
export function calculateGableWallHeight(baseWallHeight: number, roofHeight: number): number {
3434
return baseWallHeight + roofHeight;
3535
}
36-
37-
/**
38-
* Converts dimensions from millimeters to meters
39-
* @param mm Dimension in millimeters
40-
* @returns Dimension in meters
41-
*/
42-
export function mmToM(mm: number): number {
43-
return mm / 1000;
44-
}

app/page.tsx

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,27 @@
1-
'use client';
1+
import Link from 'next/link';
2+
import Header from './components/Header'; // Keep header for now
23

3-
import Header from "./components/Header";
4-
import Calculator from "./components/calculator/Calculator";
5-
import { WallCalculatorProvider } from "./components/calculator/context/WallCalculatorContext";
6-
7-
export default function Home() {
4+
export default function StartPage() {
85
return (
96
<div className="min-h-screen flex flex-col">
107
<Header />
11-
<WallCalculatorProvider>
12-
<Calculator />
13-
</WallCalculatorProvider>
8+
<main className="flex-grow flex flex-col items-center justify-center p-6">
9+
<h1 className="text-4xl font-bold mb-4">Welcome to Wall U-Value Calculator</h1>
10+
<p className="text-lg mb-8 text-center max-w-prose">
11+
Calculate the thermal transmittance (U-value) of your wall constructions, visualize temperature gradients, and check for potential condensation issues.
12+
</p>
13+
<Link href="/calculator" legacyBehavior>
14+
<a className="px-6 py-3 bg-blue-600 text-white rounded-md hover:bg-blue-700 transition-colors text-lg font-semibold">
15+
Go to Calculator
16+
</a>
17+
</Link>
18+
{/* Optional: Add link to house sample page if desired */}
19+
{/* <Link href="/houseSamplePage" legacyBehavior>
20+
<a className="mt-4 px-6 py-3 bg-green-600 text-white rounded-md hover:bg-green-700 transition-colors text-lg font-semibold">
21+
View House Sample
22+
</a>
23+
</Link> */}
24+
</main>
1425
</div>
1526
);
1627
}

bun.lockb

299 KB
Binary file not shown.

lib/utils.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,12 @@ import { twMerge } from "tailwind-merge"
44
export function cn(...inputs: ClassValue[]) {
55
return twMerge(clsx(inputs))
66
}
7+
8+
/**
9+
* Converts dimensions from millimeters to meters
10+
* @param mm Dimension in millimeters
11+
* @returns Dimension in meters
12+
*/
13+
export function mmToM(mm: number): number {
14+
return mm / 1000;
15+
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"version": "0.1.0",
44
"private": true,
55
"scripts": {
6-
"dev": "next dev",
6+
"dev": "next dev --turbopack",
77
"build": "next build",
88
"start": "next start",
99
"lint": "next lint"

0 commit comments

Comments
 (0)