From 26afc058f84ca6191323cdcbcd5e30ee3449cfa6 Mon Sep 17 00:00:00 2001
From: praptisharma28 <123169861+praptisharma28@users.noreply.github.com>
Date: Tue, 30 Jan 2024 18:41:18 +0530
Subject: [PATCH 1/2] BMI Calculator added
closes #217
---
BMI_Calculator/README.md | 34 ++++++
BMI_Calculator/package.json | 28 +++++
BMI_Calculator/public/index.html | 20 ++++
BMI_Calculator/src/App.jsx | 177 +++++++++++++++++++++++++++++++
BMI_Calculator/src/index.jsx | 12 +++
BMI_Calculator/src/styles.css | 28 +++++
package-lock.json | 2 +-
7 files changed, 300 insertions(+), 1 deletion(-)
create mode 100644 BMI_Calculator/README.md
create mode 100644 BMI_Calculator/package.json
create mode 100644 BMI_Calculator/public/index.html
create mode 100644 BMI_Calculator/src/App.jsx
create mode 100644 BMI_Calculator/src/index.jsx
create mode 100644 BMI_Calculator/src/styles.css
diff --git a/BMI_Calculator/README.md b/BMI_Calculator/README.md
new file mode 100644
index 000000000..4ba07f600
--- /dev/null
+++ b/BMI_Calculator/README.md
@@ -0,0 +1,34 @@
+# BMI - Calculator
+
+## Tech Stack
+
+- React
+- JavaScript
+- HTML
+- CSS
+
+## How to Run the Code
+
+To run the code, follow these steps:
+
+1. Clone the repository.
+2. Navigate to the project directory.
+3. Install the dependencies by running the following command in your terminal:
+
+ ```bash
+ npm install
+ ```
+
+4. Start the development server by running the following command:
+
+ ```bash
+ npm start
+ ```
+
+5. Open your browser and visit `http://localhost:3000` to view the application.
+
+## Demo Video
+
+Check out the demo video below to see the BMI Calculator in action:
+
+[![BMI Calculator Demo](https://youtu.be/WEU9jhG0hSE?si=4_XtXizDHEUxOh85/0.jpg)](https://youtu.be/WEU9jhG0hSE?si=4_XtXizDHEUxOh85)
diff --git a/BMI_Calculator/package.json b/BMI_Calculator/package.json
new file mode 100644
index 000000000..2355e8f50
--- /dev/null
+++ b/BMI_Calculator/package.json
@@ -0,0 +1,28 @@
+{
+ "name": "simple-bmi-calculatorreact",
+ "version": "1.0.0",
+ "description": "",
+ "keywords": [],
+ "main": "src/index.js",
+ "dependencies": {
+ "react": "17.0.2",
+ "react-dom": "17.0.2",
+ "react-scripts": "4.0.0"
+ },
+ "devDependencies": {
+ "@babel/runtime": "7.13.8",
+ "typescript": "4.1.3"
+ },
+ "scripts": {
+ "start": "react-scripts start",
+ "build": "react-scripts build",
+ "test": "react-scripts test --env=jsdom",
+ "eject": "react-scripts eject"
+ },
+ "browserslist": [
+ ">0.2%",
+ "not dead",
+ "not ie <= 11",
+ "not op_mini all"
+ ]
+ }
\ No newline at end of file
diff --git a/BMI_Calculator/public/index.html b/BMI_Calculator/public/index.html
new file mode 100644
index 000000000..9e3546dd6
--- /dev/null
+++ b/BMI_Calculator/public/index.html
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+
+
+ React App
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/BMI_Calculator/src/App.jsx b/BMI_Calculator/src/App.jsx
new file mode 100644
index 000000000..788fb4228
--- /dev/null
+++ b/BMI_Calculator/src/App.jsx
@@ -0,0 +1,177 @@
+import React, { Component } from "react";
+import "./styles.css";
+// class App extends Component {
+// constructor(props) {
+// super(props);
+// this.state = {
+// fullName: '',
+// weight: '',
+// height: '',
+// bmi: '',
+// message: '',
+// optimalWeight: ''
+// };
+
+// this.handleChange = this.handleChange.bind(this);
+// this.calculateBMI = this.calculateBMI.bind(this);
+// this.handleSubmit = this.handleSubmit.bind(this);
+// }
+
+// handleChange(e) {
+// this.setState({ [e.target.name]: e.target.value });
+// }
+
+// calculateBMI() {
+// let heightSquared = ((this.state.height / 100) * this.state.height) / 100;
+// let bmi = this.state.weight / heightSquared;
+// let low = Math.round(18.5 * heightSquared);
+// let high = Math.round(24.99 * heightSquared);
+// let message = '';
+// if (bmi >= 18.5 && bmi <= 24.99) {
+// message = 'You are in a healthy weight range';
+// } else if (bmi >= 25 && bmi <= 29.9) {
+// message = 'You are overweight';
+// } else if (bmi >= 30) {
+// message = 'You are obese';
+// } else if (bmi < 18.5) {
+// message = 'You are under weight';
+// }
+
+// this.setState({ message: message });
+// this.setState({
+// optimalWeight:
+// 'Your suggested weight range is between ' + low + ' - ' + high
+// });
+// this.setState({ bmi: Math.round(bmi * 100) / 100 });
+// }
+
+// handleSubmit(e) {
+// this.calculateBMI();
+// e.preventDefault();
+// // console.log(this.state);
+// }
+
+// render() {
+// return (
+//
+// );
+// }
+// }
+
+// export default App;
+
+class App extends React.Component {
+ constructor() {
+ super();
+ this.state = {
+ height: "",
+ weight: "",
+ bmi: "",
+ msg: ""
+ };
+
+ // this.handleChange = this.handleChange.bind(this);
+ // this.handleSubmit = this.handleSubmit.bind(this);
+ // this.calculateBMI = this.calculateBMI.bind(this);
+ }
+
+ handleChange = (e) => {
+ this.setState({ [e.target.name]: e.target.value });
+ };
+
+ calculateBMI = () => {
+ let heightSq = (this.state.height / 100) * (this.state.height / 100);
+ let bmi = this.state.weight / heightSq;
+ let msg = "";
+ if (bmi < 18.5) {
+ msg = "under Weight";
+ } else if (bmi >= 18.5 && bmi <= 24.9) {
+ msg = "Normal Weight";
+ } else if (bmi >= 25 && bmi <= 29.9) {
+ msg = "Over Weight";
+ } else if (bmi >= 30) {
+ msg = "Obesity";
+ }
+ this.setState({ msg: msg });
+ this.setState({ bmi: Math.round(bmi * 100) / 100 });
+ };
+
+ handleSubmit = (e) => {
+ this.calculateBMI();
+ e.preventDefault();
+ };
+
+ render() {
+ return (
+
+ );
+ }
+}
+export default App;
diff --git a/BMI_Calculator/src/index.jsx b/BMI_Calculator/src/index.jsx
new file mode 100644
index 000000000..d65892e7f
--- /dev/null
+++ b/BMI_Calculator/src/index.jsx
@@ -0,0 +1,12 @@
+import { StrictMode } from "react";
+import ReactDOM from "react-dom";
+
+import App from "./App";
+
+const rootElement = document.getElementById("root");
+ReactDOM.render(
+
+
+ ,
+ rootElement
+);
diff --git a/BMI_Calculator/src/styles.css b/BMI_Calculator/src/styles.css
new file mode 100644
index 000000000..a45ab8367
--- /dev/null
+++ b/BMI_Calculator/src/styles.css
@@ -0,0 +1,28 @@
+.App {
+ display: flex;
+ justify-content: center;
+ border-radius: 5px;
+ background-color: lightcoral;
+ padding: 20px;
+ border: 1px solid cadetblue;
+ border-radius: 100px;
+ }
+
+ input {
+ width: 100%;
+ padding: 5px;
+ margin: 8px 0;
+ box-sizing: border-box;
+ }
+
+ button {
+ width: 100%;
+ padding: 5px;
+ margin: 8px 0;
+ box-sizing: border-box;
+ background-color: lightslategray;
+ }
+ button:hover {
+ background-color: lightsteelblue;
+ }
+
\ No newline at end of file
diff --git a/package-lock.json b/package-lock.json
index 70d12b5ac..7c97416ff 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,6 +1,6 @@
{
"name": "ReactCreations",
- "lockfileVersion": 3,
+ "lockfileVersion": 2,
"requires": true,
"packages": {}
}
From 1159fa37fdfe27ae97464eacad2127a5e8da16e9 Mon Sep 17 00:00:00 2001
From: praptisharma28 <123169861+praptisharma28@users.noreply.github.com>
Date: Tue, 30 Jan 2024 18:44:58 +0530
Subject: [PATCH 2/2] Create .gitignore
---
BMI_Calculator/.gitignore | 15 +++++++++++++++
1 file changed, 15 insertions(+)
create mode 100644 BMI_Calculator/.gitignore
diff --git a/BMI_Calculator/.gitignore b/BMI_Calculator/.gitignore
new file mode 100644
index 000000000..a88639f82
--- /dev/null
+++ b/BMI_Calculator/.gitignore
@@ -0,0 +1,15 @@
+# Ignore node_modules directory
+node_modules/
+
+# Ignore build output
+build/
+
+# Ignore IDE and editor files
+.vscode/
+.idea/
+
+# Ignore environment-specific files
+.env
+
+# Ignore log files
+*.log