diff --git a/.babelrc b/.babelrc new file mode 100644 index 0000000..85ccdd2 --- /dev/null +++ b/.babelrc @@ -0,0 +1,4 @@ +{ + "presets": ["@babel/preset-env", "@babel/preset-react"] + } + \ No newline at end of file diff --git a/App.jsx b/App.jsx index 1aa6ae9..a2b3645 100644 --- a/App.jsx +++ b/App.jsx @@ -1,11 +1,66 @@ -import React from 'react'; +import React, { useState } from 'react'; +import "./design.css" -class App extends React.Component { - render() { - return ( -
simon, helloworld!!!
- ); +const App = () => { + const [height, setHeight] = useState(''); + const [weight, setWeight] = useState(''); + const [bmi, setBMI] = useState(''); + const [message, setMessage] = useState(''); + const [error, setError] = useState(''); + + const handleHeightChange = event => { + setHeight(event.target.value); + setError(''); + setMessage(''); + } + + const handleWeightChange = event => { + setWeight(event.target.value); + setError(''); + setMessage(''); + } + + const handleCalculateBMI = () => { + if (height <= 0 || weight <= 0) { + setError('Please enter valid values for height and weight.'); + setBMI(''); + return; + } + + const bmi = calculateBMI(height, weight); + setBMI(bmi); + + if (bmi < 18.5) { + setMessage('You are underweight.'); + } else if (bmi >= 18.5 && bmi <= 24.9) { + setMessage('You have a healthy weight.'); + } else if (bmi >= 25 && bmi <= 29.9) { + setMessage('You are overweight.'); + } else { + setMessage('You are obese.'); + } } + + const calculateBMI = (height, weight) => { + const heightInMeters = height / 100; + const bmi = weight / (heightInMeters * heightInMeters); + return bmi.toFixed(2); + } + + return ( +
+ + +
+ + +
+ + {error &&

{error}

} + {message &&

{message}

} + {bmi &&

Your BMI is {bmi}

} +
+ ); } -export default App; +export default App; \ No newline at end of file diff --git a/another.pl b/another.pl new file mode 100644 index 0000000..52148cf --- /dev/null +++ b/another.pl @@ -0,0 +1,14 @@ +{ + "presets": [ + "@babel/preset-react", + [ + "@babel/preset-env", + { + "targets": { + "node": "current" + } + } + ] + ], + "plugins": ["@babel/plugin-proposal-class-properties"] +} diff --git a/design.css b/design.css new file mode 100644 index 0000000..e31f3b3 --- /dev/null +++ b/design.css @@ -0,0 +1,47 @@ +body { + font-family: Arial, sans-serif; + margin: 0; + padding: 0; + } + + .container { + max-width: 600px; + margin: 0 auto; + padding: 20px; + background-color: #4CAF50; + } + + form { + display: flex; + flex-direction: column; + gap: 10px; + margin-bottom: 20px; + } + + form label { + font-weight: bold; + } + + form input[type="number"] { + padding: 10px; + border-radius: 5px; + border: 1px solid #ccc; + } + + form button { + background-color: #4CAF50; + color: white; + padding: 10px; + border: none; + border-radius: 5px; + cursor: pointer; + } + + .error { + color: red; + } + + .message { + font-weight: bold; + } + \ No newline at end of file diff --git a/dist/index.js b/dist/index.js new file mode 100644 index 0000000..036c7aa --- /dev/null +++ b/dist/index.js @@ -0,0 +1,2 @@ +/*! For license information please see index.js.LICENSE.txt */ +(()=>{"use strict";var e={418:e=>{var t=Object.getOwnPropertySymbols,n=Object.prototype.hasOwnProperty,r=Object.prototype.propertyIsEnumerable;e.exports=function(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},n=0;n<10;n++)t["_"+String.fromCharCode(n)]=n;if("0123456789"!==Object.getOwnPropertyNames(t).map((function(e){return t[e]})).join(""))return!1;var r={};return"abcdefghijklmnopqrst".split("").forEach((function(e){r[e]=e})),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},r)).join("")}catch(e){return!1}}()?Object.assign:function(e,l){for(var a,o,u=function(e){if(null==e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}(e),i=1;i{var r=n(294),l=n(418),a=n(840);function o(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n