Upload 8 files
Browse files- .env.local +1 -0
- .gitignore +24 -0
- README.md +20 -5
- index.html +44 -0
- index.tsx +822 -0
- metadata.json +5 -0
- package.json +22 -0
- tsconfig.json +29 -0
.env.local
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
GEMINI_API_KEY=PLACEHOLDER_API_KEY
|
.gitignore
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Logs
|
| 2 |
+
logs
|
| 3 |
+
*.log
|
| 4 |
+
npm-debug.log*
|
| 5 |
+
yarn-debug.log*
|
| 6 |
+
yarn-error.log*
|
| 7 |
+
pnpm-debug.log*
|
| 8 |
+
lerna-debug.log*
|
| 9 |
+
|
| 10 |
+
node_modules
|
| 11 |
+
dist
|
| 12 |
+
dist-ssr
|
| 13 |
+
*.local
|
| 14 |
+
|
| 15 |
+
# Editor directories and files
|
| 16 |
+
.vscode/*
|
| 17 |
+
!.vscode/extensions.json
|
| 18 |
+
.idea
|
| 19 |
+
.DS_Store
|
| 20 |
+
*.suo
|
| 21 |
+
*.ntvs*
|
| 22 |
+
*.njsproj
|
| 23 |
+
*.sln
|
| 24 |
+
*.sw?
|
README.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<div align="center">
|
| 2 |
+
<img width="1200" height="475" alt="GHBanner" src="https://github.com/user-attachments/assets/0aa67016-6eaf-458a-adb2-6e31a0763ed6" />
|
| 3 |
+
</div>
|
| 4 |
+
|
| 5 |
+
# Run and deploy your AI Studio app
|
| 6 |
+
|
| 7 |
+
This contains everything you need to run your app locally.
|
| 8 |
+
|
| 9 |
+
View your app in AI Studio: https://ai.studio/apps/drive/1hPm592sg0tb4Wq4kBBTguV4nfHOcuaTm
|
| 10 |
+
|
| 11 |
+
## Run Locally
|
| 12 |
+
|
| 13 |
+
**Prerequisites:** Node.js
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
1. Install dependencies:
|
| 17 |
+
`npm install`
|
| 18 |
+
2. Set the `GEMINI_API_KEY` in [.env.local](.env.local) to your Gemini API key
|
| 19 |
+
3. Run the app:
|
| 20 |
+
`npm run dev`
|
index.html
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8" />
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
| 6 |
+
<title>Structural Design App</title>
|
| 7 |
+
<script src="https://cdn.tailwindcss.com"></script>
|
| 8 |
+
<style>
|
| 9 |
+
body {
|
| 10 |
+
background-color: #f3f4f6;
|
| 11 |
+
}
|
| 12 |
+
/* Custom scrollbar for a cleaner look */
|
| 13 |
+
::-webkit-scrollbar {
|
| 14 |
+
width: 8px;
|
| 15 |
+
height: 8px;
|
| 16 |
+
}
|
| 17 |
+
::-webkit-scrollbar-track {
|
| 18 |
+
background: #f1f1f1;
|
| 19 |
+
}
|
| 20 |
+
::-webkit-scrollbar-thumb {
|
| 21 |
+
background: #c1c1c1;
|
| 22 |
+
border-radius: 4px;
|
| 23 |
+
}
|
| 24 |
+
::-webkit-scrollbar-thumb:hover {
|
| 25 |
+
background: #a8a8a8;
|
| 26 |
+
}
|
| 27 |
+
</style>
|
| 28 |
+
<script type="importmap">
|
| 29 |
+
{
|
| 30 |
+
"imports": {
|
| 31 |
+
"react/": "https://esm.sh/react@^19.2.3/",
|
| 32 |
+
"react": "https://esm.sh/react@^19.2.3",
|
| 33 |
+
"react-dom/": "https://esm.sh/react-dom@^19.2.3/",
|
| 34 |
+
"@google/genai": "https://esm.sh/@google/genai@^1.34.0"
|
| 35 |
+
}
|
| 36 |
+
}
|
| 37 |
+
</script>
|
| 38 |
+
<link rel="stylesheet" href="/index.css">
|
| 39 |
+
</head>
|
| 40 |
+
<body>
|
| 41 |
+
<div id="root"></div>
|
| 42 |
+
<script type="module" src="/index.tsx"></script>
|
| 43 |
+
</body>
|
| 44 |
+
</html>
|
index.tsx
ADDED
|
@@ -0,0 +1,822 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import React, { useState, useEffect } from "react";
|
| 2 |
+
import { createRoot } from "react-dom/client";
|
| 3 |
+
import { GoogleGenAI } from "@google/genai";
|
| 4 |
+
|
| 5 |
+
// --- Types & Interfaces ---
|
| 6 |
+
|
| 7 |
+
type DesignType = 'one-way-slab' | 'two-way-slab' | 'beam' | 'column';
|
| 8 |
+
type DesignCode = 'ACI-318' | 'Eurocode-2' | 'IS-456';
|
| 9 |
+
|
| 10 |
+
interface BarType {
|
| 11 |
+
name: string;
|
| 12 |
+
dia: number; // inches
|
| 13 |
+
area: number; // sq inches
|
| 14 |
+
}
|
| 15 |
+
|
| 16 |
+
// Imperial Bar Sizes (ASTM A615)
|
| 17 |
+
const IMPERIAL_BARS: BarType[] = [
|
| 18 |
+
{ name: '#3', dia: 0.375, area: 0.11 },
|
| 19 |
+
{ name: '#4', dia: 0.500, area: 0.20 },
|
| 20 |
+
{ name: '#5', dia: 0.625, area: 0.31 },
|
| 21 |
+
{ name: '#6', dia: 0.750, area: 0.44 },
|
| 22 |
+
{ name: '#7', dia: 0.875, area: 0.60 },
|
| 23 |
+
{ name: '#8', dia: 1.000, area: 0.79 },
|
| 24 |
+
{ name: '#9', dia: 1.128, area: 1.00 },
|
| 25 |
+
{ name: '#10', dia: 1.270, area: 1.27 },
|
| 26 |
+
{ name: '#11', dia: 1.410, area: 1.56 },
|
| 27 |
+
{ name: '#14', dia: 1.693, area: 2.25 },
|
| 28 |
+
{ name: '#18', dia: 2.257, area: 4.00 },
|
| 29 |
+
];
|
| 30 |
+
|
| 31 |
+
interface DesignInputs {
|
| 32 |
+
span: number; // ft
|
| 33 |
+
width: number; // in
|
| 34 |
+
depth: number; // in
|
| 35 |
+
cover: number; // in
|
| 36 |
+
fc: number; // psi
|
| 37 |
+
fy: number; // psi
|
| 38 |
+
deadLoad: number; // ksf (slabs), klf (beams), kips (cols)
|
| 39 |
+
liveLoad: number; // ksf (slabs), klf (beams), kips (cols)
|
| 40 |
+
barIndex: number; // Index in IMPERIAL_BARS
|
| 41 |
+
spanY?: number; // ft (for two-way slab)
|
| 42 |
+
providedDevLength?: number; // in
|
| 43 |
+
dlFactor: number;
|
| 44 |
+
llFactor: number;
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
interface DesignResults {
|
| 48 |
+
mu?: number; // k-ft
|
| 49 |
+
pu?: number; // kips
|
| 50 |
+
asRequired: number; // in²
|
| 51 |
+
barCount?: number;
|
| 52 |
+
spacing?: number; // in
|
| 53 |
+
status: 'ok' | 'fail' | 'warning';
|
| 54 |
+
message: string;
|
| 55 |
+
codeUsed: string;
|
| 56 |
+
requiredDevLength: number; // in
|
| 57 |
+
devLengthStatus: 'ok' | 'short';
|
| 58 |
+
}
|
| 59 |
+
|
| 60 |
+
interface LoadCombOption {
|
| 61 |
+
id: string;
|
| 62 |
+
name: string;
|
| 63 |
+
dl: number;
|
| 64 |
+
ll: number;
|
| 65 |
+
}
|
| 66 |
+
|
| 67 |
+
// --- Constants ---
|
| 68 |
+
|
| 69 |
+
const DEFAULT_INPUTS: Record<DesignType, DesignInputs> = {
|
| 70 |
+
'one-way-slab': { span: 12, width: 12, depth: 6, cover: 0.75, fc: 4000, fy: 60000, deadLoad: 0.100, liveLoad: 0.050, barIndex: 1, providedDevLength: 24, dlFactor: 1.2, llFactor: 1.6 },
|
| 71 |
+
'two-way-slab': { span: 15, spanY: 18, width: 12, depth: 7, cover: 0.75, fc: 4000, fy: 60000, deadLoad: 0.120, liveLoad: 0.060, barIndex: 1, providedDevLength: 24, dlFactor: 1.2, llFactor: 1.6 },
|
| 72 |
+
'beam': { span: 20, width: 12, depth: 20, cover: 1.5, fc: 4000, fy: 60000, deadLoad: 1.0, liveLoad: 0.8, barIndex: 4, providedDevLength: 36, dlFactor: 1.2, llFactor: 1.6 },
|
| 73 |
+
'column': { span: 10, width: 16, depth: 16, cover: 1.5, fc: 5000, fy: 60000, deadLoad: 200, liveLoad: 100, barIndex: 5, providedDevLength: 30, dlFactor: 1.2, llFactor: 1.6 },
|
| 74 |
+
};
|
| 75 |
+
|
| 76 |
+
// --- Unit Conversions ---
|
| 77 |
+
const psiToMPa = (psi: number) => psi * 0.00689476;
|
| 78 |
+
const inToMm = (inch: number) => inch * 25.4;
|
| 79 |
+
const mm2ToIn2 = (mm2: number) => mm2 / 645.16;
|
| 80 |
+
|
| 81 |
+
// --- Calculation Logic ---
|
| 82 |
+
|
| 83 |
+
const calculateDevelopmentLength = (code: DesignCode, fc: number, fy: number, bar: BarType): number => {
|
| 84 |
+
if (code === 'ACI-318') {
|
| 85 |
+
const lambda = 1.0;
|
| 86 |
+
const psi_t = 1.0;
|
| 87 |
+
const psi_e = 1.0;
|
| 88 |
+
|
| 89 |
+
let factor = 0;
|
| 90 |
+
if (bar.dia <= 0.75) {
|
| 91 |
+
factor = (fy * psi_t * psi_e) / (25 * lambda * Math.sqrt(fc));
|
| 92 |
+
} else {
|
| 93 |
+
factor = (fy * psi_t * psi_e) / (20 * lambda * Math.sqrt(fc));
|
| 94 |
+
}
|
| 95 |
+
|
| 96 |
+
const ld = factor * bar.dia;
|
| 97 |
+
return Math.max(ld, 12);
|
| 98 |
+
} else if (code === 'Eurocode-2') {
|
| 99 |
+
const fck = psiToMPa(fc);
|
| 100 |
+
const fyk = psiToMPa(fy);
|
| 101 |
+
const db = inToMm(bar.dia);
|
| 102 |
+
const fctm = 0.3 * Math.pow(fck, 2/3);
|
| 103 |
+
const fctd = fctm / 1.5;
|
| 104 |
+
const n1 = 1.0;
|
| 105 |
+
const n2 = 1.0;
|
| 106 |
+
const fbd = 2.25 * n1 * n2 * fctd;
|
| 107 |
+
const fyd = fyk / 1.15;
|
| 108 |
+
const sigma_sd = fyd;
|
| 109 |
+
const lb_rqd = (db / 4) * (sigma_sd / fbd);
|
| 110 |
+
return lb_rqd / 25.4;
|
| 111 |
+
} else if (code === 'IS-456') {
|
| 112 |
+
const fck = psiToMPa(fc);
|
| 113 |
+
const fyk = psiToMPa(fy);
|
| 114 |
+
const db = inToMm(bar.dia);
|
| 115 |
+
let tau_bd = 1.2;
|
| 116 |
+
if (fck >= 40) tau_bd = 1.9;
|
| 117 |
+
else if (fck >= 35) tau_bd = 1.7;
|
| 118 |
+
else if (fck >= 30) tau_bd = 1.5;
|
| 119 |
+
else if (fck >= 25) tau_bd = 1.4;
|
| 120 |
+
tau_bd = tau_bd * 1.6;
|
| 121 |
+
const sigma_s = 0.87 * fyk;
|
| 122 |
+
const Ld = (db * sigma_s) / (4 * tau_bd);
|
| 123 |
+
return Ld / 25.4;
|
| 124 |
+
}
|
| 125 |
+
return 0;
|
| 126 |
+
};
|
| 127 |
+
|
| 128 |
+
const calculateDesign = (type: DesignType, inputs: DesignInputs, code: DesignCode): DesignResults => {
|
| 129 |
+
const { span, width, depth, cover, fc, fy, deadLoad, liveLoad, barIndex, providedDevLength, dlFactor, llFactor } = inputs;
|
| 130 |
+
const bar = IMPERIAL_BARS[barIndex];
|
| 131 |
+
|
| 132 |
+
const d = depth - cover - bar.dia / 2;
|
| 133 |
+
|
| 134 |
+
let result: DesignResults = {
|
| 135 |
+
asRequired: 0,
|
| 136 |
+
status: 'ok',
|
| 137 |
+
message: '',
|
| 138 |
+
codeUsed: code,
|
| 139 |
+
requiredDevLength: 0,
|
| 140 |
+
devLengthStatus: 'ok'
|
| 141 |
+
};
|
| 142 |
+
|
| 143 |
+
result.requiredDevLength = calculateDevelopmentLength(code, fc, fy, bar);
|
| 144 |
+
|
| 145 |
+
if (providedDevLength && providedDevLength < result.requiredDevLength) {
|
| 146 |
+
result.devLengthStatus = 'short';
|
| 147 |
+
}
|
| 148 |
+
|
| 149 |
+
// --- Flexure/Axial Calculation with Custom Load Factors ---
|
| 150 |
+
// wu is factored load per unit (ksf, klf, or kips)
|
| 151 |
+
const wu = dlFactor * deadLoad + llFactor * liveLoad;
|
| 152 |
+
|
| 153 |
+
if (type === 'one-way-slab' || type === 'beam') {
|
| 154 |
+
let w_line_load = wu;
|
| 155 |
+
if (type === 'one-way-slab') {
|
| 156 |
+
w_line_load = wu * (width / 12);
|
| 157 |
+
}
|
| 158 |
+
|
| 159 |
+
const muKft = (w_line_load * Math.pow(span, 2)) / 8;
|
| 160 |
+
result.mu = muKft;
|
| 161 |
+
const muLbIn = muKft * 12000;
|
| 162 |
+
|
| 163 |
+
let requiredAs = 0;
|
| 164 |
+
|
| 165 |
+
if (code === 'ACI-318') {
|
| 166 |
+
const phi = 0.9;
|
| 167 |
+
let a = 0.2 * d;
|
| 168 |
+
for(let i=0; i<5; i++) {
|
| 169 |
+
requiredAs = muLbIn / (phi * fy * (d - a/2));
|
| 170 |
+
a = (requiredAs * fy) / (0.85 * fc * width);
|
| 171 |
+
}
|
| 172 |
+
} else {
|
| 173 |
+
const muNmm = (muKft * 1.35582) * 1e6;
|
| 174 |
+
const d_mm = inToMm(d);
|
| 175 |
+
const fyk = psiToMPa(fy);
|
| 176 |
+
|
| 177 |
+
let asReqMm2 = 0;
|
| 178 |
+
if (code === 'Eurocode-2') {
|
| 179 |
+
const fyd = fyk / 1.15;
|
| 180 |
+
asReqMm2 = muNmm / (fyd * 0.9 * d_mm);
|
| 181 |
+
} else {
|
| 182 |
+
const fyd = 0.87 * fyk;
|
| 183 |
+
asReqMm2 = muNmm / (fyd * 0.9 * d_mm);
|
| 184 |
+
}
|
| 185 |
+
requiredAs = mm2ToIn2(asReqMm2);
|
| 186 |
+
}
|
| 187 |
+
|
| 188 |
+
let asMin = 0;
|
| 189 |
+
if (code === 'ACI-318') {
|
| 190 |
+
const min1 = (3 * Math.sqrt(fc) * width * d) / fy;
|
| 191 |
+
const min2 = (200 * width * d) / fy;
|
| 192 |
+
asMin = Math.max(min1, min2);
|
| 193 |
+
if (type === 'one-way-slab') asMin = 0.0018 * width * depth;
|
| 194 |
+
} else {
|
| 195 |
+
asMin = 0.0015 * width * depth;
|
| 196 |
+
}
|
| 197 |
+
|
| 198 |
+
const finalAs = Math.max(requiredAs, asMin);
|
| 199 |
+
result.asRequired = finalAs;
|
| 200 |
+
|
| 201 |
+
if (type === 'one-way-slab') {
|
| 202 |
+
let spacing = (bar.area / finalAs) * width;
|
| 203 |
+
const maxSpacing = Math.min(3 * depth, 18);
|
| 204 |
+
spacing = Math.min(spacing, maxSpacing);
|
| 205 |
+
result.spacing = Math.floor(spacing);
|
| 206 |
+
result.message = `Use ${bar.name} @ ${result.spacing}" c/c`;
|
| 207 |
+
} else {
|
| 208 |
+
const numBars = Math.ceil(finalAs / bar.area);
|
| 209 |
+
result.barCount = numBars;
|
| 210 |
+
result.message = `Use ${numBars} ${bar.name} Bars (Bottom)`;
|
| 211 |
+
|
| 212 |
+
const stirrup = 0.375;
|
| 213 |
+
const minGap = Math.max(1, bar.dia);
|
| 214 |
+
const reqWidth = 2*cover + 2*stirrup + numBars*bar.dia + (numBars-1)*minGap;
|
| 215 |
+
|
| 216 |
+
if (reqWidth > width) {
|
| 217 |
+
result.status = 'warning';
|
| 218 |
+
result.message += ` (Layering required)`;
|
| 219 |
+
}
|
| 220 |
+
}
|
| 221 |
+
|
| 222 |
+
} else if (type === 'two-way-slab') {
|
| 223 |
+
const ly = inputs.spanY || span;
|
| 224 |
+
const lx = Math.min(span, ly);
|
| 225 |
+
const coeff = 0.06;
|
| 226 |
+
const w_ksf = wu;
|
| 227 |
+
const muKftPerFt = coeff * w_ksf * Math.pow(lx, 2);
|
| 228 |
+
|
| 229 |
+
result.mu = muKftPerFt;
|
| 230 |
+
const muLbIn = muKftPerFt * 12000;
|
| 231 |
+
|
| 232 |
+
const phi = 0.9;
|
| 233 |
+
const approxAs = muLbIn / (phi * fy * 0.9 * d);
|
| 234 |
+
const asMin = 0.0018 * 12 * depth;
|
| 235 |
+
|
| 236 |
+
const finalAs = Math.max(approxAs, asMin);
|
| 237 |
+
result.asRequired = finalAs;
|
| 238 |
+
|
| 239 |
+
let spacing = (bar.area / finalAs) * 12;
|
| 240 |
+
spacing = Math.min(spacing, 2*depth, 18);
|
| 241 |
+
result.spacing = Math.floor(spacing);
|
| 242 |
+
result.message = `Use ${bar.name} @ ${result.spacing}" c/c EW`;
|
| 243 |
+
|
| 244 |
+
} else if (type === 'column') {
|
| 245 |
+
result.pu = wu;
|
| 246 |
+
const Ag = width * depth;
|
| 247 |
+
|
| 248 |
+
let reqAst = 0;
|
| 249 |
+
if (code === 'ACI-318') {
|
| 250 |
+
const phi = 0.65;
|
| 251 |
+
const alpha = 0.80;
|
| 252 |
+
const term = wu / (phi * alpha);
|
| 253 |
+
reqAst = (term*1000 - 0.85*fc*Ag) / (fy - 0.85*fc);
|
| 254 |
+
} else {
|
| 255 |
+
const P_lb = wu * 1000;
|
| 256 |
+
reqAst = (P_lb - 0.4*fc*Ag) / (0.67*fy - 0.4*fc);
|
| 257 |
+
}
|
| 258 |
+
|
| 259 |
+
const minAst = 0.01 * Ag;
|
| 260 |
+
const maxAst = 0.04 * Ag;
|
| 261 |
+
|
| 262 |
+
reqAst = Math.max(reqAst, minAst);
|
| 263 |
+
|
| 264 |
+
if (reqAst > maxAst) {
|
| 265 |
+
result.status = 'fail';
|
| 266 |
+
result.message = 'Section too small (>4% Steel)';
|
| 267 |
+
result.asRequired = reqAst;
|
| 268 |
+
} else {
|
| 269 |
+
result.asRequired = reqAst;
|
| 270 |
+
let numBars = Math.ceil(reqAst / bar.area);
|
| 271 |
+
numBars = Math.max(numBars, 4);
|
| 272 |
+
if (numBars % 2 !== 0) numBars++;
|
| 273 |
+
result.barCount = numBars;
|
| 274 |
+
result.message = `Use ${numBars} ${bar.name} Bars`;
|
| 275 |
+
}
|
| 276 |
+
}
|
| 277 |
+
|
| 278 |
+
return result;
|
| 279 |
+
};
|
| 280 |
+
|
| 281 |
+
|
| 282 |
+
// --- Schematic Component ---
|
| 283 |
+
|
| 284 |
+
const SchematicView = ({ type, width, depth, cover, barCount, barIndex, spacing, span, spanY }:
|
| 285 |
+
{ type: DesignType, width: number, depth: number, cover: number, barCount?: number, barIndex: number, spacing?: number, span: number, spanY?: number }) => {
|
| 286 |
+
|
| 287 |
+
const bar = IMPERIAL_BARS[barIndex];
|
| 288 |
+
const scale = 180 / Math.max(width, depth);
|
| 289 |
+
const svgWidth = 280;
|
| 290 |
+
const drawWidth = type.includes('slab') ? 240 : width * scale;
|
| 291 |
+
const drawDepth = type.includes('slab') ? depth * (240/(width || 12)) : depth * scale;
|
| 292 |
+
const slabVisualWidth = 240;
|
| 293 |
+
const slabVisualDepth = type.includes('slab') ? depth * (240 / 12) * 0.6 : 0;
|
| 294 |
+
const concreteColor = "#f1f5f9"; // Lighter for glass UI contrast
|
| 295 |
+
const steelColor = "#ef4444";
|
| 296 |
+
const stirrupColor = "#94a3b8";
|
| 297 |
+
|
| 298 |
+
const [show, setShow] = useState(false);
|
| 299 |
+
useEffect(() => {
|
| 300 |
+
setShow(false);
|
| 301 |
+
setTimeout(() => setShow(true), 100);
|
| 302 |
+
}, [type, width, depth, barCount, spacing, barIndex]);
|
| 303 |
+
|
| 304 |
+
if (type === 'beam' || type === 'column') {
|
| 305 |
+
const bars = [];
|
| 306 |
+
if (barCount) {
|
| 307 |
+
if (type === 'beam') {
|
| 308 |
+
const availW = drawWidth - 2*cover*scale;
|
| 309 |
+
const gap = barCount > 1 ? availW / (barCount - 1) : 0;
|
| 310 |
+
for(let i=0; i<barCount; i++) {
|
| 311 |
+
bars.push(<circle key={i} cx={cover*scale + i*gap} cy={drawDepth - cover*scale} r={Math.max(bar.dia*scale/2, 3)} fill={steelColor} className={`transition-all duration-700 ease-out ${show ? 'opacity-100 scale-100' : 'opacity-0 scale-0'}`} style={{transitionDelay: `${i*100}ms`, transformBox: 'fill-box', transformOrigin: 'center'}} />);
|
| 312 |
+
}
|
| 313 |
+
} else {
|
| 314 |
+
const inset = cover*scale;
|
| 315 |
+
const w = drawWidth - 2*inset;
|
| 316 |
+
const h = drawDepth - 2*inset;
|
| 317 |
+
bars.push(<circle key="c1" cx={inset} cy={inset} r={3} fill={steelColor} className={`transition-all duration-500 ${show ? 'opacity-100' : 'opacity-0'}`} />);
|
| 318 |
+
bars.push(<circle key="c2" cx={inset+w} cy={inset} r={3} fill={steelColor} className={`transition-all duration-500 ${show ? 'opacity-100' : 'opacity-0'}`} />);
|
| 319 |
+
bars.push(<circle key="c3" cx={inset+w} cy={inset+h} r={3} fill={steelColor} className={`transition-all duration-500 ${show ? 'opacity-100' : 'opacity-0'}`} />);
|
| 320 |
+
bars.push(<circle key="c4" cx={inset} cy={inset+h} r={3} fill={steelColor} className={`transition-all duration-500 ${show ? 'opacity-100' : 'opacity-0'}`} />);
|
| 321 |
+
|
| 322 |
+
const rem = Math.max(0, barCount - 4);
|
| 323 |
+
if (rem > 0) bars.push(<text key="t" x={drawWidth/2} y={drawDepth/2} textAnchor="middle" dy=".3em" fontSize="10" fill={stirrupColor}>+{rem} bars</text>);
|
| 324 |
+
}
|
| 325 |
+
}
|
| 326 |
+
|
| 327 |
+
return (
|
| 328 |
+
<div className="flex flex-col items-center justify-center h-full animate-fadeInUp">
|
| 329 |
+
<svg width={svgWidth} height={drawDepth + 60} viewBox={`0 0 ${svgWidth} ${drawDepth + 60}`} className="transition-all duration-500 drop-shadow-lg">
|
| 330 |
+
<g transform={`translate(${(svgWidth - drawWidth)/2}, 30)`}>
|
| 331 |
+
<rect x="0" y="0" width={drawWidth} height={drawDepth} fill={concreteColor} stroke="#cbd5e1" strokeWidth="2" rx="4" />
|
| 332 |
+
<rect x={cover*scale} y={cover*scale} width={drawWidth - 2*cover*scale} height={drawDepth - 2*cover*scale} fill="none" stroke={stirrupColor} strokeWidth="1.5" rx="2" />
|
| 333 |
+
{bars}
|
| 334 |
+
<text x="-10" y={drawDepth/2} className="text-[10px]" textAnchor="end" fill="#64748b">{depth}"</text>
|
| 335 |
+
<text x={drawWidth/2} y={drawDepth + 15} className="text-[10px]" textAnchor="middle" fill="#64748b">{width}"</text>
|
| 336 |
+
</g>
|
| 337 |
+
</svg>
|
| 338 |
+
</div>
|
| 339 |
+
);
|
| 340 |
+
}
|
| 341 |
+
|
| 342 |
+
if (type.includes('slab')) {
|
| 343 |
+
const visualSp = spacing ? spacing * (slabVisualWidth / 12) : 20;
|
| 344 |
+
const numBars = Math.floor(slabVisualWidth / Math.max(visualSp, 10));
|
| 345 |
+
const bars = [];
|
| 346 |
+
for(let i=0; i<numBars; i++) {
|
| 347 |
+
bars.push(<circle key={i} cx={visualSp/2 + i*visualSp} cy={slabVisualDepth - cover*(slabVisualDepth/depth)} r={2.5} fill={steelColor} className={`transition-all duration-500 ${show ? 'opacity-100' : 'opacity-0'}`} style={{transitionDelay: `${i*30}ms`}}/>);
|
| 348 |
+
}
|
| 349 |
+
|
| 350 |
+
return (
|
| 351 |
+
<div className="flex flex-col items-center justify-center h-full animate-fadeInUp">
|
| 352 |
+
<svg width={slabVisualWidth + 40} height={slabVisualDepth + 60} className="drop-shadow-lg">
|
| 353 |
+
<g transform="translate(20, 30)">
|
| 354 |
+
<rect x="0" y="0" width={slabVisualWidth} height={slabVisualDepth} fill={concreteColor} stroke="#cbd5e1" strokeWidth="2" rx="4" />
|
| 355 |
+
{bars}
|
| 356 |
+
<text x={slabVisualWidth/2} y={slabVisualDepth + 15} className="text-[10px]" textAnchor="middle" fill="#64748b">12" Strip</text>
|
| 357 |
+
<text x="-5" y={slabVisualDepth/2} className="text-[10px]" textAnchor="end" fill="#64748b">{depth}"</text>
|
| 358 |
+
</g>
|
| 359 |
+
</svg>
|
| 360 |
+
</div>
|
| 361 |
+
)
|
| 362 |
+
}
|
| 363 |
+
|
| 364 |
+
return null;
|
| 365 |
+
};
|
| 366 |
+
|
| 367 |
+
// --- Components ---
|
| 368 |
+
|
| 369 |
+
const GlobalStyles = () => (
|
| 370 |
+
<style>{`
|
| 371 |
+
@keyframes fadeInUp {
|
| 372 |
+
from { opacity: 0; transform: translateY(10px) scale(0.98); }
|
| 373 |
+
to { opacity: 1; transform: translateY(0) scale(1); }
|
| 374 |
+
}
|
| 375 |
+
.animate-fadeInUp {
|
| 376 |
+
animation: fadeInUp 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
|
| 377 |
+
}
|
| 378 |
+
@keyframes gradientShift {
|
| 379 |
+
0% { background-position: 0% 50%; }
|
| 380 |
+
50% { background-position: 100% 50%; }
|
| 381 |
+
100% { background-position: 0% 50%; }
|
| 382 |
+
}
|
| 383 |
+
.animate-gradient {
|
| 384 |
+
background-size: 200% 200%;
|
| 385 |
+
animation: gradientShift 15s ease infinite;
|
| 386 |
+
}
|
| 387 |
+
.glass-panel {
|
| 388 |
+
background: rgba(255, 255, 255, 0.25);
|
| 389 |
+
backdrop-filter: blur(12px);
|
| 390 |
+
-webkit-backdrop-filter: blur(12px);
|
| 391 |
+
border: 1px solid rgba(255, 255, 255, 0.3);
|
| 392 |
+
box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
|
| 393 |
+
}
|
| 394 |
+
.glass-input {
|
| 395 |
+
background: rgba(255, 255, 255, 0.3);
|
| 396 |
+
backdrop-filter: blur(4px);
|
| 397 |
+
border: 1px solid rgba(255, 255, 255, 0.3);
|
| 398 |
+
}
|
| 399 |
+
.glass-input:focus-within {
|
| 400 |
+
background: rgba(255, 255, 255, 0.6);
|
| 401 |
+
border-color: rgba(255, 255, 255, 0.8);
|
| 402 |
+
}
|
| 403 |
+
.glass-sidebar {
|
| 404 |
+
background: rgba(15, 23, 42, 0.65);
|
| 405 |
+
backdrop-filter: blur(20px);
|
| 406 |
+
border-right: 1px solid rgba(255, 255, 255, 0.05);
|
| 407 |
+
}
|
| 408 |
+
`}</style>
|
| 409 |
+
);
|
| 410 |
+
|
| 411 |
+
const InputField = ({ label, value, onChange, unit, readOnly = false, highlight = false, small = false }: { label: string, value: number, onChange: (v: number) => void, unit?: string, readOnly?: boolean, highlight?: boolean, small?: boolean }) => (
|
| 412 |
+
<div className="flex flex-col group">
|
| 413 |
+
<label className={`font-bold text-slate-600 uppercase tracking-wide mb-1 truncate group-hover:text-blue-600 transition-colors duration-300 ${small ? 'text-[9px]' : 'text-[10px]'}`} title={label}>{label}</label>
|
| 414 |
+
<div className={`flex items-center rounded-xl glass-input transition-all duration-300 transform origin-left
|
| 415 |
+
${highlight ? 'border-amber-400 ring-2 ring-amber-100' : ''}
|
| 416 |
+
${!readOnly ? 'group-hover:-translate-y-0.5 group-hover:shadow-md focus-within:ring-2 focus-within:ring-blue-400 focus-within:-translate-y-1 focus-within:shadow-lg' : ''}
|
| 417 |
+
`}>
|
| 418 |
+
<input
|
| 419 |
+
type="number"
|
| 420 |
+
readOnly={readOnly}
|
| 421 |
+
className={`w-full bg-transparent px-3 py-2 text-sm text-slate-800 font-medium focus:outline-none ${readOnly ? 'cursor-not-allowed text-slate-500' : ''}`}
|
| 422 |
+
value={value}
|
| 423 |
+
onChange={(e) => onChange(parseFloat(e.target.value) || 0)}
|
| 424 |
+
/>
|
| 425 |
+
{unit && <span className="mr-3 text-slate-500 font-medium text-[10px] select-none">{unit}</span>}
|
| 426 |
+
</div>
|
| 427 |
+
</div>
|
| 428 |
+
);
|
| 429 |
+
|
| 430 |
+
const App = () => {
|
| 431 |
+
const [activeType, setActiveType] = useState<DesignType>('one-way-slab');
|
| 432 |
+
const [designCode, setDesignCode] = useState<DesignCode>('ACI-318');
|
| 433 |
+
const [inputs, setInputs] = useState<DesignInputs>(DEFAULT_INPUTS['one-way-slab']);
|
| 434 |
+
const [result, setResult] = useState<DesignResults | null>(null);
|
| 435 |
+
const [aiAnalysis, setAiAnalysis] = useState<string>('');
|
| 436 |
+
const [isAnalyzing, setIsAnalyzing] = useState(false);
|
| 437 |
+
const [selectedLoadComb, setSelectedLoadComb] = useState<string>('code');
|
| 438 |
+
|
| 439 |
+
useEffect(() => {
|
| 440 |
+
// Update Load Factors when Code Changes if in "Code" mode
|
| 441 |
+
if (selectedLoadComb === 'code') {
|
| 442 |
+
if (designCode === 'ACI-318') {
|
| 443 |
+
setInputs(prev => ({...prev, dlFactor: 1.2, llFactor: 1.6}));
|
| 444 |
+
} else if (designCode === 'Eurocode-2') {
|
| 445 |
+
setInputs(prev => ({...prev, dlFactor: 1.35, llFactor: 1.5}));
|
| 446 |
+
} else if (designCode === 'IS-456') {
|
| 447 |
+
setInputs(prev => ({...prev, dlFactor: 1.5, llFactor: 1.5}));
|
| 448 |
+
}
|
| 449 |
+
} else if (selectedLoadComb === '1.4dl') {
|
| 450 |
+
setInputs(prev => ({...prev, dlFactor: 1.4, llFactor: 0}));
|
| 451 |
+
}
|
| 452 |
+
}, [designCode, selectedLoadComb]);
|
| 453 |
+
|
| 454 |
+
useEffect(() => {
|
| 455 |
+
setResult(calculateDesign(activeType, inputs, designCode));
|
| 456 |
+
setAiAnalysis('');
|
| 457 |
+
}, [inputs, activeType, designCode]);
|
| 458 |
+
|
| 459 |
+
const handleTypeChange = (type: DesignType) => {
|
| 460 |
+
setActiveType(type);
|
| 461 |
+
setInputs(prev => ({ ...DEFAULT_INPUTS[type], dlFactor: prev.dlFactor, llFactor: prev.llFactor }));
|
| 462 |
+
};
|
| 463 |
+
|
| 464 |
+
const handleInputChange = (key: keyof DesignInputs, value: number) => {
|
| 465 |
+
setInputs(prev => ({ ...prev, [key]: value }));
|
| 466 |
+
};
|
| 467 |
+
|
| 468 |
+
const runAiAnalysis = async () => {
|
| 469 |
+
if (!result) return;
|
| 470 |
+
setIsAnalyzing(true);
|
| 471 |
+
setAiAnalysis('');
|
| 472 |
+
|
| 473 |
+
try {
|
| 474 |
+
const ai = new GoogleGenAI({ apiKey: process.env.API_KEY || '' });
|
| 475 |
+
const prompt = `
|
| 476 |
+
Act as a structural engineer. Review this ${activeType.replace(/-/g, ' ')} design (${designCode}, Imperial Units).
|
| 477 |
+
|
| 478 |
+
Inputs:
|
| 479 |
+
- Span: ${inputs.span} ft
|
| 480 |
+
- Section: ${inputs.width}" x ${inputs.depth}"
|
| 481 |
+
- Materials: f'c=${inputs.fc} psi, fy=${inputs.fy} psi
|
| 482 |
+
- Loads: DL=${inputs.deadLoad}, LL=${inputs.liveLoad} with Factors: ${inputs.dlFactor}DL + ${inputs.llFactor}LL
|
| 483 |
+
|
| 484 |
+
Results:
|
| 485 |
+
- Design Load: ${result.mu ? `Mu = ${result.mu.toFixed(1)} k-ft` : `Pu = ${result.pu?.toFixed(1)} kips`}
|
| 486 |
+
- Required As: ${result.asRequired.toFixed(2)} in²
|
| 487 |
+
- Spacing/Count: ${result.message}
|
| 488 |
+
- Anchorage: Required Ld = ${result.requiredDevLength.toFixed(1)}", Provided = ${inputs.providedDevLength}"
|
| 489 |
+
|
| 490 |
+
Task:
|
| 491 |
+
Provide a short 3-bullet critique on efficiency, anchorage adequacy, and one constructability tip.
|
| 492 |
+
`;
|
| 493 |
+
|
| 494 |
+
const response = await ai.models.generateContent({
|
| 495 |
+
model: 'gemini-3-flash-preview',
|
| 496 |
+
contents: prompt,
|
| 497 |
+
});
|
| 498 |
+
|
| 499 |
+
setAiAnalysis(response.text || 'No response generated.');
|
| 500 |
+
} catch (error) {
|
| 501 |
+
console.error(error);
|
| 502 |
+
setAiAnalysis('Error retrieving AI analysis. Check API Key.');
|
| 503 |
+
} finally {
|
| 504 |
+
setIsAnalyzing(false);
|
| 505 |
+
}
|
| 506 |
+
};
|
| 507 |
+
|
| 508 |
+
const getConcreteLabel = () => designCode === 'ACI-318' ? "Concrete (f'c)" : "Concrete (fck)";
|
| 509 |
+
const getSteelLabel = () => designCode === 'ACI-318' ? "Steel (fy)" : "Steel (fyk)";
|
| 510 |
+
|
| 511 |
+
const loadCombOptions: LoadCombOption[] = [
|
| 512 |
+
{ id: 'code', name: 'Code Default (Auto)', dl: 0, ll: 0 },
|
| 513 |
+
{ id: '1.4dl', name: '1.4 DL Only', dl: 1.4, ll: 0 },
|
| 514 |
+
{ id: 'custom', name: 'User Defined', dl: 0, ll: 0 },
|
| 515 |
+
];
|
| 516 |
+
|
| 517 |
+
return (
|
| 518 |
+
<div className="min-h-screen flex flex-col md:flex-row font-sans text-gray-800 overflow-hidden bg-gradient-to-br from-indigo-500 via-purple-500 to-pink-500 animate-gradient">
|
| 519 |
+
<GlobalStyles />
|
| 520 |
+
{/* Sidebar */}
|
| 521 |
+
<aside className="w-full md:w-64 glass-sidebar text-slate-300 flex-shrink-0 flex flex-col shadow-2xl z-20">
|
| 522 |
+
<div className="p-6 border-b border-white/10">
|
| 523 |
+
<h1 className="text-2xl font-black tracking-tight text-white drop-shadow-md">RCC <span className="text-blue-400">Design</span></h1>
|
| 524 |
+
<p className="text-[10px] text-slate-400 mt-0.5 tracking-wider font-mono">By Saad Hussain</p>
|
| 525 |
+
</div>
|
| 526 |
+
|
| 527 |
+
<div className="px-6 pt-6">
|
| 528 |
+
<label className="text-[10px] uppercase text-slate-400 font-bold tracking-wider">Design Code</label>
|
| 529 |
+
<div className="mt-2 relative group">
|
| 530 |
+
<select
|
| 531 |
+
value={designCode}
|
| 532 |
+
onChange={(e) => setDesignCode(e.target.value as DesignCode)}
|
| 533 |
+
className="w-full bg-slate-800/50 text-white text-sm rounded-xl p-3 border border-white/10 focus:border-blue-400 focus:outline-none appearance-none transition-colors hover:bg-slate-800/70 cursor-pointer backdrop-blur-md"
|
| 534 |
+
>
|
| 535 |
+
<option value="ACI-318">ACI 318 (USA)</option>
|
| 536 |
+
<option value="Eurocode-2">Eurocode 2 (EU)</option>
|
| 537 |
+
<option value="IS-456">IS 456 (India)</option>
|
| 538 |
+
</select>
|
| 539 |
+
<div className="pointer-events-none absolute inset-y-0 right-0 flex items-center px-3 text-slate-400">
|
| 540 |
+
<svg className="fill-current h-4 w-4" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M9.293 12.95l.707.707L15.657 8l-1.414-1.414L10 10.828 5.757 6.586 4.343 8z"/></svg>
|
| 541 |
+
</div>
|
| 542 |
+
</div>
|
| 543 |
+
</div>
|
| 544 |
+
|
| 545 |
+
<nav className="p-4 space-y-2 mt-4 flex-1 overflow-y-auto">
|
| 546 |
+
<label className="text-[10px] uppercase text-slate-400 font-bold tracking-wider px-2 mb-2 block">Elements</label>
|
| 547 |
+
{(['one-way-slab', 'two-way-slab', 'beam', 'column'] as DesignType[]).map((type) => (
|
| 548 |
+
<button
|
| 549 |
+
key={type}
|
| 550 |
+
onClick={() => handleTypeChange(type)}
|
| 551 |
+
className={`w-full text-left px-4 py-3 rounded-xl transition-all duration-300 capitalize flex items-center justify-between group backdrop-blur-sm border border-transparent ${
|
| 552 |
+
activeType === type
|
| 553 |
+
? 'bg-blue-600/80 text-white shadow-lg shadow-blue-900/40 translate-x-1 border-blue-400/30'
|
| 554 |
+
: 'text-slate-400 hover:bg-white/10 hover:text-white hover:translate-x-1 hover:border-white/10'
|
| 555 |
+
}`}
|
| 556 |
+
>
|
| 557 |
+
{type.replace(/-/g, ' ')}
|
| 558 |
+
{activeType === type && <span className="text-blue-200 animate-pulse">→</span>}
|
| 559 |
+
</button>
|
| 560 |
+
))}
|
| 561 |
+
</nav>
|
| 562 |
+
</aside>
|
| 563 |
+
|
| 564 |
+
{/* Main Content */}
|
| 565 |
+
<main className="flex-1 overflow-y-auto relative p-4 md:p-8">
|
| 566 |
+
|
| 567 |
+
<header className="flex justify-between items-end mb-8 z-10 relative text-white animate-fadeInUp">
|
| 568 |
+
<div>
|
| 569 |
+
<h2 className="text-4xl font-black capitalize tracking-tight drop-shadow-md">{activeType.replace(/-/g, ' ')} Design</h2>
|
| 570 |
+
<div className="text-xs font-mono text-white/70 mt-2 flex items-center gap-2">
|
| 571 |
+
<span className="bg-white/10 px-3 py-1 rounded-full backdrop-blur-md border border-white/20 transition-colors hover:bg-white/20 cursor-default shadow-sm">{designCode}</span>
|
| 572 |
+
<span className="bg-white/10 px-3 py-1 rounded-full backdrop-blur-md border border-white/20 transition-colors hover:bg-white/20 cursor-default shadow-sm">Imperial Units</span>
|
| 573 |
+
</div>
|
| 574 |
+
</div>
|
| 575 |
+
</header>
|
| 576 |
+
|
| 577 |
+
<div className="grid grid-cols-1 xl:grid-cols-12 gap-6 relative z-0">
|
| 578 |
+
|
| 579 |
+
{/* Inputs Section */}
|
| 580 |
+
<div className="xl:col-span-7 space-y-6 animate-fadeInUp" style={{animationDelay: '0.1s'}}>
|
| 581 |
+
<div className="glass-panel rounded-3xl p-8 transition-all hover:shadow-2xl hover:shadow-purple-500/10 duration-500">
|
| 582 |
+
<h3 className="text-sm font-black text-slate-700 mb-6 border-b border-slate-300/30 pb-3 flex items-center gap-2 uppercase tracking-wide">
|
| 583 |
+
Geometry & Materials
|
| 584 |
+
</h3>
|
| 585 |
+
<div className="grid grid-cols-2 md:grid-cols-4 gap-x-6 gap-y-6">
|
| 586 |
+
<div className="col-span-2 md:col-span-2">
|
| 587 |
+
<InputField label="Span Length (L)" value={inputs.span} onChange={(v) => handleInputChange('span', v)} unit="ft" />
|
| 588 |
+
</div>
|
| 589 |
+
{activeType === 'two-way-slab' && (
|
| 590 |
+
<div className="col-span-2 md:col-span-2">
|
| 591 |
+
<InputField label="Span Width (Ly)" value={inputs.spanY || 0} onChange={(v) => handleInputChange('spanY', v)} unit="ft" />
|
| 592 |
+
</div>
|
| 593 |
+
)}
|
| 594 |
+
<InputField label="Section Width (b)" value={inputs.width} onChange={(v) => handleInputChange('width', v)} unit="in" />
|
| 595 |
+
<InputField label="Section Depth (h)" value={inputs.depth} onChange={(v) => handleInputChange('depth', v)} unit="in" />
|
| 596 |
+
<InputField label="Clear Cover" value={inputs.cover} onChange={(v) => handleInputChange('cover', v)} unit="in" />
|
| 597 |
+
|
| 598 |
+
{/* Bar Select */}
|
| 599 |
+
<div className="flex flex-col group">
|
| 600 |
+
<label className="text-[10px] font-bold text-slate-600 uppercase tracking-wide mb-1 truncate group-hover:text-blue-600 transition-colors">Bar Size</label>
|
| 601 |
+
<div className="relative">
|
| 602 |
+
<select
|
| 603 |
+
value={inputs.barIndex}
|
| 604 |
+
onChange={(e) => handleInputChange('barIndex', parseInt(e.target.value))}
|
| 605 |
+
className="w-full glass-input rounded-xl px-3 py-2 text-sm text-slate-800 font-medium focus:outline-none focus:ring-2 focus:ring-blue-400 appearance-none transition-all cursor-pointer hover:shadow-md"
|
| 606 |
+
>
|
| 607 |
+
{IMPERIAL_BARS.map((bar, idx) => (
|
| 608 |
+
<option key={bar.name} value={idx}>{bar.name} (d={bar.dia}")</option>
|
| 609 |
+
))}
|
| 610 |
+
</select>
|
| 611 |
+
<div className="pointer-events-none absolute inset-y-0 right-0 flex items-center px-2 text-slate-500">
|
| 612 |
+
<svg className="fill-current h-4 w-4" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M9.293 12.95l.707.707L15.657 8l-1.414-1.414L10 10.828 5.757 6.586 4.343 8z"/></svg>
|
| 613 |
+
</div>
|
| 614 |
+
</div>
|
| 615 |
+
</div>
|
| 616 |
+
|
| 617 |
+
<div className="col-span-2 md:col-span-4 border-t border-slate-300/30 pt-5 mt-2">
|
| 618 |
+
<div className="grid grid-cols-2 gap-4">
|
| 619 |
+
<InputField label={getConcreteLabel()} value={inputs.fc} onChange={(v) => handleInputChange('fc', v)} unit="psi" />
|
| 620 |
+
<InputField label={getSteelLabel()} value={inputs.fy} onChange={(v) => handleInputChange('fy', v)} unit="psi" />
|
| 621 |
+
</div>
|
| 622 |
+
</div>
|
| 623 |
+
</div>
|
| 624 |
+
</div>
|
| 625 |
+
|
| 626 |
+
<div className="grid grid-cols-1 md:grid-cols-2 gap-6">
|
| 627 |
+
<div className="glass-panel rounded-3xl p-6 transition-all hover:shadow-2xl duration-500">
|
| 628 |
+
<h3 className="text-sm font-black text-slate-700 mb-6 border-b border-slate-300/30 pb-3 uppercase tracking-wide">
|
| 629 |
+
Load Analysis
|
| 630 |
+
</h3>
|
| 631 |
+
<div className="space-y-5">
|
| 632 |
+
|
| 633 |
+
{/* Load Comb Select */}
|
| 634 |
+
<div className="flex flex-col">
|
| 635 |
+
<label className="text-[10px] font-bold text-slate-600 uppercase tracking-wide mb-1">Load Combination</label>
|
| 636 |
+
<div className="relative">
|
| 637 |
+
<select
|
| 638 |
+
value={selectedLoadComb}
|
| 639 |
+
onChange={(e) => setSelectedLoadComb(e.target.value)}
|
| 640 |
+
className="w-full glass-input rounded-xl px-3 py-2 text-xs text-slate-800 font-bold focus:outline-none focus:ring-2 focus:ring-blue-400 appearance-none cursor-pointer"
|
| 641 |
+
>
|
| 642 |
+
{loadCombOptions.map(opt => <option key={opt.id} value={opt.id}>{opt.name}</option>)}
|
| 643 |
+
</select>
|
| 644 |
+
<div className="pointer-events-none absolute inset-y-0 right-0 flex items-center px-2 text-slate-500">
|
| 645 |
+
<svg className="fill-current h-3 w-3" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M9.293 12.95l.707.707L15.657 8l-1.414-1.414L10 10.828 5.757 6.586 4.343 8z"/></svg>
|
| 646 |
+
</div>
|
| 647 |
+
</div>
|
| 648 |
+
</div>
|
| 649 |
+
|
| 650 |
+
<div className="grid grid-cols-2 gap-3 bg-white/30 p-3 rounded-xl border border-white/40">
|
| 651 |
+
<InputField label="Gamma DL" value={inputs.dlFactor} onChange={(v) => handleInputChange('dlFactor', v)} readOnly={selectedLoadComb !== 'custom'} small />
|
| 652 |
+
<InputField label="Gamma LL" value={inputs.llFactor} onChange={(v) => handleInputChange('llFactor', v)} readOnly={selectedLoadComb !== 'custom'} small />
|
| 653 |
+
</div>
|
| 654 |
+
|
| 655 |
+
<div className="grid grid-cols-2 gap-4">
|
| 656 |
+
<InputField
|
| 657 |
+
label={activeType === 'column' ? "Dead (P)" : "Dead (w)"}
|
| 658 |
+
value={inputs.deadLoad}
|
| 659 |
+
onChange={(v) => handleInputChange('deadLoad', v)}
|
| 660 |
+
unit={activeType === 'column' ? "kips" : (activeType === 'beam' ? "klf" : "ksf")}
|
| 661 |
+
/>
|
| 662 |
+
<InputField
|
| 663 |
+
label={activeType === 'column' ? "Live (P)" : "Live (w)"}
|
| 664 |
+
value={inputs.liveLoad}
|
| 665 |
+
onChange={(v) => handleInputChange('liveLoad', v)}
|
| 666 |
+
unit={activeType === 'column' ? "kips" : (activeType === 'beam' ? "klf" : "ksf")}
|
| 667 |
+
/>
|
| 668 |
+
</div>
|
| 669 |
+
</div>
|
| 670 |
+
</div>
|
| 671 |
+
|
| 672 |
+
<div className="glass-panel rounded-3xl p-6 transition-all hover:shadow-2xl duration-500">
|
| 673 |
+
<h3 className="text-sm font-black text-slate-700 mb-6 border-b border-slate-300/30 pb-3 uppercase tracking-wide flex justify-between">
|
| 674 |
+
<span>Anchorage</span>
|
| 675 |
+
<span className={`text-[10px] px-2 py-0.5 rounded-full font-bold border ${result?.devLengthStatus === 'ok' ? 'bg-green-100/50 text-green-700 border-green-200' : 'bg-red-100/50 text-red-700 border-red-200'} transition-colors duration-300 backdrop-blur-sm`}>
|
| 676 |
+
{result?.devLengthStatus === 'ok' ? 'PASS' : 'SHORT'}
|
| 677 |
+
</span>
|
| 678 |
+
</h3>
|
| 679 |
+
<div className="space-y-4">
|
| 680 |
+
<InputField
|
| 681 |
+
label="Available Anchorage Length"
|
| 682 |
+
value={inputs.providedDevLength || 0}
|
| 683 |
+
onChange={(v) => handleInputChange('providedDevLength', v)}
|
| 684 |
+
unit="in"
|
| 685 |
+
highlight={result?.devLengthStatus === 'short'}
|
| 686 |
+
/>
|
| 687 |
+
{result && (
|
| 688 |
+
<div key={result.requiredDevLength} className="text-xs flex justify-between items-center text-slate-600 pt-2 animate-fadeInUp font-medium px-1">
|
| 689 |
+
<span>Required Length (Ld):</span>
|
| 690 |
+
<span className="font-mono font-bold text-slate-800 text-sm bg-white/40 px-2 py-0.5 rounded-lg">{result.requiredDevLength.toFixed(1)}"</span>
|
| 691 |
+
</div>
|
| 692 |
+
)}
|
| 693 |
+
</div>
|
| 694 |
+
</div>
|
| 695 |
+
</div>
|
| 696 |
+
</div>
|
| 697 |
+
|
| 698 |
+
{/* Results Section */}
|
| 699 |
+
<div className="xl:col-span-5 space-y-6 animate-fadeInUp" style={{animationDelay: '0.2s'}}>
|
| 700 |
+
|
| 701 |
+
{/* Results Card */}
|
| 702 |
+
<div className={`rounded-3xl shadow-xl p-8 text-white transition-all duration-500 relative overflow-hidden group backdrop-blur-xl border border-white/20 ${
|
| 703 |
+
result?.status === 'warning' ? 'bg-gradient-to-br from-amber-500/80 to-orange-600/80 shadow-orange-500/20' :
|
| 704 |
+
result?.status === 'fail' ? 'bg-gradient-to-br from-red-600/80 to-rose-700/80 shadow-red-600/20' :
|
| 705 |
+
'bg-gradient-to-br from-blue-600/80 to-indigo-700/80 shadow-blue-600/20'
|
| 706 |
+
}`}>
|
| 707 |
+
{/* Decorative Background Elements */}
|
| 708 |
+
<div className="absolute top-0 right-0 w-32 h-32 bg-white/20 rounded-full blur-3xl -mr-10 -mt-10 group-hover:scale-150 transition-transform duration-700 mix-blend-overlay"></div>
|
| 709 |
+
|
| 710 |
+
<div className="relative z-10">
|
| 711 |
+
<div className="flex justify-between items-start mb-6">
|
| 712 |
+
<div>
|
| 713 |
+
<h3 className="text-2xl font-bold tracking-tight text-white drop-shadow-sm">Design Results</h3>
|
| 714 |
+
<p className="opacity-90 text-xs mt-1 text-indigo-100">Ultimate Strength Design Method</p>
|
| 715 |
+
</div>
|
| 716 |
+
{result?.status !== 'ok' && (
|
| 717 |
+
<span className="bg-white/20 backdrop-blur-md px-3 py-1 rounded-full text-xs font-bold uppercase tracking-wider shadow-sm border border-white/20 animate-pulse">
|
| 718 |
+
{result?.status}
|
| 719 |
+
</span>
|
| 720 |
+
)}
|
| 721 |
+
</div>
|
| 722 |
+
|
| 723 |
+
{result && (
|
| 724 |
+
<div key={`${result.asRequired}-${result.mu}`} className="space-y-6 animate-fadeInUp">
|
| 725 |
+
<div className="grid grid-cols-2 gap-4">
|
| 726 |
+
<div className="bg-black/10 backdrop-blur-md rounded-2xl p-4 border border-white/10 transition-colors hover:bg-black/20 group/item">
|
| 727 |
+
<span className="opacity-70 text-[10px] uppercase font-bold tracking-wider block mb-1 group-hover/item:text-white transition-colors text-indigo-100">Factored Load</span>
|
| 728 |
+
<span className="text-2xl font-mono font-bold tracking-tighter text-white">
|
| 729 |
+
{result.pu ? result.pu.toFixed(1) : result.mu?.toFixed(1)} <span className="text-sm font-sans font-normal opacity-80">{result.pu ? 'kips' : 'k-ft'}</span>
|
| 730 |
+
</span>
|
| 731 |
+
</div>
|
| 732 |
+
<div className="bg-black/10 backdrop-blur-md rounded-2xl p-4 border border-white/10 transition-colors hover:bg-black/20 group/item">
|
| 733 |
+
<span className="opacity-70 text-[10px] uppercase font-bold tracking-wider block mb-1 group-hover/item:text-white transition-colors text-indigo-100">Required Steel</span>
|
| 734 |
+
<span className="text-2xl font-mono font-bold tracking-tighter text-white">
|
| 735 |
+
{result.asRequired.toFixed(2)} <span className="text-sm font-sans font-normal opacity-80">in²</span>
|
| 736 |
+
</span>
|
| 737 |
+
</div>
|
| 738 |
+
</div>
|
| 739 |
+
|
| 740 |
+
<div className="bg-white/90 backdrop-blur-xl text-slate-800 rounded-2xl p-5 shadow-lg transform transition-transform hover:scale-[1.02] hover:shadow-xl border border-white/50">
|
| 741 |
+
<p className="text-[10px] uppercase tracking-widest text-slate-500 font-bold mb-2">Recommendation</p>
|
| 742 |
+
<p className="text-xl font-bold text-slate-800 leading-tight">{result.message}</p>
|
| 743 |
+
</div>
|
| 744 |
+
</div>
|
| 745 |
+
)}
|
| 746 |
+
</div>
|
| 747 |
+
</div>
|
| 748 |
+
|
| 749 |
+
{/* Schematic Visualization */}
|
| 750 |
+
<div className="glass-panel rounded-3xl p-8 flex flex-col items-center justify-center min-h-[260px] relative overflow-hidden group hover:shadow-2xl transition-all duration-500">
|
| 751 |
+
<div className="absolute top-0 left-0 w-full h-1 bg-gradient-to-r from-blue-400 via-indigo-400 to-purple-400 transform origin-left transition-transform duration-500 scale-x-50 group-hover:scale-x-100 opacity-70"></div>
|
| 752 |
+
<h3 className="text-xs font-bold text-slate-500 uppercase w-full mb-6 flex justify-between">
|
| 753 |
+
<span>Section Preview</span>
|
| 754 |
+
<span className="text-[10px] bg-slate-800/5 px-2 py-0.5 rounded text-slate-500 border border-slate-800/5">Not to scale</span>
|
| 755 |
+
</h3>
|
| 756 |
+
{result && (
|
| 757 |
+
<SchematicView
|
| 758 |
+
type={activeType}
|
| 759 |
+
width={inputs.width}
|
| 760 |
+
depth={inputs.depth}
|
| 761 |
+
cover={inputs.cover}
|
| 762 |
+
barCount={result.barCount}
|
| 763 |
+
barIndex={inputs.barIndex}
|
| 764 |
+
spacing={result.spacing}
|
| 765 |
+
span={inputs.span}
|
| 766 |
+
spanY={inputs.spanY}
|
| 767 |
+
/>
|
| 768 |
+
)}
|
| 769 |
+
</div>
|
| 770 |
+
|
| 771 |
+
{/* AI Assistant */}
|
| 772 |
+
<div className="glass-panel rounded-3xl p-6 relative overflow-hidden">
|
| 773 |
+
<div className="absolute -right-10 -top-10 w-40 h-40 bg-purple-500/10 rounded-full blur-3xl"></div>
|
| 774 |
+
<div className="flex items-center space-x-3 mb-4 relative z-10">
|
| 775 |
+
<div className="h-10 w-10 rounded-full bg-indigo-600 flex items-center justify-center text-white shadow-lg shadow-indigo-500/30 ring-2 ring-white/30">
|
| 776 |
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" className="w-5 h-5">
|
| 777 |
+
<path fillRule="evenodd" d="M9.315 7.584C12.195 3.883 16.695 1.5 21.75 1.5a.75.75 0 01.75.75c0 5.056-2.383 9.555-6.084 12.436-3.118 2.424-7.146 2.424-10.264 0-1.025-.798-1.575-2.046-1.42-3.32.128-1.06.945-1.928 2.01-2.043a3.75 3.75 0 013.32 1.421c.82 1.054 2.296 1.258 3.348.455.766-.584.97-1.636.455-2.39a3.75 3.75 0 00-2.39-1.297z" clipRule="evenodd" />
|
| 778 |
+
<path d="M4.5 16.5a1.5 1.5 0 100 3 1.5 1.5 0 000-3zM3 15.75a3 3 0 013-3h1.5a.75.75 0 000-1.5H6a4.5 4.5 0 00-4.408 5.253.75.75 0 001.352-.393A3 3 0 013 15.75z" />
|
| 779 |
+
</svg>
|
| 780 |
+
</div>
|
| 781 |
+
<div>
|
| 782 |
+
<h3 className="font-bold text-indigo-900 text-sm">AI Engineer</h3>
|
| 783 |
+
<p className="text-[10px] text-indigo-700 font-medium">Gemini 3 Flash</p>
|
| 784 |
+
</div>
|
| 785 |
+
</div>
|
| 786 |
+
|
| 787 |
+
<div className="mb-4 text-xs text-slate-700 min-h-[80px] bg-white/40 backdrop-blur-md p-4 rounded-2xl border border-white/40 shadow-sm leading-relaxed transition-all duration-300 hover:bg-white/50 relative z-10">
|
| 788 |
+
{isAnalyzing ? (
|
| 789 |
+
<div className="flex items-center space-x-2 animate-pulse py-2">
|
| 790 |
+
<div className="w-1.5 h-1.5 bg-indigo-500 rounded-full"></div>
|
| 791 |
+
<div className="w-1.5 h-1.5 bg-indigo-500 rounded-full animation-delay-200"></div>
|
| 792 |
+
<div className="w-1.5 h-1.5 bg-indigo-500 rounded-full animation-delay-400"></div>
|
| 793 |
+
<span className="font-medium text-indigo-600 ml-2">Reviewing structural design...</span>
|
| 794 |
+
</div>
|
| 795 |
+
) : aiAnalysis ? (
|
| 796 |
+
<div className="animate-fadeInUp">
|
| 797 |
+
{aiAnalysis.split('\n').map((line, i) => <p key={i} className="mb-1">{line}</p>)}
|
| 798 |
+
</div>
|
| 799 |
+
) : (
|
| 800 |
+
<span className="opacity-60 italic">Ask for a peer review of your section details.</span>
|
| 801 |
+
)}
|
| 802 |
+
</div>
|
| 803 |
+
|
| 804 |
+
<button
|
| 805 |
+
onClick={runAiAnalysis}
|
| 806 |
+
disabled={isAnalyzing || !result}
|
| 807 |
+
className="w-full py-2.5 bg-white/70 hover:bg-indigo-600 hover:text-white border border-white/50 text-indigo-800 font-bold rounded-xl transition-all duration-200 text-xs shadow-sm flex items-center justify-center gap-2 group active:scale-95 backdrop-blur-sm relative z-10"
|
| 808 |
+
>
|
| 809 |
+
<span>Generate Report</span>
|
| 810 |
+
<svg className="w-3 h-3 group-hover:translate-x-1 transition-transform" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path strokeLinecap="round" strokeLinejoin="round" strokeWidth="2" d="M14 5l7 7m0 0l-7 7m7-7H3"></path></svg>
|
| 811 |
+
</button>
|
| 812 |
+
</div>
|
| 813 |
+
|
| 814 |
+
</div>
|
| 815 |
+
</div>
|
| 816 |
+
</main>
|
| 817 |
+
</div>
|
| 818 |
+
);
|
| 819 |
+
};
|
| 820 |
+
|
| 821 |
+
const root = createRoot(document.getElementById("root")!);
|
| 822 |
+
root.render(<App />);
|
metadata.json
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"description": "By Saad.",
|
| 3 |
+
"requestFramePermissions": [],
|
| 4 |
+
"name": "RCC Design "
|
| 5 |
+
}
|
package.json
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "rcc-design",
|
| 3 |
+
"private": true,
|
| 4 |
+
"version": "0.0.0",
|
| 5 |
+
"type": "module",
|
| 6 |
+
"scripts": {
|
| 7 |
+
"dev": "vite",
|
| 8 |
+
"build": "vite build",
|
| 9 |
+
"preview": "vite preview"
|
| 10 |
+
},
|
| 11 |
+
"dependencies": {
|
| 12 |
+
"react": "^19.2.3",
|
| 13 |
+
"react-dom": "^19.2.3",
|
| 14 |
+
"@google/genai": "^1.34.0"
|
| 15 |
+
},
|
| 16 |
+
"devDependencies": {
|
| 17 |
+
"@types/node": "^22.14.0",
|
| 18 |
+
"@vitejs/plugin-react": "^5.0.0",
|
| 19 |
+
"typescript": "~5.8.2",
|
| 20 |
+
"vite": "^6.2.0"
|
| 21 |
+
}
|
| 22 |
+
}
|
tsconfig.json
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"compilerOptions": {
|
| 3 |
+
"target": "ES2022",
|
| 4 |
+
"experimentalDecorators": true,
|
| 5 |
+
"useDefineForClassFields": false,
|
| 6 |
+
"module": "ESNext",
|
| 7 |
+
"lib": [
|
| 8 |
+
"ES2022",
|
| 9 |
+
"DOM",
|
| 10 |
+
"DOM.Iterable"
|
| 11 |
+
],
|
| 12 |
+
"skipLibCheck": true,
|
| 13 |
+
"types": [
|
| 14 |
+
"node"
|
| 15 |
+
],
|
| 16 |
+
"moduleResolution": "bundler",
|
| 17 |
+
"isolatedModules": true,
|
| 18 |
+
"moduleDetection": "force",
|
| 19 |
+
"allowJs": true,
|
| 20 |
+
"jsx": "react-jsx",
|
| 21 |
+
"paths": {
|
| 22 |
+
"@/*": [
|
| 23 |
+
"./*"
|
| 24 |
+
]
|
| 25 |
+
},
|
| 26 |
+
"allowImportingTsExtensions": true,
|
| 27 |
+
"noEmit": true
|
| 28 |
+
}
|
| 29 |
+
}
|