-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
104 additions
and
21 deletions.
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
This file was deleted.
Oops, something went wrong.
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,56 @@ | ||
import { ChangeEvent, useContext, useState } from "react"; | ||
import Check from "./icons/Check"; | ||
import GlobalContext from "../contexts/globalContext"; | ||
|
||
const Base = () => { | ||
const [value, setValue] = useState(16); | ||
const { changeBase } = useContext(GlobalContext)!; | ||
const [isFocused, setIsFocused] = useState(false); | ||
|
||
const handleChange = (event: ChangeEvent<HTMLInputElement>) => { | ||
const { value, min, max } = event.target; | ||
const newValue = Math.max( | ||
Number(min), | ||
Math.min(Number(max), Number(value)), | ||
); | ||
|
||
setValue(newValue); | ||
}; | ||
|
||
const handleDone = () => changeBase(value); | ||
|
||
return ( | ||
<div className="flex flex-col items-baseline sm:flex-row"> | ||
<h3 | ||
className="mb-[0.5rem] min-w-[8rem] text-secondary-text" | ||
children="Base" | ||
/> | ||
|
||
<div className="relative max-w-[8rem] "> | ||
<input | ||
onFocus={() => setIsFocused(true)} | ||
onBlur={() => setIsFocused(false)} | ||
min={1} | ||
max={999} | ||
type="number" | ||
className="text-secondary w-full rounded-inner border border-primary-color-500 bg-transparent p-[0.5rem] text-primary-text" | ||
value={value} | ||
onChange={handleChange} | ||
/> | ||
<button | ||
className="absolute right-[0] h-full rounded-r-inner border border-primary-color-500 bg-primary-color-500 px-[1rem] hover:bg-primary-color-700" | ||
onClick={handleDone} | ||
> | ||
<Check /> | ||
</button> | ||
{isFocused && ( | ||
<p className="absolute -bottom-[0.25rem] left-[0] translate-y-full whitespace-nowrap text-[1rem] text-tertiary-text"> | ||
TIP: 16 is a good start | ||
</p> | ||
)} | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Base; |
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
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
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,18 @@ | ||
const Check = () => { | ||
return ( | ||
<svg | ||
width="15" | ||
height="15" | ||
viewBox="0 0 15 15" | ||
fill="none" | ||
xmlns="http://www.w3.org/2000/svg" | ||
> | ||
<path | ||
d="M5.62509 10.1063L3.45634 7.93752C3.33948 7.82066 3.18098 7.755 3.01572 7.755C2.85045 7.755 2.69195 7.82066 2.57509 7.93752C2.45823 8.05438 2.39258 8.21288 2.39258 8.37814C2.39258 8.45997 2.4087 8.541 2.44001 8.61661C2.47133 8.69221 2.51723 8.7609 2.57509 8.81877L5.18759 11.4313C5.43134 11.675 5.82509 11.675 6.06884 11.4313L12.6813 4.81877C12.7982 4.70191 12.8639 4.54341 12.8639 4.37814C12.8639 4.21288 12.7982 4.05438 12.6813 3.93752C12.5645 3.82066 12.406 3.755 12.2407 3.755C12.0754 3.755 11.917 3.82066 11.8001 3.93752L5.62509 10.1063Z" | ||
fill="currentColor" | ||
/> | ||
</svg> | ||
); | ||
}; | ||
|
||
export default Check; |
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
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