Skip to content

Commit

Permalink
Merge branch 'main' into feat/2024updates
Browse files Browse the repository at this point in the history
  • Loading branch information
BrandonTheBusyBeaver117 committed Mar 10, 2024
2 parents e85aeb4 + 603cf43 commit 538c668
Show file tree
Hide file tree
Showing 3 changed files with 325 additions and 325 deletions.
4 changes: 2 additions & 2 deletions src/components/Scout.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,8 @@ const Scout = () => {
<>
<Toggle prop="scoreTrap" phase label="Score Trap" trueLabel = "Scored Trap" color="green" width="fiveTwelfths" height="twoHigh"></Toggle>
<Toggle prop="harmonize" phase label="Harmonize" trueLabel = "Harmonized" color="yellow" width={"fiveTwelfths"} height="twoHigh"></Toggle>
<Toggle prop="park" phase label="Park" trueLabel = "Parked" color="purple" width={"fiveTwelfths"} height="twoHigh"></Toggle>
<Numbers label="Climb Time of start (secs)" idealLength = {2} prop="climbTimeOfStart" width = "fiveTwelfths" twoLines={false} height = "twoHigh"></Numbers>
<Toggle prop="park" phase label="Park" trueLabel = "Parked" color="purple" width={"fiveTwelfths"} height="twoHigh"></Toggle>
<Numbers label="Climb Time of start (secs)" phase idealLength = {2} prop="climbTimeOfStart" width = "fiveTwelfths" twoLines={false} height = "twoHigh"></Numbers>
<Undo width = "fiveTwelfths" height = "twoHigh"></Undo>

<Next width ="fiveTwelfths" height = "twoHigh"></Next>
Expand Down
106 changes: 53 additions & 53 deletions src/components/inputs/Numbers.jsx
Original file line number Diff line number Diff line change
@@ -1,53 +1,53 @@
import React, { useContext } from "react"
import { Context } from "../../state"
import PropTypes from "prop-types"

import "./inputs.scss"

const Numbers = ({ label, prop, idealLength = 4, width, twoLines, height }) => {

const [state, dispatch] = useContext(Context)
const id = `Numbers-${label}-${prop}`.replaceAll(" ", "_")

const numberInputComponent = <>
<label htmlFor={id} className={`${twoLines ? "default" : ""}`}>
{label}
</label>
<input
id={id}
type="number"
pattern="[0-9]*"
placeholder={"0".repeat(idealLength)}
autoComplete="off"
className={`${width ? width : "wide"}`}
onChange={(event) => {
dispatch({
type: "set",
prop,
val: !(
event.target.value === undefined || event.target.value === ""
)
? parseInt(event.target.value)
: undefined,
})
}}
value={state[prop] ?? ""}
/>
</>

return twoLines ? numberInputComponent : (
<div className={`Numbers ${ width ? width :"wide"} ${height}`}>
{numberInputComponent}
</div>
)
}

Numbers.propTypes = {
label: PropTypes.string.isRequired,
prop: PropTypes.string.isRequired,
idealLength: PropTypes.number,
width: PropTypes.string,
twoLines: PropTypes.bool,
}

export default Numbers
import React, { useContext } from "react"
import { Context } from "../../state"
import PropTypes from "prop-types"

import "./inputs.scss"

const Numbers = ({ label, prop, phase, idealLength = 4, width, twoLines, height }) => {

const [state, dispatch] = useContext(Context)
const id = `Numbers-${label}-${prop}`.replaceAll(" ", "_")

const numberInputComponent = <>
<label htmlFor={id} className={`${twoLines ? "default" : ""}`}>
{label}
</label>
<input
id={id}
type="number"
pattern="[0-9]*"
placeholder={"0".repeat(idealLength)}
autoComplete="off"
className={`${width ? width : "wide"}`}
onChange={(event) => {
dispatch({
type: `set${phase ? "InPhase" : ""}`,
prop,
val: !(
event.target.value === undefined || event.target.value === ""
)
? parseInt(event.target.value)
: undefined,
})
}}
value={state[prop] ?? ""}
/>
</>

return twoLines ? numberInputComponent : (
<div className={`Numbers ${ width ? width :"wide"} ${height}`}>
{numberInputComponent}
</div>
)
}

Numbers.propTypes = {
label: PropTypes.string.isRequired,
prop: PropTypes.string.isRequired,
idealLength: PropTypes.number,
width: PropTypes.string,
twoLines: PropTypes.bool,
}

export default Numbers
Loading

0 comments on commit 538c668

Please sign in to comment.