-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Av4 flow rate page #8
Open
underdoggum
wants to merge
2
commits into
main
Choose a base branch
from
AV4-Flow-Rate-Page
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
"use client"; | ||
|
||
import { useState } from "react"; | ||
import Input from "./Input"; | ||
import "../styles/Form.css"; | ||
|
||
type FormProps = { | ||
onCalculate: (calculatedValue: number) => void; | ||
}; | ||
|
||
export default function Form({ onCalculate }: FormProps) { | ||
const [formData, setFormData] = useState<{ | ||
containerSize: number; | ||
tryOne: number; | ||
tryTwo: number; | ||
tryThree: number; | ||
}>({ | ||
containerSize: 0, | ||
tryOne: 0, | ||
tryTwo: 0, | ||
tryThree: 0, | ||
}); | ||
|
||
const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => { | ||
const { name, value } = event.target; | ||
setFormData((prev) => ({ | ||
...prev, | ||
[name]: parseFloat(value) || 0, | ||
})); | ||
}; | ||
|
||
const clear = () => { | ||
onCalculate(0); | ||
setFormData({ | ||
containerSize: 0, | ||
tryOne: 0, | ||
tryTwo: 0, | ||
tryThree: 0, | ||
}); | ||
} | ||
|
||
const handleSubmit = (event: React.FormEvent) => { | ||
event.preventDefault(); | ||
const { | ||
containerSize, | ||
tryOne, | ||
tryTwo, | ||
tryThree, | ||
} = formData; | ||
|
||
const sum = tryOne + tryTwo + tryThree; | ||
const avg = sum / 3; | ||
|
||
let ingress; | ||
if (avg != 0) { | ||
ingress = containerSize / avg; | ||
} else { | ||
ingress = 0; | ||
} | ||
|
||
onCalculate(ingress); | ||
}; | ||
|
||
const containerSizeLabel = "Container Size (L)"; | ||
const tryOneLabel = "Try One (s)"; | ||
const tryTwoLabel = "Try Two (s)"; | ||
const tryThreeLabel = "Try Three (s)"; | ||
|
||
return ( | ||
<form className="form" onSubmit={handleSubmit}> | ||
<div className="input-wrapper"> | ||
<Input | ||
label={containerSizeLabel} | ||
name="containerSize" | ||
min="0.01" | ||
handleChange={handleChange} | ||
/> | ||
<Input | ||
label={tryOneLabel} | ||
name="tryOne" | ||
min="0" | ||
handleChange={handleChange} | ||
/> | ||
<Input | ||
label={tryTwoLabel} | ||
name="tryTwo" | ||
min="0" | ||
handleChange={handleChange} | ||
/> | ||
<Input | ||
label={tryThreeLabel} | ||
name="tryThree" | ||
min="0" | ||
handleChange={handleChange} | ||
/> | ||
</div> | ||
|
||
<div className="button-wrapper"> | ||
<button type="reset" className="clear-button" onClick={clear}> | ||
Clear | ||
</button> | ||
<button type="submit" className="submit-button"> | ||
Submit | ||
</button> | ||
</div> | ||
</form> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import "../styles/Input.css" | ||
|
||
type InputProps = { | ||
label: string; | ||
name: string; | ||
handleChange: (event: React.ChangeEvent<HTMLInputElement>) => void; | ||
min?: string; | ||
}; | ||
|
||
export default function Input({ label, name, min, handleChange }: InputProps) { | ||
return ( | ||
<div className="input-group"> | ||
<p>{label}</p> | ||
<input name={name} min={min} type="number" onChange={handleChange} step="0.01"></input> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
"use client"; | ||
|
||
import { useState } from "react"; | ||
import Form from "./components/Form"; | ||
import "./styles/Main.css"; | ||
import Link from "next/link"; | ||
|
||
const containerSize = 20 // liters | ||
|
||
const tryOne = 20 // seconds | ||
const tryTwo = 25 | ||
const tryThree = 22 | ||
|
||
const sum = tryOne + tryTwo + tryThree | ||
|
||
const avg = sum / 3 | ||
|
||
const ingress = containerSize / avg // liters/second | ||
|
||
function printIngressFormula() { | ||
console.log("The ingress formula is: " + ingress + " liters/second"); | ||
} | ||
|
||
printIngressFormula() | ||
|
||
export default function ReservoirIngressFormula() { | ||
const [ingress, setIngress] = | ||
useState(0); | ||
|
||
const handleCalculate = (calculatedValue: number) => { | ||
setIngress(calculatedValue); | ||
}; | ||
|
||
return ( | ||
<div className="page"> | ||
<div className="main-content-wrapper"> | ||
<div className="main-content"> | ||
<div className="header-wrapper"> | ||
<h1 className="page-header"> | ||
Reservoir Ingress Flow Rate Formula | ||
</h1> | ||
</div> | ||
<div className="form-wrapper"> | ||
<Form onCalculate={handleCalculate}></Form> | ||
</div> | ||
<div className="result-wrapper"> | ||
<h2>The flow rate for the reservoir ingress is:</h2> | ||
<div className="result-container"> | ||
<div> | ||
<p className="answer"> | ||
{ingress.toFixed(2)} L/s | ||
</p> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
<div className="footer"> | ||
<Link href="/">Return to home</Link> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
.form { | ||
display: flex; | ||
align-items: center; | ||
justify-content: space-around; | ||
flex-direction: column; | ||
width: 100%; | ||
height: 100%; | ||
} | ||
|
||
.input-wrapper { | ||
height: 80%; | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: space-around; | ||
} | ||
.button-wrapper { | ||
height: 20%; | ||
width: 100%; | ||
display: flex; | ||
flex-direction: column; | ||
} | ||
|
||
.button-wrapper button { | ||
height: 45%; | ||
border-radius: 5px; | ||
} | ||
|
||
.clear-button { | ||
width: 25%; | ||
background-color: #6c6b6b; | ||
color: white; | ||
font-weight: bold; | ||
margin: auto; | ||
} | ||
|
||
.clear-button:hover { | ||
background-color: rgb(63, 62, 62); | ||
} | ||
|
||
.submit-button { | ||
width: 25%; | ||
background-color: rgb(72, 72, 198); | ||
color: white; | ||
font-weight: bold; | ||
margin: auto; | ||
} | ||
|
||
.submit-button:hover { | ||
background-color: darkblue; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
.input-group { | ||
width: 100%; | ||
height: 30%; | ||
display: flex; | ||
flex-direction: column; | ||
margin: auto; | ||
} | ||
|
||
input { | ||
width: 100%; | ||
height: 50%; | ||
font-size: 100%; | ||
padding-left: 1%; | ||
border: 2px solid black; | ||
border-radius: 5px; | ||
} | ||
|
||
p { | ||
font-size: large; | ||
font-weight: bold; | ||
font-family: Verdana; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
.page { | ||
width: 100vw; | ||
height: 100vh; | ||
min-height: 1000px; | ||
overflow-y: auto; | ||
display: flex; | ||
align-items: center; | ||
margin: auto; | ||
color: var(--dark-text); | ||
background-color: rgb(236, 236, 236); | ||
} | ||
|
||
.main-content-wrapper { | ||
width: 50%; | ||
height: 90%; | ||
min-height: 900px; | ||
padding: 2%; | ||
display: flex; | ||
align-items: center; | ||
flex-direction: column; | ||
margin: auto; | ||
background-color: white; | ||
border: 1px solid black; | ||
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); /* Shadow for depth */ | ||
} | ||
|
||
.back-button { | ||
width: 75px; | ||
height: 45px; | ||
position: fixed; | ||
bottom: 0; | ||
left: 0; | ||
font-size: large; | ||
font-weight: bold; | ||
} | ||
.main-content { | ||
height: 95%; | ||
display: flex; | ||
flex-direction: column; | ||
flex-grow: 1; | ||
} | ||
|
||
.footer { | ||
height: 5%; | ||
width: 100%; | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: flex-end; | ||
} | ||
|
||
.footer a { | ||
color: blue; | ||
text-decoration: underline; | ||
} | ||
|
||
.footer a:hover { | ||
color: darkblue; | ||
} | ||
|
||
.header-wrapper { | ||
height: 10%; | ||
padding-top: 5%; | ||
min-height: 150px; | ||
text-align: center; | ||
font-family: Verdana; | ||
display: flex; | ||
} | ||
|
||
.form-wrapper { | ||
height: 65%; | ||
min-height: 500px; | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: space-around; | ||
} | ||
|
||
.result-wrapper { | ||
margin-top: 2.5%; | ||
padding-top: 2.5%; | ||
border-top: 2px solid black; | ||
display: flex; | ||
height: 25%; | ||
flex-direction: column; | ||
text-align: center; | ||
} | ||
|
||
.result-container { | ||
height: 80%; | ||
margin: auto; | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: space-evenly; | ||
} | ||
.result-wrapper h2 { | ||
height: 15%; | ||
} | ||
|
||
.answer { | ||
font-size: 2rem; | ||
/* min-height: 200px; */ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a little unclear on the wording to use here:
"Reservoir Ingress Flow Rate" vs. just "Flow Rate" etc.
Also wasn't sure whether to re-label everything as Flow Rate instead of Reservoir Ingress, e.g. URL path, title of the page, wording in the description, and code variable references
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Waiting on a translation to put description hereedit: NVM. Description will be added in #12