import React, { useState, useEffect } from 'react'; import { Ruler, ArrowUpRight, ArrowDownRight, RefreshCw, Calculator, Info, Edit3, Target } from 'lucide-react'; const App = () => { // 基本設定の状態 (すべてmm単位) // 初期値を文字列で管理することで、入力時の挙動を制御しやすくする const [totalLength, setTotalLength] = useState('10000'); const [totalHeightDiff, setTotalHeightDiff] = useState('100'); const [slopeDirection, setSlopeDirection] = useState(1); // 1: 下がり, -1: 上がり // 基点設定 const [baseLevel, setBaseLevel] = useState('75'); const [baseSign, setBaseSign] = useState(1); // 1: プラス, -1: マイナス // 測りたい場所 (最小50, 最大10000, 5mm刻み) const [currentDist, setCurrentDist] = useState('5000'); // 計算結果 const [finalLevel, setFinalLevel] = useState(0); const [slopePercent, setSlopePercent] = useState(0); // 数値変換用ヘルパー const num = (val) => Number(val) || 0; // 計算ロジック useEffect(() => { const L = num(totalLength); const H = num(totalHeightDiff); const D = num(currentDist); const B = num(baseLevel); if (L > 0) { const slopeRatio = H / L; const deltaH = slopeRatio * D * (slopeDirection === 1 ? -1 : 1); const startLevel = B * baseSign; const result = startLevel + deltaH; setFinalLevel(result.toFixed(1)); const percent = (H / L) * 100; setSlopePercent(percent.toFixed(2)); } }, [totalLength, totalHeightDiff, slopeDirection, baseLevel, baseSign, currentDist]); // 入力フォーカス時の処理(全選択) const handleFocus = (e) => { e.target.select(); }; // リセット const resetFields = () => { setTotalLength('10000'); setTotalHeightDiff('100'); setSlopeDirection(1); setBaseLevel('75'); setBaseSign(1); setCurrentDist('5000'); }; return (
Kawabata-Gumi Edition
現在の設計レベル